matebeamter/src/API.hs

111 lines
3.3 KiB
Haskell

{-# OPTIONS_GHC -fno-warn-missing-signatures #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE PackageImports #-}
module API where
import Servant.API
import Servant.Links
-- import Servant.RawM
import Servant.HTML.Blaze
import Data.Proxy
import qualified Data.Text as T
-- imports from "mateamt"
import qualified "mateamt" Types as MT
-- internal imports
import Types
type UserAPI =
Header "Cookie" T.Text :> (Get '[HTML] UserSelectPage
:<|> "user" :> Capture "id" Int :> QueryParam "refine" MT.ProductRefine
:> Get '[HTML] UserOverviewPage
:<|> "user" :> Capture "id" Int :> "buy"
:> ReqBody '[FormUrlEncoded] [MT.PurchaseDetail]
:> QueryFlag "force"
:> Post '[HTML] BuyConfirmPage
:<|> "user" :> Capture "id" Int :> "purchasecomplete"
:> ReqBody '[FormUrlEncoded] [MT.PurchaseDetail]
:> QueryFlag "force"
:> Post '[HTML] UserSelectPage
:<|> "user" :> Capture "id" Int :> "recharge"
:> Get '[HTML] UserRechargePage
:<|> "user" :> Capture "id" Int :> "recharge"
:> ReqBody '[FormUrlEncoded] UserRecharge
:> Post '[HTML] UserOverviewPage
:<|> "user" :> Capture "id" Int :> "manage" :> Get '[HTML] UserManagePage
:<|> "user" :> Capture "id" Int :> "manage"
:> ReqBody '[FormUrlEncoded] MT.UserDetailsSubmit
:> Post '[HTML] UserManagePage
:<|> "user" :> Capture "id" Int :> "manage" :> "authcreate"
:> ReqBody '[FormUrlEncoded] AuthSubmitReturn
:> Post '[HTML] UserManagePage
:<|> "user" :> Capture "id" Int :> "manage" :> "authdelete"
:> ReqBody '[FormUrlEncoded] AuthDetailId
:> Post '[HTML] UserManagePage
:<|> "user" :> "create" :> Get '[HTML] UserNewPage
:<|> "user" :> "create" :> ReqBody '[FormUrlEncoded] MT.UserSubmit
:> Post '[HTML] UserSelectPage
:<|> "buy"
:> QueryParam "refine" MT.ProductRefine
:> Get '[HTML] CashBuyOverviewPage
:<|> "buy"
-- :> QueryFlag "force"
:> ReqBody '[FormUrlEncoded] [MT.PurchaseDetail]
:> Post '[HTML] CashBuyConfirmPage
:<|> "journal" :> QueryParam "page" Word
:> Get '[HTML] JournalPage
:<|> "journal" :> "check"
:> Get '[HTML] JournalCheckPage
:<|> "journal" :> "check"
:> ReqBody '[FormUrlEncoded] CashCheck
:> Post '[HTML] JournalPage
:<|> "product" :> "list"
:> Get '[HTML] ProductPriceListPage
:<|> "auth"
:> QueryParam "destination" T.Text
:> Get '[HTML]
(Headers
'[ Header "Set-Cookie" T.Text
, Header "Set-Cookie" T.Text
]
AuthPage)
:<|> "auth" :> QueryParam "destination" T.Text
:> ReqBody '[FormUrlEncoded] AuthReturn
:> Post '[HTML] UserSelectPage
:<|> "auth" :> "logout"
:> Post '[HTML] UserOverviewPage
)
( userSelectLink :<|>
userOverviewLink :<|>
buyLink :<|>
purchaseCompleteLink :<|>
userRechargeLink :<|>
userPostRechargeLink :<|>
userManageLink :<|>
userManageDetailsSubmitLink :<|>
userManageAuthCreateLink :<|>
userManageAuthDeleteLink :<|>
userNewLink :<|>
userNewPostLink :<|>
cashBuyLink :<|>
cashBuyPostLink :<|>
journalLink :<|>
journalGetCheckLink :<|>
journalPostCheckLink :<|>
productGetPriceListLink :<|>
authLink :<|>
authPostLink :<|>
authLogoutLink
) = allLinks (Proxy :: Proxy UserAPI)