module Wire.API.Routes.Public.Gundeck where
import Data.Id (ClientId)
import Data.Range
import Imports
import Servant
import Wire.API.Error
import Wire.API.Error.Gundeck as E
import Wire.API.Notification
import Wire.API.Push.V2.Token
import Wire.API.Routes.API
import Wire.API.Routes.MultiVerb
import Wire.API.Routes.Named
import Wire.API.Routes.Public
import Wire.API.Routes.Version
type GundeckAPI = PushAPI :<|> NotificationAPI
type PushAPI =
Named
"register-push-token"
( Summary "Register a native push token"
:> ZUser
:> ZConn
:> "push"
:> "tokens"
:> ReqBody '[JSON] PushToken
:> MultiVerb 'POST '[JSON] AddTokenResponses (Either AddTokenError AddTokenSuccess)
)
:<|> Named
"delete-push-token"
( Summary "Unregister a native push token"
:> ZUser
:> "push"
:> "tokens"
:> Capture' '[Description "The push token to delete"] "pid" Token
:> MultiVerb 'DELETE '[JSON] DeleteTokenResponses (Maybe ())
)
:<|> Named
"get-push-tokens"
( Summary "List the user's registered push tokens"
:> ZUser
:> "push"
:> "tokens"
:> Get
'[JSON]
PushTokenList
)
type NotificationAPI =
Named
"get-notification-by-id"
( Summary "Fetch a notification by ID"
:> ZUser
:> "notifications"
:> Capture' '[Description "Notification ID"] "id" NotificationId
:> QueryParam' [Optional, Strict, Description "Only return notifications targeted at the given client"] "client" ClientId
:> MultiVerb
'GET
'[JSON]
'[ ErrorResponse 'E.NotificationNotFound,
Respond 200 "Notification found" QueuedNotification
]
(Maybe QueuedNotification)
)
:<|> Named
"get-last-notification"
( Summary "Fetch the last notification"
:> ZUser
:> "notifications"
:> "last"
:> QueryParam' [Optional, Strict, Description "Only return notifications targeted at the given client"] "client" ClientId
:> MultiVerb
'GET
'[JSON]
'[ ErrorResponse 'E.NotificationNotFound,
Respond 200 "Notification found" QueuedNotification
]
(Maybe QueuedNotification)
)
:<|> Named
"get-notifications@v2"
( Summary "Fetch notifications"
:> Until 'V3
:> ZUser
:> "notifications"
:> QueryParam' [Optional, Strict, Description "Only return notifications more recent than this"] "since" RawNotificationId
:> QueryParam' [Optional, Strict, Description "Only return notifications targeted at the given client"] "client" ClientId
:> QueryParam' [Optional, Strict, Description "Maximum number of notifications to return"] "size" (Range 100 10000 Int32)
:> MultiVerb
'GET
'[JSON]
'[ Respond 404 "Notification list" QueuedNotificationList,
Respond 200 "Notification list" QueuedNotificationList
]
GetNotificationsResponse
)
:<|> Named
"get-notifications"
( Summary "Fetch notifications"
:> From 'V3
:> ZUser
:> "notifications"
:> QueryParam' [Optional, Strict, Description "Only return notifications more recent than this"] "since" NotificationId
:> QueryParam' [Optional, Strict, Description "Only return notifications targeted at the given client"] "client" ClientId
:> QueryParam' [Optional, Strict, Description "Maximum number of notifications to return"] "size" (Range 100 10000 Int32)
:> MultiVerb
'GET
'[JSON]
'[ ErrorResponse 'E.NotificationNotFound,
Respond 200 "Notification list" QueuedNotificationList
]
(Maybe QueuedNotificationList)
)
data GundeckAPITag
instance ServiceAPI GundeckAPITag v where
type ServiceAPIRoutes GundeckAPITag = GundeckAPI