diff --git a/endpoints/cart.post.py b/endpoints/cart.post.py index e69de29..7ef30d9 100644 --- a/endpoints/cart.post.py +++ b/endpoints/cart.post.py @@ -0,0 +1,36 @@ +from fastapi import APIRouter, HTTPException + +carts = [] # In-memory storage + +router = APIRouter() + +@router.post("/cart") +async def add_to_cart( + user_id: str, + item_id: str, + quantity: int = 1 +): + """Add item to user's cart""" + cart = next((c for c in carts if c["user_id"] == user_id), None) + + if not cart: + cart = { + "user_id": user_id, + "items": [] + } + carts.append(cart) + + cart["items"].append({ + "item_id": item_id, + "quantity": quantity + }) + + return { + "message": "Item added to cart", + "cart_id": user_id, + "items": cart["items"], + "features": { + "max_items": 10, + "expires_in": 3600 + } + } \ No newline at end of file