diff options
Diffstat (limited to 'src/Shop/Types.hs')
-rw-r--r-- | src/Shop/Types.hs | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/src/Shop/Types.hs b/src/Shop/Types.hs new file mode 100644 index 0000000..c2ddaa5 --- /dev/null +++ b/src/Shop/Types.hs @@ -0,0 +1,56 @@ +{-# LANGUAGE DeriveGeneric #-} +module Shop.Types + ( Product(..) + , Article(..) + , ChargeForm(..) + , ChargeResponse(..) + ) + where + +import Protolude hiding (Product(..)) +import Data.Aeson (ToJSON(..), FromJSON(..), Value(..)) +import Servant.API + + +data ChargeResponse = ChargeResponse + { chargeid :: Text + , chargeamount :: Text + } + deriving (Show, Read, Generic, Eq) + +instance ToJSON ChargeResponse +instance FromJSON ChargeResponse + +data Product = Product + { nom :: Text + , description :: Text + , poids :: Int + -- ^ poids en grammes + , prix :: Int + -- ^ prix en centimes d'euros + } + deriving (Show, Read, Generic, Eq) + +instance ToJSON Product +instance FromJSON Product + +data Article = Article + { product :: Product + , quantity :: Int + } + deriving (Show, Read, Generic, Eq) + +instance ToJSON Article +instance FromJSON Article + +data ChargeForm = ChargeForm + { name :: Text + , email :: Text + , phone :: Text + , date :: Text + , articles :: [Article] + } + deriving (Show, Read, Generic, Eq) + +instance ToJSON ChargeForm +instance FromJSON ChargeForm |