Update code in endpoints/customer.post.py

This commit is contained in:
Backend IM Bot 2025-03-25 13:01:11 +00:00
parent 9481c4bab0
commit 03c73bfd0d

View File

@ -0,0 +1,36 @@
from fastapi import APIRouter, HTTPException
import uuid
customers = [] # In-memory storage
router = APIRouter()
@router.post("/customer")
async def create_customer(
email: str = "customer@example.com",
name: str = "John Doe",
location: str = "New York",
gender: str = "male"
):
"""Create new customer endpoint"""
if any(c["email"] == email for c in customers):
raise HTTPException(status_code=400, detail="Email already exists")
customer_id = str(uuid.uuid4())
customers.append({
"id": customer_id,
"email": email,
"name": name,
"location": location,
"gender": gender
})
return {
"message": "Customer created successfully",
"customer_id": customer_id,
"email": email,
"next_steps": [
"Complete customer profile",
"Add payment method"
]
}