Skip to content

Commit

Permalink
Add an example endpoint for making requests to printful
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisLovering committed Aug 19, 2024
1 parent dec7cf2 commit 139f7d3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
2 changes: 2 additions & 0 deletions thallium-backend/src/routes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
16 changes: 16 additions & 0 deletions thallium-backend/src/routes/templates.py
Original file line number Diff line number Diff line change
@@ -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()

0 comments on commit 139f7d3

Please sign in to comment.