Add new fields to Owner for payment confirmation
This commit is contained in:
parent
ebf3d2ce25
commit
00f2f2003a
2 changed files with 18 additions and 5 deletions
|
@ -9,9 +9,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
### Added
|
||||
|
||||
- New `Config` type to house the configuration parameters
|
||||
- New field in `Owner` type to store toggle for payment confirmation
|
||||
- New field in `Owner` type to store viewing key
|
||||
|
||||
### Changed
|
||||
|
||||
- Added alphabetic sorting to list of items
|
||||
- Refactored code to use new `Config` type
|
||||
- Enhance `decodeHexText` to support Unicode
|
||||
- Enhance `encodeHexText` to support Unicode
|
||||
|
|
20
src/Owner.hs
20
src/Owner.hs
|
@ -6,6 +6,7 @@ module Owner where
|
|||
|
||||
import Data.Aeson
|
||||
import qualified Data.Bson as B
|
||||
import Data.Maybe
|
||||
import qualified Data.Text as T
|
||||
import Data.Time.Clock
|
||||
import Data.Typeable
|
||||
|
@ -37,12 +38,13 @@ data Owner =
|
|||
, ozats :: Bool
|
||||
, oinvoices :: Bool
|
||||
, oexpiration :: UTCTime
|
||||
, opayconf :: Bool
|
||||
, oviewkey :: T.Text
|
||||
}
|
||||
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 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) =
|
||||
case i of
|
||||
Just oid ->
|
||||
object
|
||||
|
@ -68,6 +70,7 @@ instance ToJSON Owner where
|
|||
, "zats" .= zats
|
||||
, "invoices" .= inv
|
||||
, "expiration" .= eTs
|
||||
, "payconf" .= pc
|
||||
, "viewKey" .= vk
|
||||
]
|
||||
Nothing ->
|
||||
|
@ -94,6 +97,7 @@ instance ToJSON Owner where
|
|||
, "zats" .= zats
|
||||
, "invoices" .= inv
|
||||
, "expiration" .= eTs
|
||||
, "payconf" .= pc
|
||||
, "viewKey" .= vk
|
||||
]
|
||||
|
||||
|
@ -122,7 +126,8 @@ instance FromJSON Owner where
|
|||
zats <- obj .: "zats"
|
||||
inv <- obj .: "invoices"
|
||||
ets <- obj .: "expiration"
|
||||
vk <- obj .: "viewKey"
|
||||
pc <- obj .:? "payconf"
|
||||
vk <- obj .:? "viewKey"
|
||||
pure $
|
||||
Owner
|
||||
(if not (null i)
|
||||
|
@ -149,7 +154,8 @@ instance FromJSON Owner where
|
|||
zats
|
||||
inv
|
||||
ets
|
||||
vk
|
||||
(fromMaybe False pc)
|
||||
(fromMaybe "" vk)
|
||||
|
||||
instance Val Owner where
|
||||
cast' (Doc d) = do
|
||||
|
@ -175,10 +181,12 @@ instance Val Owner where
|
|||
zats <- B.lookup "zats" d
|
||||
inv <- B.lookup "invoices" d
|
||||
ets <- B.lookup "expiration" d
|
||||
pc <- B.lookup "payconf" d
|
||||
vk <- B.lookup "viewKey" d
|
||||
Just (Owner i a n c t tV v vV f l e s ct st p ph w co paid zats inv ets vk)
|
||||
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)
|
||||
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 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) =
|
||||
case i of
|
||||
Just oid ->
|
||||
Doc
|
||||
|
@ -204,6 +212,7 @@ instance Val Owner where
|
|||
, "zats" =: zats
|
||||
, "invoices" =: inv
|
||||
, "expiration" =: ets
|
||||
, "payconf" =: pc
|
||||
, "viewKey" =: vk
|
||||
]
|
||||
Nothing ->
|
||||
|
@ -229,6 +238,7 @@ instance Val Owner where
|
|||
, "zats" =: zats
|
||||
, "invoices" =: inv
|
||||
, "expiration" =: ets
|
||||
, "payconf" =: pc
|
||||
, "viewKey" =: vk
|
||||
]
|
||||
|
||||
|
|
Loading…
Reference in a new issue