2025-03-21 10:23:07 +00:00

30 lines
856 B
Python

from fastapi import APIRouter, HTTPException
customers = [] # In-memory storage
router = APIRouter()
@router.post("/signup")
async def list_customers(
store_id: str = "default_store",
page: int = 1,
limit: int = 10
):
"""Get list of store customers"""
if not any(c["store_id"] == store_id for c in customers):
raise HTTPException(status_code=400, detail="Store not found")
store_customers = [c for c in customers if c["store_id"] == store_id]
start = (page - 1) * limit
end = start + limit
return {
"message": "Customers retrieved successfully",
"store_id": store_id,
"customers": store_customers[start:end],
"pagination": {
"page": page,
"total": len(store_customers),
"pages": (len(store_customers) + limit - 1) // limit
}
}