diff --git a/endpoints/api/v1/endpoint.post.py b/endpoints/api/v1/endpoint.post.py index 2d9bd6b..f3ae69b 100644 --- a/endpoints/api/v1/endpoint.post.py +++ b/endpoints/api/v1/endpoint.post.py @@ -1,51 +1,39 @@ from fastapi import APIRouter, Depends, HTTPException from core.database import fake_users_db import uuid -from typing import Optional -from pydantic import BaseModel router = APIRouter() -class FabricSale(BaseModel): - fabric_type: str - quantity: float - price_per_unit: float - customer_id: Optional[str] = None - shipping_address: Optional[str] = None - @router.post("/api/v1/endpoint") -async def create_fabric_sale( - sale: FabricSale +async def bike_endpoint( + bike_name: str, + bike_type: str, + price: float, + available: bool = True ): - """Process new fabric sale""" - sale_id = str(uuid.uuid4()) + """Create new bike entry""" + bike_id = str(uuid.uuid4()) - # Simulate sale processing - sale_record = { - "id": sale_id, - "fabric_type": sale.fabric_type, - "quantity": sale.quantity, - "price_per_unit": sale.price_per_unit, - "total_amount": sale.quantity * sale.price_per_unit, - "customer_id": sale.customer_id, - "shipping_address": sale.shipping_address, - "status": "processed" + if bike_id in fake_users_db: + raise HTTPException(status_code=400, detail="Bike ID already exists") + + bike_data = { + "id": bike_id, + "name": bike_name, + "type": bike_type, + "price": price, + "available": available, + "created_at": str(uuid.uuid1()) } - # Store in demo database - fake_users_db[sale_id] = sale_record + fake_users_db[bike_id] = bike_data return { - "message": "Fabric sale processed successfully", - "sale_id": sale_id, - "data": sale_record, + "message": "Bike created successfully", + "bike_id": bike_id, + "data": bike_data, "metadata": { - "timestamp": "2024-01-20T12:00:00Z", - "status": "completed" - }, - "next_steps": [ - "Generate invoice", - "Prepare shipping label", - "Schedule delivery" - ] + "created_timestamp": bike_data["created_at"], + "status": "active" if available else "inactive" + } } \ No newline at end of file