From e4129b2970a691449453ce35acc542eb07967d7c Mon Sep 17 00:00:00 2001 From: Rene Vergara Date: Thu, 15 Dec 2022 15:47:02 -0600 Subject: [PATCH] Add endpoint to query WooCommerce token --- src/ZGoBackend.hs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/ZGoBackend.hs b/src/ZGoBackend.hs index 4261731..0438fb9 100644 --- a/src/ZGoBackend.hs +++ b/src/ZGoBackend.hs @@ -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"