65 lines
1.3 KiB
Haskell
65 lines
1.3 KiB
Haskell
|
{-# LANGUAGE DataKinds #-}
|
||
|
{-# LANGUAGE DeriveGeneric #-}
|
||
|
{-# LANGUAGE FlexibleContexts #-}
|
||
|
{-# LANGUAGE FlexibleInstances #-}
|
||
|
{-# LANGUAGE MultiParamTypeClasses #-}
|
||
|
{-# LANGUAGE OverloadedStrings #-}
|
||
|
{-# LANGUAGE ScopedTypeVariables #-}
|
||
|
{-# LANGUAGE TypeFamilies #-}
|
||
|
{-# LANGUAGE TypeOperators #-}
|
||
|
{-# LANGUAGE UndecidableInstances #-}
|
||
|
{-# LANGUAGE PackageImports #-}
|
||
|
module Client where
|
||
|
|
||
|
import Servant
|
||
|
import Servant.Client
|
||
|
|
||
|
import Network.HTTP.Client hiding (Proxy)
|
||
|
|
||
|
import Control.Monad.IO.Class (liftIO)
|
||
|
|
||
|
-- imports from mateamt
|
||
|
|
||
|
import qualified "mateamt" API as MT
|
||
|
import qualified "mateamt" Types as MT
|
||
|
|
||
|
-- internal imports
|
||
|
|
||
|
import Types
|
||
|
|
||
|
mateApi :: Proxy MT.MateAPI
|
||
|
mateApi = Proxy
|
||
|
|
||
|
( authGet :<|>
|
||
|
authSend :<|>
|
||
|
authLogout :<|>
|
||
|
|
||
|
userNew :<|>
|
||
|
userGet :<|>
|
||
|
userUpdate :<|>
|
||
|
userList :<|>
|
||
|
userRecharge :<|>
|
||
|
userTransfer :<|>
|
||
|
|
||
|
productNew :<|>
|
||
|
productOverview :<|>
|
||
|
productStockRefill :<|>
|
||
|
productStockUpdate :<|>
|
||
|
productList :<|>
|
||
|
|
||
|
buy :<|>
|
||
|
|
||
|
journalShow :<|>
|
||
|
|
||
|
avatarGet :<|>
|
||
|
avatarInsert :<|>
|
||
|
avatarUpdate :<|>
|
||
|
avatarList
|
||
|
) = client mateApi
|
||
|
|
||
|
getClients clientEnv = hoistClient
|
||
|
mateApi
|
||
|
( fmap (either (error . show) id)
|
||
|
. (`runClientM` mkClientEnv clientEnv (BaseUrl Http "localhost" 8000 "/")))
|
||
|
(client mateApi)
|