2019-09-08 10:48:57 +00:00
|
|
|
{-# 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 :<|>
|
|
|
|
|
2019-09-15 22:00:15 +00:00
|
|
|
authManageList :<|>
|
|
|
|
authManageNewAuth :<|>
|
|
|
|
authManageDeleteAuth :<|>
|
|
|
|
|
2019-09-08 10:48:57 +00:00
|
|
|
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)
|