36 lines
901 B
Python
36 lines
901 B
Python
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"
|
|
]
|
|
} |