mateamt/src/API.hs

49 lines
1.5 KiB
Haskell
Raw Normal View History

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 Data.Text
import Data.Time (UTCTime)
import Servant.API
-- internal imports
import Model as M
import Types
2019-04-16 04:23:08 +00:00
type UserAPI =
"user" :>
2019-05-16 02:07:20 +00:00
( "list" :> AuthProtect "header-auth"
:> QueryParam "refine" Refine :> Get '[JSON] [User]
2019-04-16 04:23:08 +00:00
:<|> "new" :> ReqBody '[JSON] UserSubmit :> Post '[JSON] Int
2019-05-16 16:37:04 +00:00
:<|> "details" :> AuthProtect "header-auth"
:> Capture "id" Int :> Get '[JSON] UserDetails
:<|> "details" :> AuthProtect "header-auth"
:> Capture "id" Int :> ReqBody '[JSON] UserDetailsSubmit :> Post '[JSON] ()
2019-04-16 04:23:08 +00:00
)
2019-07-18 15:09:26 +00:00
:<|> "product" :>
( "list" :> Get '[JSON] [Product]
:<|> "new" :> AuthProtect "header-auth" :> ReqBody '[JSON] ProductSubmit
2019-07-18 12:57:35 +00:00
:> Post '[JSON] Int
:<|> "update" :> AuthProtect "header-auth"
2019-07-18 15:09:26 +00:00
:> Capture "id" Int :> ReqBody '[JSON] ProductSubmit :> Post '[JSON] ()
2019-07-18 12:57:35 +00:00
)
2019-07-18 17:01:49 +00:00
:<|> "buy" :> AuthProtect "header-auth" :> ReqBody '[JSON] [PurchaseDetail]
:> Post '[JSON] PurchaseResult
2019-04-17 05:51:15 +00:00
:<|> "auth" :>
( "get" :> ReqBody '[JSON] Int :> Post '[JSON] AuthInfo
:<|> "send" :> ReqBody '[JSON] AuthRequest :> Post '[JSON] AuthResult
2019-07-18 14:09:59 +00:00
:<|> "logout" :> AuthProtect "header-auth" :> ReqBody '[JSON] Int
:> Post '[JSON] ()
2019-04-17 05:51:15 +00:00
)