2019-07-18 17:01:49 +00:00
|
|
|
{-# LANGUAGE DeriveGeneric #-}
|
|
|
|
|
|
|
|
module Types.Purchase where
|
|
|
|
|
2019-07-20 16:36:47 +00:00
|
|
|
import Data.Aeson
|
|
|
|
|
2019-07-18 17:01:49 +00:00
|
|
|
import GHC.Generics
|
|
|
|
|
|
|
|
|
|
|
|
data PurchaseDetail = PurchaseDetail
|
2019-07-28 09:55:22 +00:00
|
|
|
{ purchaseDetailBeverage :: Int
|
|
|
|
, purchaseDetailAmount :: Int
|
2019-07-18 17:01:49 +00:00
|
|
|
}
|
2019-07-20 16:36:47 +00:00
|
|
|
deriving (Generic, Show)
|
2019-07-18 17:01:49 +00:00
|
|
|
|
|
|
|
instance ToJSON PurchaseDetail where
|
|
|
|
toEncoding = genericToEncoding defaultOptions
|
|
|
|
|
2019-07-20 16:36:47 +00:00
|
|
|
instance FromJSON PurchaseDetail
|
|
|
|
|
2019-07-18 17:01:49 +00:00
|
|
|
|
2019-07-20 16:36:47 +00:00
|
|
|
data PurchaseResult = PurchaseResult
|
2019-07-28 09:55:22 +00:00
|
|
|
{ purchaseResultFlag :: PurchaseResultFlag
|
|
|
|
, purchaseResultMissingItems :: [PurchaseDetail]
|
2019-07-20 16:36:47 +00:00
|
|
|
}
|
|
|
|
deriving (Generic, Show)
|
2019-07-18 17:01:49 +00:00
|
|
|
|
2019-07-20 16:36:47 +00:00
|
|
|
instance ToJSON PurchaseResult where
|
|
|
|
toEncoding = genericToEncoding defaultOptions
|
|
|
|
|
|
|
|
instance FromJSON PurchaseResult
|
|
|
|
|
|
|
|
|
|
|
|
data PurchaseResultFlag
|
2019-07-18 17:01:49 +00:00
|
|
|
= PurchaseOK
|
|
|
|
| PurchaseDebtful
|
|
|
|
| PayAmount Int
|
|
|
|
deriving (Generic, Show)
|
|
|
|
|
2019-07-20 16:36:47 +00:00
|
|
|
instance ToJSON PurchaseResultFlag where
|
2019-07-18 17:01:49 +00:00
|
|
|
toEncoding = genericToEncoding defaultOptions
|
|
|
|
|
2019-07-20 16:36:47 +00:00
|
|
|
instance FromJSON PurchaseResultFlag
|