aboutsummaryrefslogtreecommitdiff
path: root/servant/api/Thermoprint/Api.hs
diff options
context:
space:
mode:
Diffstat (limited to 'servant/api/Thermoprint/Api.hs')
-rw-r--r--servant/api/Thermoprint/Api.hs35
1 files changed, 0 insertions, 35 deletions
diff --git a/servant/api/Thermoprint/Api.hs b/servant/api/Thermoprint/Api.hs
deleted file mode 100644
index f3318c4..0000000
--- a/servant/api/Thermoprint/Api.hs
+++ /dev/null
@@ -1,35 +0,0 @@
1{-# LANGUAGE DataKinds, TypeOperators, DeriveGeneric #-}
2
3module Thermoprint.Api
4 ( ThermoprintApi
5 ) where
6
7import Thermoprint
8import Data.Aeson
9import Servant.API
10import qualified Data.Text.Lazy as Text
11import qualified Data.ByteString.Lazy.Char8 as ByteString
12import Data.ByteString.Lazy.Char8 (ByteString)
13import GHC.Generics
14
15import Control.Monad
16
17import Data.Int (Int64)
18
19instance ToJSON ByteString where
20 toJSON = toJSON . Text.pack . ByteString.unpack
21instance FromJSON ByteString where
22 parseJSON value = (ByteString.pack . Text.unpack) `liftM` parseJSON value
23
24instance ToJSON c => ToJSON (Inline c)
25instance FromJSON c => FromJSON (Inline c)
26
27instance ToJSON c => ToJSON (Block c)
28instance FromJSON c => FromJSON (Block c)
29
30type ThermoprintApi = "print" :> Capture "printerId" Integer :> ReqBody '[JSON] (Block String) :> Post '[JSON] ()
31 :<|> "drafts" :> Get '[JSON] [(Int64, String)]
32 :<|> "drafts" :> ReqBody '[JSON] (String, Block String) :> Put '[JSON] Int64
33 :<|> "drafts" :> Capture "draftId" Int64 :> Get '[JSON] (String, Block String)
34 :<|> "drafts" :> Capture "draftId" Int64 :> ReqBody '[JSON] (String, Block String) :> Put '[JSON] ()
35 :<|> "drafts" :> Capture "draftId" Int64 :> Delete '[JSON] ()