Rebuild owner endpoints

This commit is contained in:
Rene Vergara 2023-05-09 11:03:26 -05:00
parent a201810134
commit d67d1937f5
Signed by: pitmutt
GPG key ID: 65122AD495A7F5B2

View file

@ -918,7 +918,22 @@ routes pipe config = do
Web.Scotty.json Web.Scotty.json
(object (object
[ "message" .= ("Owner found!" :: String) [ "message" .= ("Owner found!" :: String)
, "owner" .= toJSON (q :: Owner) , "owner" .=
object
[ "_id" .= (show $ o_id q :: String)
, "address" .= oaddress q
, "name" .= oname q
, "currency" .= ocurrency q
, "tax" .= otax q
, "taxValue" .= otaxValue q
, "vat" .= ovat q
, "vatValue" .= ovatValue q
, "paid" .= opaid q
, "zats" .= ozats q
, "invoices" .= oinvoices q
, "expiration" .= oexpiration q
, "crmToken" .= ocrmToken q
]
]) ])
get "/api/ownerid" $ do get "/api/ownerid" $ do
id <- param "id" id <- param "id"
@ -934,7 +949,22 @@ routes pipe config = do
Web.Scotty.json Web.Scotty.json
(object (object
[ "message" .= ("Owner found!" :: String) [ "message" .= ("Owner found!" :: String)
, "owner" .= toJSON (q :: Owner) , "owner" .=
object
[ "_id" .= (show $ o_id q :: String)
, "address" .= oaddress q
, "name" .= oname q
, "currency" .= ocurrency q
, "tax" .= otax q
, "taxValue" .= otaxValue q
, "vat" .= ovat q
, "vatValue" .= ovatValue q
, "paid" .= opaid q
, "zats" .= ozats q
, "invoices" .= oinvoices q
, "expiration" .= oexpiration q
, "crmToken" .= ocrmToken q
]
]) ])
--Upsert owner to DB --Upsert owner to DB
post "/api/owner" $ do post "/api/owner" $ do