Add endpoint to query WooCommerce token

This commit is contained in:
Rene Vergara 2022-12-15 15:47:02 -06:00
parent cb9b5cd411
commit e4129b2970
Signed by: pitmutt
GPG key ID: 65122AD495A7F5B2

View file

@ -618,6 +618,21 @@ routes pipe config = do
c <- param "code"
liftAndCatchIO $ run (addAccCode oAdd c)
status accepted202
-- Get the WooCommerce token
get "/api/wootoken" $ do
oid <- param "ownerid"
res <- liftAndCatchIO $ run (findWooToken (read oid))
let t1 = cast' . Doc =<< res
case t1 of
Nothing -> status noContent204
Just t -> do
status ok200
Web.Scotty.json
(object
[ "ownerid" .= show (w_owner t)
, "token" .= w_token t
, "siteurl" .= w_url t
])
-- Authenticate the WooCommerce plugin
get "/auth" $ do
oid <- param "ownerid"