matebeamter/src/API.hs

90 lines
2.7 KiB
Haskell
Raw Normal View History

2019-10-16 16:07:12 +00:00
{-# OPTIONS_GHC -fno-warn-missing-signatures #-}
2019-09-08 00:37:50 +00:00
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
2019-09-17 19:29:56 +00:00
{-# LANGUAGE PackageImports #-}
2019-09-08 00:37:50 +00:00
module API where
import Servant.API
2019-09-16 07:44:46 +00:00
import Servant.Links
2019-10-16 16:07:12 +00:00
-- import Servant.RawM
2019-09-08 00:37:50 +00:00
import Servant.HTML.Blaze
2019-09-16 07:44:46 +00:00
import Data.Proxy
2019-10-04 07:04:23 +00:00
import qualified Data.Text as T
2019-09-17 19:29:56 +00:00
-- imports from "mateamt"
import qualified "mateamt" Types as MT
2019-09-08 00:37:50 +00:00
-- internal imports
import Types
type UserAPI =
2019-10-04 07:04:23 +00:00
Header "Cookie" T.Text :> (Get '[HTML] UserSelectPage
:<|> "user" :> Capture "id" Int :> QueryParam "refine" MT.ProductRefine
2019-10-04 07:04:23 +00:00
:> Get '[HTML] UserOverviewPage
:<|> "user" :> Capture "id" Int :> "buy"
:> ReqBody '[FormUrlEncoded] [MT.PurchaseDetail]
2019-10-24 16:05:22 +00:00
:> QueryParam "force" Bool
2019-10-23 18:35:07 +00:00
:> Post '[HTML] BuyConfirmPage
:<|> "user" :> Capture "id" Int :> "purchasecomplete"
2019-10-23 18:35:07 +00:00
:> ReqBody '[FormUrlEncoded] [MT.PurchaseDetail]
2019-10-24 16:05:22 +00:00
:> QueryParam "force" Bool
2019-10-23 18:35:07 +00:00
:> Post '[HTML] UserSelectPage
2019-11-01 11:22:28 +00:00
:<|> "user" :> Capture "id" Int :> "recharge"
:> Get '[HTML] UserRechargePage
:<|> "user" :> Capture "id" Int :> "recharge"
:> ReqBody '[FormUrlEncoded] UserRecharge
:> Post '[HTML] UserOverviewPage
2019-10-15 06:38:32 +00:00
:<|> "user" :> Capture "id" Int :> "manage" :> Get '[HTML] UserManagePage
:<|> "user" :> Capture "id" Int :> "manage"
:> ReqBody '[FormUrlEncoded] MT.UserDetailsSubmit
:> Post '[HTML] UserManagePage
2019-10-15 06:38:32 +00:00
:<|> "user" :> Capture "id" Int :> "manage" :> "authcreate"
:> ReqBody '[FormUrlEncoded] AuthSubmitReturn
:> Post '[HTML] UserManagePage
2019-10-15 06:38:32 +00:00
:<|> "user" :> Capture "id" Int :> "manage" :> "authdelete"
:> ReqBody '[FormUrlEncoded] AuthDetailId
:> Post '[HTML] UserManagePage
2019-10-15 06:38:32 +00:00
:<|> "user" :> "create" :> Get '[HTML] UserNewPage
:<|> "user" :> "create" :> ReqBody '[FormUrlEncoded] MT.UserSubmit
:> Post '[HTML] UserSelectPage
2019-10-04 07:04:23 +00:00
:<|> "auth"
:> QueryParam "destination" T.Text
2019-10-04 07:04:23 +00:00
:> Get '[HTML]
(Headers
'[ Header "Set-Cookie" T.Text
, Header "Set-Cookie" T.Text
]
AuthPage)
:<|> "auth" :> QueryParam "destination" T.Text
:> ReqBody '[FormUrlEncoded] AuthReturn
2019-10-04 07:04:23 +00:00
:> Post '[HTML] UserSelectPage
2019-10-14 18:10:30 +00:00
:<|> "auth" :> "logout"
:> Post '[HTML] UserOverviewPage
2019-10-04 07:04:23 +00:00
)
2019-09-16 07:44:46 +00:00
( userSelectLink :<|>
userOverviewLink :<|>
buyLink :<|>
2019-10-23 18:35:07 +00:00
purchaseCompleteLink :<|>
2019-11-01 11:22:28 +00:00
userRechargeLink :<|>
userPostRechargeLink :<|>
userManageLink :<|>
userManageDetailsSubmitLink :<|>
userManageAuthCreateLink :<|>
userManageAuthDeleteLink :<|>
2019-10-15 06:38:32 +00:00
userNewLink :<|>
userNewPostLink :<|>
2019-10-04 07:04:23 +00:00
authLink :<|>
2019-10-14 18:10:30 +00:00
authPostLink :<|>
authLogoutLink
2019-09-16 07:44:46 +00:00
) = allLinks (Proxy :: Proxy UserAPI)