Add CRM access token to Owner
This commit is contained in:
parent
d060032668
commit
0f333fd92c
4 changed files with 45 additions and 7 deletions
|
@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Field `crmToken` for `Owner`
|
||||||
|
|
||||||
## [1.0.0] - 2022-07-27
|
## [1.0.0] - 2022-07-27
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
39
src/Owner.hs
39
src/Owner.hs
|
@ -40,11 +40,12 @@ data Owner =
|
||||||
, oexpiration :: UTCTime
|
, oexpiration :: UTCTime
|
||||||
, opayconf :: Bool
|
, opayconf :: Bool
|
||||||
, oviewkey :: T.Text
|
, oviewkey :: T.Text
|
||||||
|
, ocrmToken :: T.Text
|
||||||
}
|
}
|
||||||
deriving (Eq, Show, Generic, Typeable)
|
deriving (Eq, Show, Generic, Typeable)
|
||||||
|
|
||||||
instance ToJSON Owner where
|
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) =
|
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) =
|
||||||
case i of
|
case i of
|
||||||
Just oid ->
|
Just oid ->
|
||||||
object
|
object
|
||||||
|
@ -72,6 +73,7 @@ instance ToJSON Owner where
|
||||||
, "expiration" .= eTs
|
, "expiration" .= eTs
|
||||||
, "payconf" .= pc
|
, "payconf" .= pc
|
||||||
, "viewkey" .= vk
|
, "viewkey" .= vk
|
||||||
|
, "crmToken" .= cT
|
||||||
]
|
]
|
||||||
Nothing ->
|
Nothing ->
|
||||||
object
|
object
|
||||||
|
@ -99,6 +101,7 @@ instance ToJSON Owner where
|
||||||
, "expiration" .= eTs
|
, "expiration" .= eTs
|
||||||
, "payconf" .= pc
|
, "payconf" .= pc
|
||||||
, "viewkey" .= vk
|
, "viewkey" .= vk
|
||||||
|
, "crmToken" .= cT
|
||||||
]
|
]
|
||||||
|
|
||||||
instance FromJSON Owner where
|
instance FromJSON Owner where
|
||||||
|
@ -128,6 +131,7 @@ instance FromJSON Owner where
|
||||||
ets <- obj .: "expiration"
|
ets <- obj .: "expiration"
|
||||||
pc <- obj .:? "payconf"
|
pc <- obj .:? "payconf"
|
||||||
vk <- obj .:? "viewkey"
|
vk <- obj .:? "viewkey"
|
||||||
|
cT <- obj .:? "crmToken"
|
||||||
pure $
|
pure $
|
||||||
Owner
|
Owner
|
||||||
(if not (null i)
|
(if not (null i)
|
||||||
|
@ -156,6 +160,7 @@ instance FromJSON Owner where
|
||||||
ets
|
ets
|
||||||
(fromMaybe False pc)
|
(fromMaybe False pc)
|
||||||
(fromMaybe "" vk)
|
(fromMaybe "" vk)
|
||||||
|
(fromMaybe "" cT)
|
||||||
|
|
||||||
instance Val Owner where
|
instance Val Owner where
|
||||||
cast' (Doc d) = do
|
cast' (Doc d) = do
|
||||||
|
@ -183,10 +188,36 @@ instance Val Owner where
|
||||||
ets <- B.lookup "expiration" d
|
ets <- B.lookup "expiration" d
|
||||||
pc <- B.lookup "payconf" d
|
pc <- B.lookup "payconf" d
|
||||||
vk <- B.lookup "viewKey" d
|
vk <- B.lookup "viewKey" d
|
||||||
|
cT <- B.lookup "crmToken" d
|
||||||
Just
|
Just
|
||||||
(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)
|
(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)
|
||||||
cast' _ = Nothing
|
cast' _ = Nothing
|
||||||
val (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) =
|
val (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) =
|
||||||
case i of
|
case i of
|
||||||
Just oid ->
|
Just oid ->
|
||||||
Doc
|
Doc
|
||||||
|
@ -214,6 +245,7 @@ instance Val Owner where
|
||||||
, "expiration" =: ets
|
, "expiration" =: ets
|
||||||
, "payconf" =: pc
|
, "payconf" =: pc
|
||||||
, "viewKey" =: vk
|
, "viewKey" =: vk
|
||||||
|
, "crmToken" =: cT
|
||||||
]
|
]
|
||||||
Nothing ->
|
Nothing ->
|
||||||
Doc
|
Doc
|
||||||
|
@ -240,6 +272,7 @@ instance Val Owner where
|
||||||
, "expiration" =: ets
|
, "expiration" =: ets
|
||||||
, "payconf" =: pc
|
, "payconf" =: pc
|
||||||
, "viewKey" =: vk
|
, "viewKey" =: vk
|
||||||
|
, "crmToken" =: cT
|
||||||
]
|
]
|
||||||
|
|
||||||
-- Database actions
|
-- Database actions
|
||||||
|
|
|
@ -74,7 +74,7 @@ main = do
|
||||||
"ZGO::5d3d4494-51c0-432d-8495-050419957aea\nReply-To:\nzs1w6nkameazc5gujm69350syl5w8tgvyaphums3pw8eytzy5ym08x7dvskmykkatmwrucmgv3er8e"
|
"ZGO::5d3d4494-51c0-432d-8495-050419957aea\nReply-To:\nzs1w6nkameazc5gujm69350syl5w8tgvyaphums3pw8eytzy5ym08x7dvskmykkatmwrucmgv3er8e"
|
||||||
describe "PIN generator" $ do
|
describe "PIN generator" $ do
|
||||||
it "should give a 7 digit" $ do
|
it "should give a 7 digit" $ do
|
||||||
length (T.unpack (unsafePerformIO generatePin)) `shouldBe` 7
|
length (T.unpack (unsafePerformIO (generatePin 1010))) `shouldBe` 7
|
||||||
describe "API endpoints" $ do
|
describe "API endpoints" $ do
|
||||||
beforeAll_ (startAPI loadedConfig) $ do
|
beforeAll_ (startAPI loadedConfig) $ do
|
||||||
describe "Price endpoint" $ do
|
describe "Price endpoint" $ do
|
||||||
|
@ -518,6 +518,7 @@ startAPI config = do
|
||||||
(UTCTime (fromGregorian 2022 4 16) (secondsToDiffTime 0))
|
(UTCTime (fromGregorian 2022 4 16) (secondsToDiffTime 0))
|
||||||
False
|
False
|
||||||
""
|
""
|
||||||
|
""
|
||||||
_ <- access pipe master "test" (Database.MongoDB.delete (select [] "owners"))
|
_ <- access pipe master "test" (Database.MongoDB.delete (select [] "owners"))
|
||||||
let o = val myOwner
|
let o = val myOwner
|
||||||
case o of
|
case o of
|
||||||
|
@ -604,8 +605,8 @@ instance Arbitrary Owner where
|
||||||
inv <- arbitrary
|
inv <- arbitrary
|
||||||
exp <- arbitrary
|
exp <- arbitrary
|
||||||
payconf <- arbitrary
|
payconf <- arbitrary
|
||||||
--exp <- arbitrary
|
vk <- arbitrary
|
||||||
Owner i a n c t tV v vV f l e s ct st p ph w co paid zats inv exp payconf <$>
|
Owner i a n c t tV v vV f l e s ct st p ph w co paid zats inv exp payconf vk <$>
|
||||||
arbitrary
|
arbitrary
|
||||||
|
|
||||||
instance Arbitrary Item where
|
instance Arbitrary Item where
|
||||||
|
|
|
@ -5,7 +5,7 @@ cabal-version: 1.12
|
||||||
-- see: https://github.com/sol/hpack
|
-- see: https://github.com/sol/hpack
|
||||||
|
|
||||||
name: zgo-backend
|
name: zgo-backend
|
||||||
version: 0.1.0.2
|
version: 1.0.0
|
||||||
synopsis: Haskell Back-end for the ZGo point-of-sale application
|
synopsis: Haskell Back-end for the ZGo point-of-sale application
|
||||||
description: Please see the README on GitLab at <https://gitlab.com/pitmutt/zgo-backend#readme>
|
description: Please see the README on GitLab at <https://gitlab.com/pitmutt/zgo-backend#readme>
|
||||||
category: Web
|
category: Web
|
||||||
|
|
Loading…
Reference in a new issue