Update code in endpoints/customer.post.py
This commit is contained in:
parent
9481c4bab0
commit
03c73bfd0d
@ -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"
|
||||||
|
]
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user