fastlane / routes /order_management.py
Hugo Guarin
Update space
c169262
raw
history blame contribute delete
753 Bytes
from fastapi import APIRouter, status, HTTPException
from services.elasticsearch import get_order_details, get_customer
router = APIRouter()
@router.get("/track-order/{order_id}")
def handle_track_order(order_id: str):
order = get_order_details(order_id)
if not order:
raise HTTPException(
status_code=status.HTTP_404_NOT_FOUND, detail="Order not found")
return order
@router.get("/order-history")
def view_order_history(customer_id: str):
customer = get_customer(customer_id)
if not customer:
raise HTTPException(
status_code=status.HTTP_404_NOT_FOUND, detail="Customer not found")
# Retrieve order history from customer data
return {"order_history": customer.get("orders", [])}