From ed7c0a75b90faad4d66fd3e0dabbe059cacf1b28 Mon Sep 17 00:00:00 2001 From: Félix Sipma Date: Fri, 16 Feb 2018 16:02:14 +0100 Subject: add initial server --- src/Shop/Types.hs | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 src/Shop/Types.hs (limited to 'src/Shop/Types.hs') 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 -- cgit v1.2.3