2019-04-15 20:23:25 +00:00
|
|
|
{-# LANGUAGE DataKinds #-}
|
|
|
|
{-# LANGUAGE TypeOperators #-}
|
|
|
|
{-# LANGUAGE DeriveGeneric #-}
|
|
|
|
{-# LANGUAGE FlexibleInstances #-}
|
|
|
|
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
|
|
|
|
{-# LANGUAGE MultiParamTypeClasses #-}
|
|
|
|
{-# LANGUAGE OverloadedStrings #-}
|
|
|
|
{-# LANGUAGE RankNTypes #-}
|
|
|
|
{-# LANGUAGE ScopedTypeVariables #-}
|
|
|
|
|
|
|
|
module API where
|
|
|
|
|
|
|
|
import Servant.API
|
|
|
|
|
|
|
|
-- internal imports
|
|
|
|
|
|
|
|
import Types
|
|
|
|
|
2019-04-16 04:23:08 +00:00
|
|
|
type UserAPI =
|
2019-09-06 19:42:08 +00:00
|
|
|
"auth" :> "get" :> ReqBody '[JSON] Int :> Post '[JSON] AuthInfo
|
2019-08-06 18:15:54 +00:00
|
|
|
:<|> "auth" :> ReqBody '[JSON] AuthRequest :> Post '[JSON] AuthResult
|
|
|
|
:<|> "auth" :> AuthProtect "header-auth" :> ReqBody '[JSON] Int
|
|
|
|
:> Delete '[JSON] ()
|
|
|
|
|
|
|
|
:<|> "user" :> ReqBody '[JSON] UserSubmit :> Post '[JSON] Int
|
|
|
|
:<|> "user" :> AuthProtect "header-auth"
|
|
|
|
:> Capture "uid'" Int :> Get '[JSON] UserDetails
|
|
|
|
:<|> "user" :> AuthProtect "header-auth"
|
|
|
|
:> Capture "uid'" Int :> ReqBody '[JSON] UserDetailsSubmit :> Patch '[JSON] ()
|
|
|
|
:<|> "user" :> "list" :> AuthProtect "header-auth"
|
|
|
|
:> QueryParam "refine" Refine :> Get '[JSON] [User]
|
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] ()
|
|
|
|
:<|> "product" :> "list" :> Get '[JSON] [ProductOverview]
|
|
|
|
|
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
|
|
|
|
:> QueryParam "offset" Int :> Get '[JSON] [JournalEntry]
|