logistics-api-rxfsc8/endpoints/users/hashadproject-8ld3bk.post.py

27 lines
779 B
Python

from fastapi import APIRouter, Depends, HTTPException
from core.database import fake_users_db
router = APIRouter()
@router.post("/users/hashadproject-8ld3bk")
async def fetch_user_details(
code_id: str
):
"""Fetch user details based on codeID"""
user = fake_users_db.get(code_id)
if not user:
raise HTTPException(status_code=404, detail="User not found")
return {
"message": "User details retrieved successfully",
"data": {
"user_id": user["id"],
"username": code_id,
"email": user["email"],
"status": "active" if not user["disabled"] else "disabled"
},
"metadata": {
"source": "demo_db",
"timestamp": "2024-01-01T00:00:00Z"
}
}