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
|
2019-10-14 04:38:16 +00:00
|
|
|
:<|> "user" :> Capture "id" Int :> QueryParam "refine" MT.ProductRefine
|
2019-10-04 07:04:23 +00:00
|
|
|
:> Get '[HTML] UserOverviewPage
|
2019-10-22 03:54:55 +00:00
|
|
|
:<|> "user" :> Capture "id" Int :> "buy"
|
|
|
|
:> ReqBody '[FormUrlEncoded] [MT.PurchaseDetail]
|
2019-10-23 18:35:07 +00:00
|
|
|
:> Post '[HTML] BuyConfirmPage
|
2019-10-24 05:39:46 +00:00
|
|
|
:<|> "user" :> Capture "id" Int :> "purchasecomplete"
|
2019-10-23 18:35:07 +00:00
|
|
|
:> ReqBody '[FormUrlEncoded] [MT.PurchaseDetail]
|
|
|
|
:> Post '[HTML] UserSelectPage
|
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
|
2019-10-14 13:07:17 +00:00
|
|
|
:> Post '[HTML] UserManagePage
|
2019-10-15 06:38:32 +00:00
|
|
|
:<|> "user" :> Capture "id" Int :> "manage" :> "authcreate"
|
2019-10-14 13:07:17 +00:00
|
|
|
:> ReqBody '[FormUrlEncoded] AuthSubmitReturn
|
|
|
|
:> Post '[HTML] UserManagePage
|
2019-10-15 06:38:32 +00:00
|
|
|
:<|> "user" :> Capture "id" Int :> "manage" :> "authdelete"
|
2019-10-14 13:07:17 +00:00
|
|
|
:> 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"
|
2019-10-14 04:38:16 +00:00
|
|
|
:> 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)
|
2019-10-14 04:38:16 +00:00
|
|
|
:<|> "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 :<|>
|
2019-10-22 03:54:55 +00:00
|
|
|
buyLink :<|>
|
2019-10-23 18:35:07 +00:00
|
|
|
purchaseCompleteLink :<|>
|
2019-10-14 13:07:17 +00:00
|
|
|
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)
|