mateamt/src/Types/Purchase.hs

46 lines
1,020 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
2022-07-17 19:28:22 +00:00
import Data.OpenApi (ToSchema)
2019-07-18 17:01:49 +00:00
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
2022-07-17 19:28:22 +00:00
instance ToSchema 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
2022-07-17 19:28:22 +00:00
instance ToSchema PurchaseResult
2019-07-20 16:36:47 +00:00
data PurchaseResultFlag
2019-07-18 17:01:49 +00:00
= PurchaseOK
| PurchaseDebtful
| PayAmount Int
2021-07-14 01:08:58 +00:00
deriving (Generic, Show, Eq)
2019-07-18 17:01:49 +00:00
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
2022-07-17 19:28:22 +00:00
instance ToSchema PurchaseResultFlag