Unified Address support #8
1 changed files with 20 additions and 2 deletions
22
src/Order.hs
22
src/Order.hs
|
@ -12,6 +12,7 @@ import Data.Time.Clock
|
||||||
import Database.MongoDB
|
import Database.MongoDB
|
||||||
import GHC.Generics
|
import GHC.Generics
|
||||||
import Test.QuickCheck
|
import Test.QuickCheck
|
||||||
|
import WooCommerce (WooToken(w_id))
|
||||||
|
|
||||||
-- | Type to represent a ZGo order
|
-- | Type to represent a ZGo order
|
||||||
data ZGoOrder = ZGoOrder
|
data ZGoOrder = ZGoOrder
|
||||||
|
@ -72,7 +73,7 @@ instance ToJSON ZGoOrder where
|
||||||
instance FromJSON ZGoOrder where
|
instance FromJSON ZGoOrder where
|
||||||
parseJSON =
|
parseJSON =
|
||||||
withObject "Order" $ \obj -> do
|
withObject "Order" $ \obj -> do
|
||||||
i <- obj .:? "_id"
|
i <- obj .: "_id"
|
||||||
a <- obj .: "address"
|
a <- obj .: "address"
|
||||||
s <- obj .: "session"
|
s <- obj .: "session"
|
||||||
ts <- obj .: "timestamp"
|
ts <- obj .: "timestamp"
|
||||||
|
@ -86,7 +87,24 @@ instance FromJSON ZGoOrder where
|
||||||
eI <- obj .: "externalInvoice"
|
eI <- obj .: "externalInvoice"
|
||||||
sC <- obj .: "shortCode"
|
sC <- obj .: "shortCode"
|
||||||
tk <- obj .: "token"
|
tk <- obj .: "token"
|
||||||
pure $ ZGoOrder (read =<< i) a s ts c cur p t tZ l pd eI sC tk
|
pure $
|
||||||
|
ZGoOrder
|
||||||
|
(if not (null i)
|
||||||
|
then Just (read i :: ObjectId)
|
||||||
|
else Nothing)
|
||||||
|
a
|
||||||
|
s
|
||||||
|
ts
|
||||||
|
c
|
||||||
|
cur
|
||||||
|
p
|
||||||
|
t
|
||||||
|
tZ
|
||||||
|
l
|
||||||
|
pd
|
||||||
|
eI
|
||||||
|
sC
|
||||||
|
tk
|
||||||
|
|
||||||
instance Val ZGoOrder where
|
instance Val ZGoOrder where
|
||||||
val (ZGoOrder i a s ts c cur p t tZ l pd eI sC tk) =
|
val (ZGoOrder i a s ts c cur p t tZ l pd eI sC tk) =
|
||||||
|
|
Loading…
Reference in a new issue