mateamt/src/Types/Purchase.hs

46 lines
856 B
Haskell
Raw Normal View History

2019-07-18 17:01:49 +00:00
{-# LANGUAGE DeriveGeneric #-}
module Types.Purchase where
import Data.Text
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
{ pdBeverage :: Int
, pdAmount :: Int
}
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
{ prFlag :: PurchaseResultFlag
, prMissingItems :: [PurchaseDetail]
}
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