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"