f7e1574176
Better-Auth uses nanoid strings for user IDs, not UUIDs. Changed all user_id parameter/return types in the API layer from UUID to str, removed the obsolete UUID import where unused, and updated the _validate_session_token return type accordingly. Co-authored-by: CartSnitch Engineer Bot <cartnoreply@cartsnitch.com> Co-authored-by: Paperclip <noreply@paperclip.ing>
33 lines
973 B
Python
33 lines
973 B
Python
"""Coupon routes: browse, relevant matches."""
|
|
|
|
from uuid import UUID
|
|
|
|
from fastapi import APIRouter, Depends, Query
|
|
from sqlalchemy.ext.asyncio import AsyncSession
|
|
|
|
from cartsnitch_api.auth.dependencies import get_current_user
|
|
from cartsnitch_api.database import get_db
|
|
from cartsnitch_api.schemas import CouponResponse
|
|
from cartsnitch_api.services.coupons import CouponService
|
|
|
|
router = APIRouter(prefix="/coupons", tags=["coupons"])
|
|
|
|
|
|
@router.get("", response_model=list[CouponResponse])
|
|
async def list_coupons(
|
|
store_id: UUID | None = Query(None),
|
|
user_id: str = Depends(get_current_user),
|
|
db: AsyncSession = Depends(get_db),
|
|
):
|
|
svc = CouponService(db)
|
|
return await svc.list_coupons(store_id)
|
|
|
|
|
|
@router.get("/relevant", response_model=list[CouponResponse])
|
|
async def relevant_coupons(
|
|
user_id: str = Depends(get_current_user),
|
|
db: AsyncSession = Depends(get_db),
|
|
):
|
|
svc = CouponService(db)
|
|
return await svc.relevant_coupons(user_id)
|