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-11-09 11:29:29 +00:00
|
|
|
:> QueryFlag "force"
|
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]
|
2019-11-09 11:29:29 +00:00
|
|
|
:> QueryFlag "force"
|
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
|
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-11-03 11:30:46 +00:00
|
|
|
:<|> "buy"
|
|
|
|
:> QueryParam "refine" MT.ProductRefine
|
|
|
|
:> Get '[HTML] CashBuyOverviewPage
|
|
|
|
:<|> "buy"
|
2019-11-09 11:29:29 +00:00
|
|
|
-- :> QueryFlag "force"
|
2019-11-03 11:30:46 +00:00
|
|
|
:> ReqBody '[FormUrlEncoded] [MT.PurchaseDetail]
|
|
|
|
:> Post '[HTML] CashBuyConfirmPage
|
2019-11-02 21:53:23 +00:00
|
|
|
:<|> "journal" :> QueryParam "page" Word
|
|
|
|
:> Get '[HTML] JournalPage
|
2019-12-11 03:12:19 +00:00
|
|
|
:<|> "journal" :> "check"
|
|
|
|
:> Get '[HTML] JournalCheckPage
|
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-11-01 11:22:28 +00:00
|
|
|
userRechargeLink :<|>
|
|
|
|
userPostRechargeLink :<|>
|
2019-10-14 13:07:17 +00:00
|
|
|
userManageLink :<|>
|
|
|
|
userManageDetailsSubmitLink :<|>
|
|
|
|
userManageAuthCreateLink :<|>
|
|
|
|
userManageAuthDeleteLink :<|>
|
2019-10-15 06:38:32 +00:00
|
|
|
userNewLink :<|>
|
|
|
|
userNewPostLink :<|>
|
2019-11-03 11:30:46 +00:00
|
|
|
cashBuyLink :<|>
|
|
|
|
cashBuyPostLink :<|>
|
2019-11-02 21:53:23 +00:00
|
|
|
journalLink :<|>
|
2019-12-11 03:12:19 +00:00
|
|
|
journalCheckLink :<|>
|
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)
|