syntax = "v1"

type (
	NotificationPublic {
		Id        string `json:"id"`
		Title     string `json:"title"`
		Body      string `json:"body"`
		Kind      string `json:"kind"` // job|system
		RefType   string `json:"ref_type"`
		RefId     string `json:"ref_id,optional"`
		ReadAt    int64  `json:"read_at,optional"`
		CreatedAt int64  `json:"created_at"`
	}

	NotificationListData {
		List []NotificationPublic `json:"list"`
	}

	UnreadCountData {
		Count int64 `json:"count"`
	}

	NotificationIdPath {
		Id string `path:"id"`
	}
)

@server (
	jwt:        Auth
	group:      notifications
	prefix:     /api/v1/notifications
	middleware: AuthJWT
)
service gateway {
	@handler ListNotifications
	get / returns (NotificationListData)

	@handler UnreadNotificationCount
	get /unread-count returns (UnreadCountData)

	@handler MarkNotificationRead
	post /:id/read (NotificationIdPath) returns (OkData)

	@handler MarkAllNotificationsRead
	post /read-all returns (OkData)
}
