From 139f7d3edae898792c26d9fc5a338b79bd529854 Mon Sep 17 00:00:00 2001 From: Chris Lovering Date: Mon, 19 Aug 2024 01:38:10 +0100 Subject: [PATCH] Add an example endpoint for making requests to printful --- thallium-backend/src/routes/__init__.py | 2 ++ thallium-backend/src/routes/templates.py | 16 ++++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 thallium-backend/src/routes/templates.py diff --git a/thallium-backend/src/routes/__init__.py b/thallium-backend/src/routes/__init__.py index 2dc76c8..4ab0c94 100644 --- a/thallium-backend/src/routes/__init__.py +++ b/thallium-backend/src/routes/__init__.py @@ -2,11 +2,13 @@ from src.routes.debug import router as debug_router from src.routes.login import router as login_router +from src.routes.templates import router as template_router from src.routes.vouchers import router as voucher_router from src.settings import CONFIG top_level_router = APIRouter() top_level_router.include_router(login_router) +top_level_router.include_router(template_router) top_level_router.include_router(voucher_router) if CONFIG.debug: top_level_router.include_router(debug_router) diff --git a/thallium-backend/src/routes/templates.py b/thallium-backend/src/routes/templates.py new file mode 100644 index 0000000..7dad7f7 --- /dev/null +++ b/thallium-backend/src/routes/templates.py @@ -0,0 +1,16 @@ +import logging + +from fastapi import APIRouter, Depends + +from src.auth import TokenAuth +from src.settings import PrintfulClient + +router = APIRouter(tags=["Printful"], prefix="/printful", dependencies=[Depends(TokenAuth(allow_regular_users=True))]) +log = logging.getLogger(__name__) + + +@router.get("/templates") +async def get_templates(client: PrintfulClient) -> dict: + """Return all templates in printful.""" + resp = await client.get("/product-templates") + return resp.json()