Enhance owner endpoint
This commit is contained in:
parent
849f1d9120
commit
aef26675b4
2 changed files with 23 additions and 22 deletions
|
@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
|
|
||||||
- Modified API tests to use `session` parameter.
|
- Modified API tests to use `session` parameter.
|
||||||
- Modified `api/owner` endpoint to use a specific data structure to create new owners
|
- Modified `api/owner` endpoint to use a specific data structure to create new owners
|
||||||
|
- Modified `api/owner` endpoint to use session as input
|
||||||
|
|
||||||
## [1.4.1] - 2023-05-02
|
## [1.4.1] - 2023-05-02
|
||||||
|
|
||||||
|
|
|
@ -914,35 +914,35 @@ routes pipe config = do
|
||||||
get "/getaddr" $ do Web.Scotty.json (object ["addr" .= nodeAddress])
|
get "/getaddr" $ do Web.Scotty.json (object ["addr" .= nodeAddress])
|
||||||
--Get owner by address
|
--Get owner by address
|
||||||
get "/api/owner" $ do
|
get "/api/owner" $ do
|
||||||
addr <- param "address"
|
session <- param "session"
|
||||||
owner <- liftAndCatchIO $ run (findOwner addr)
|
user <- liftAndCatchIO $ run (findUser session)
|
||||||
case owner of
|
case parseUserBson =<< user of
|
||||||
|
Nothing -> status noContent204
|
||||||
|
Just u -> do
|
||||||
|
owner <- liftAndCatchIO $ run (findOwner $ uaddress u)
|
||||||
|
case cast' . Doc =<< owner of
|
||||||
Nothing -> status noContent204
|
Nothing -> status noContent204
|
||||||
Just o -> do
|
Just o -> do
|
||||||
let pOwner = cast' (Doc o)
|
|
||||||
case pOwner of
|
|
||||||
Nothing -> status internalServerError500
|
|
||||||
Just q -> do
|
|
||||||
status ok200
|
status ok200
|
||||||
Web.Scotty.json
|
Web.Scotty.json
|
||||||
(object
|
(object
|
||||||
[ "message" .= ("Owner found!" :: String)
|
[ "message" .= ("Owner found!" :: String)
|
||||||
, "owner" .=
|
, "owner" .=
|
||||||
object
|
object
|
||||||
[ "_id" .= (maybe "" show $ o_id q :: String)
|
[ "_id" .= (maybe "" show $ o_id o :: String)
|
||||||
, "address" .= oaddress q
|
, "address" .= oaddress o
|
||||||
, "name" .= oname q
|
, "name" .= oname o
|
||||||
, "currency" .= ocurrency q
|
, "currency" .= ocurrency o
|
||||||
, "tax" .= otax q
|
, "tax" .= otax o
|
||||||
, "taxValue" .= otaxValue q
|
, "taxValue" .= otaxValue o
|
||||||
, "vat" .= ovat q
|
, "vat" .= ovat o
|
||||||
, "vatValue" .= ovatValue q
|
, "vatValue" .= ovatValue o
|
||||||
, "paid" .= opaid q
|
, "paid" .= opaid o
|
||||||
, "zats" .= ozats q
|
, "zats" .= ozats o
|
||||||
, "invoices" .= oinvoices q
|
, "invoices" .= oinvoices o
|
||||||
, "expiration" .= oexpiration q
|
, "expiration" .= oexpiration o
|
||||||
, "payconf" .= opayconf q
|
, "payconf" .= opayconf o
|
||||||
, "crmToken" .= ocrmToken q
|
, "crmToken" .= ocrmToken o
|
||||||
]
|
]
|
||||||
])
|
])
|
||||||
get "/api/ownerid" $ do
|
get "/api/ownerid" $ do
|
||||||
|
|
Loading…
Reference in a new issue