mateamt/src/Types/Purchase.hs

44 lines
884 B
Haskell
Raw Normal View History

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-10-27 21:46:07 +00:00
{ purchaseDetailProduct :: 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