|
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") |
|
|
|
return {"order_history": customer.get("orders", [])} |
|
|