Unified Address support #8
1 changed files with 68 additions and 71 deletions
29
src/Owner.hs
29
src/Owner.hs
|
@ -14,8 +14,7 @@ import Database.MongoDB
|
|||
import GHC.Generics
|
||||
|
||||
-- | Type to represent a ZGo shop owner/business
|
||||
data Owner =
|
||||
Owner
|
||||
data Owner = Owner
|
||||
{ o_id :: Maybe ObjectId
|
||||
, oaddress :: T.Text
|
||||
, oname :: T.Text
|
||||
|
@ -41,8 +40,7 @@ data Owner =
|
|||
, opayconf :: Bool
|
||||
, oviewkey :: T.Text
|
||||
, ocrmToken :: T.Text
|
||||
}
|
||||
deriving (Eq, Show, Generic, Typeable)
|
||||
} deriving (Eq, Show, Generic, Typeable)
|
||||
|
||||
instance ToJSON Owner where
|
||||
toJSON (Owner i a n c t tV v vV f l e s ct st p ph w co paid zats inv eTs pc vk cT) =
|
||||
|
@ -276,8 +274,7 @@ instance Val Owner where
|
|||
]
|
||||
|
||||
-- | Type to represent informational data for Owners from UI
|
||||
data OwnerData =
|
||||
OwnerData
|
||||
data OwnerData = OwnerData
|
||||
{ od_first :: T.Text
|
||||
, od_last :: T.Text
|
||||
, od_name :: T.Text
|
||||
|
@ -289,8 +286,7 @@ data OwnerData =
|
|||
, od_email :: T.Text
|
||||
, od_website :: T.Text
|
||||
, od_phone :: T.Text
|
||||
}
|
||||
deriving (Eq, Show, Generic)
|
||||
} deriving (Eq, Show, Generic)
|
||||
|
||||
instance FromJSON OwnerData where
|
||||
parseJSON =
|
||||
|
@ -308,8 +304,7 @@ instance FromJSON OwnerData where
|
|||
ph <- obj .: "phone"
|
||||
pure $ OwnerData f l n s c st p co e w ph
|
||||
|
||||
data OwnerSettings =
|
||||
OwnerSettings
|
||||
data OwnerSettings = OwnerSettings
|
||||
{ os_id :: Maybe ObjectId
|
||||
, os_address :: T.Text
|
||||
, os_name :: T.Text
|
||||
|
@ -325,8 +320,7 @@ data OwnerSettings =
|
|||
, os_payconf :: Bool
|
||||
, os_crmToken :: T.Text
|
||||
, os_viewKey :: T.Text
|
||||
}
|
||||
deriving (Eq, Show, Generic)
|
||||
} deriving (Eq, Show, Generic)
|
||||
|
||||
instance FromJSON OwnerSettings where
|
||||
parseJSON =
|
||||
|
@ -424,6 +418,11 @@ findExpiringOwners now =
|
|||
["paid" =: True, "expiration" =: ["$lte" =: addUTCTime 172800 now]]
|
||||
"owners")
|
||||
|
||||
findWithKeys :: Action IO [Document]
|
||||
findWithKeys =
|
||||
rest =<<
|
||||
find (select ["paid" =: True, "invoices" =: True, "payconf" =: True] "owners")
|
||||
|
||||
removePro :: T.Text -> Action IO ()
|
||||
removePro o =
|
||||
modify (select ["address" =: o] "owners") ["$set" =: ["invoices" =: False]]
|
||||
|
@ -450,14 +449,12 @@ upsertViewingKey o vk =
|
|||
modify (select ["_id" =: o_id o] "owners") ["$set" =: ["viewKey" =: vk]]
|
||||
|
||||
-- | Type for a pro session
|
||||
data ZGoProSession =
|
||||
ZGoProSession
|
||||
data ZGoProSession = ZGoProSession
|
||||
{ ps_id :: Maybe ObjectId
|
||||
, psaddress :: T.Text
|
||||
, psexpiration :: UTCTime
|
||||
, psclosed :: Bool
|
||||
}
|
||||
deriving (Eq, Show)
|
||||
} deriving (Eq, Show)
|
||||
|
||||
instance Val ZGoProSession where
|
||||
cast' (Doc d) = do
|
||||
|
|
Loading…
Reference in a new issue