mateamt/src/API.hs

177 lines
5.1 KiB
Haskell
Raw Normal View History

2019-04-15 20:23:25 +00:00
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
module API where
import Servant.API
2019-09-16 07:00:11 +00:00
import Servant.Links
2019-09-07 18:05:24 +00:00
import Servant.RawM
2019-04-15 20:23:25 +00:00
2019-09-16 07:00:11 +00:00
import Data.Proxy
2019-04-15 20:23:25 +00:00
-- internal imports
import Types
2019-12-19 01:40:54 +00:00
type MateAPI = "v1" :> (
"auth" :> "get" :> ReqBody '[JSON] TicketRequest :> Post '[JSON] AuthInfo
2019-08-06 18:15:54 +00:00
:<|> "auth" :> ReqBody '[JSON] AuthRequest :> Post '[JSON] AuthResult
2019-09-15 12:59:22 +00:00
:<|> "auth" :> AuthProtect "header-auth" :> Delete '[JSON] ()
2019-08-06 18:15:54 +00:00
2019-09-16 06:59:57 +00:00
:<|> "auth" :> "manage" :> AuthProtect "header-auth"
:> Get '[JSON] [AuthOverview]
:<|> "auth" :> "manage" :> AuthProtect "header-auth"
:> ReqBody '[JSON] AuthSubmit :> Post '[JSON] Int
:<|> "auth" :> "manage" :> AuthProtect "header-auth"
:> ReqBody '[JSON] Int :> Delete '[JSON] ()
2019-08-06 18:15:54 +00:00
:<|> "user" :> ReqBody '[JSON] UserSubmit :> Post '[JSON] Int
:<|> "user" :> AuthProtect "header-auth" :> Get '[JSON] UserDetails
2019-08-06 18:15:54 +00:00
:<|> "user" :> AuthProtect "header-auth"
2019-09-16 06:59:57 +00:00
:> ReqBody '[JSON] UserDetailsSubmit :> Patch '[JSON] ()
2019-09-09 10:53:07 +00:00
:<|> "user" :> "list" :> QueryParam "refine" UserRefine :> Get '[JSON] [UserSummary]
2019-08-14 16:03:51 +00:00
:<|> "user" :> "recharge" :> AuthProtect "header-auth"
:> ReqBody '[JSON] UserRecharge :> Post '[JSON] ()
2019-09-06 19:43:46 +00:00
:<|> "user" :> "transfer" :> AuthProtect "header-auth"
:> ReqBody '[JSON] UserTransfer :> Post '[JSON] ()
2019-08-06 18:15:54 +00:00
:<|> "product" :> AuthProtect "header-auth" :> ReqBody '[JSON] ProductSubmit
:> Post '[JSON] Int
:<|> "product" :> Capture "pid" Int :> Get '[JSON] ProductOverview
:<|> "product" :> AuthProtect "header-auth"
:> ReqBody '[JSON] [AmountRefill] :> Patch '[JSON] ()
:<|> "product" :> AuthProtect "header-auth"
:> ReqBody '[JSON] [AmountUpdate] :> Put '[JSON] ()
2019-09-09 10:57:08 +00:00
:<|> "product" :> "list" :> QueryParam "refine" ProductRefine
:> Get '[JSON] [ProductOverview]
:<|> "product" :> "shortlist" :> QueryParam "refine" ProductRefine
:> Get '[JSON] [ProductShortOverview]
2019-08-06 18:15:54 +00:00
2019-07-18 17:01:49 +00:00
:<|> "buy" :> AuthProtect "header-auth" :> ReqBody '[JSON] [PurchaseDetail]
:> Post '[JSON] PurchaseResult
2019-08-08 16:59:23 +00:00
:<|> "journal" :> AuthProtect "header-auth" :> QueryParam "limit" Int
2019-12-11 23:47:46 +00:00
:> QueryParam "offset" Int
:> Get '[JSON] [JournalEntry]
:<|> "journal" :> AuthProtect "header-auth"
:> ReqBody '[JSON] JournalCashCheck
:> Post '[JSON] ()
2019-09-07 18:05:24 +00:00
:<|> "avatar" :> Capture "id" Int :> RawM
:<|> "avatar" :> AuthProtect "header-auth" :> ReqBody '[JSON] AvatarData
:> Post '[JSON] Int
:<|> "avatar" :> AuthProtect "header-auth" :> Capture "id" Int
:> ReqBody '[JSON] AvatarData :> Patch '[JSON] ()
:<|> "avatar" :> "list" :> Get '[JSON] [Avatar]
2019-09-16 07:00:11 +00:00
2020-07-19 06:27:15 +00:00
:<|> "role" :> "list"
:> Get '[JSON] [Role]
:<|> "role" :> AuthProtect "header-auth" :> ReqBody '[JSON] RoleSubmit
:> Post '[JSON] Int
:<|> "role" :> AuthProtect "header-auth" :> Capture "rid" Int
:> ReqBody '[JSON] RoleSubmit
2020-07-19 06:27:15 +00:00
:> Patch '[JSON] ()
:<|> "role" :> AuthProtect "header-auth" :> ReqBody '[JSON] Int
:> Delete '[JSON] ()
2020-07-19 10:27:28 +00:00
:<|> "role" :> "association" :> "list"
2020-07-19 06:27:15 +00:00
:> Get '[JSON] [RoleAssociation]
:<|> "role" :> "association" :> AuthProtect "header-auth"
:> ReqBody '[JSON] RoleAssociationSubmit
:> Post '[JSON] ()
2020-07-19 06:27:15 +00:00
:<|> "role" :> "association" :> AuthProtect "header-auth"
:> ReqBody '[JSON] RoleAssociation
2020-07-19 06:27:15 +00:00
:> Delete '[JSON] ()
2019-12-19 01:40:54 +00:00
:<|> "meta" :> Get '[JSON] MetaInformation
)
2019-09-16 07:00:11 +00:00
2019-10-14 20:50:42 +00:00
authGetLink :: Link
authSendLink :: Link
authLogoutLink :: Link
2019-09-16 07:00:11 +00:00
2019-10-14 20:50:42 +00:00
authManageListLink :: Link
authManageNewAuthLink :: Link
authManageDeleteAuthLink :: Link
2019-09-16 07:00:11 +00:00
2019-10-14 20:50:42 +00:00
userNewLink :: Link
userGetLink :: Link
userUpdateLink :: Link
userListLink :: Maybe UserRefine -> Link
userRechargeLink :: Link
userTransferLink :: Link
2019-09-16 07:00:11 +00:00
2019-10-14 20:50:42 +00:00
productNewLink :: Link
productOverviewLink :: Int -> Link
productStockRefillLink :: Link
productStockUpdateLink :: Link
productListLink :: Maybe ProductRefine -> Link
productShortListLink :: Maybe ProductRefine -> Link
2019-09-16 07:00:11 +00:00
2019-10-14 20:50:42 +00:00
buyLink :: Link
2019-09-16 07:00:11 +00:00
2019-10-14 20:50:42 +00:00
journalShowLink :: Maybe Int -> Maybe Int -> Link
2019-12-11 23:47:46 +00:00
journalPostCheck :: Link
2019-09-16 07:00:11 +00:00
2019-12-11 23:48:57 +00:00
avatarGetLink :: Int -> Link
2019-10-14 20:50:42 +00:00
avaterInsertLink :: Link
avatarUpdateLink :: Int -> Link
avatarListLink :: Link
2020-07-19 06:27:15 +00:00
roleListLink :: Link
roleNewLink :: Link
roleUpdateLink :: Int -> Link
2020-07-19 06:27:15 +00:00
roleDeleteLink :: Link
roleAssociationListLink :: Link
roleAssociationSubmitLink :: Link
roleAssociationDeleteLink :: Link
2019-12-19 01:40:54 +00:00
metaGetLink :: Link
2019-11-15 17:51:51 +00:00
( authGetLink :<|>
authSendLink :<|>
authLogoutLink :<|>
2019-10-14 20:50:42 +00:00
2019-11-15 17:51:51 +00:00
authManageListLink :<|>
authManageNewAuthLink :<|>
authManageDeleteAuthLink :<|>
2019-10-14 20:50:42 +00:00
2019-11-15 17:51:51 +00:00
userNewLink :<|>
userGetLink :<|>
userUpdateLink :<|>
userListLink :<|>
userRechargeLink :<|>
userTransferLink :<|>
2019-10-14 20:50:42 +00:00
2019-11-15 17:51:51 +00:00
productNewLink :<|>
productOverviewLink :<|>
productStockRefillLink :<|>
productStockUpdateLink :<|>
productListLink :<|>
productShortListLink :<|>
2019-10-14 20:50:42 +00:00
2019-11-15 17:51:51 +00:00
buyLink :<|>
2019-10-14 20:50:42 +00:00
2019-11-15 17:51:51 +00:00
journalShowLink :<|>
2019-12-11 23:47:46 +00:00
journalPostCheck :<|>
2019-10-14 20:50:42 +00:00
2019-11-15 17:51:51 +00:00
avatarGetLink :<|>
avaterInsertLink :<|>
avatarUpdateLink :<|>
2019-12-19 01:40:54 +00:00
avatarListLink :<|>
2020-07-19 06:27:15 +00:00
roleListLink :<|>
roleNewLink :<|>
roleUpdateLink :<|>
roleDeleteLink :<|>
roleAssociationListLink :<|>
roleAssociationSubmitLink :<|>
roleAssociationDeleteLink :<|>
2019-12-19 01:40:54 +00:00
metaGetLink
2019-09-16 07:00:11 +00:00
) = allLinks (Proxy :: Proxy MateAPI)