Update code in endpoints/move.get.py
This commit is contained in:
parent
86e9131aac
commit
2b33bd5961
@ -1,15 +1,38 @@
|
||||
from fastapi import APIRouter, Depends, HTTPException
|
||||
from core.database import fake_users_db
|
||||
from django.shortcuts import get_object_or_404
|
||||
from django.core.exceptions import ValidationError
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
@router.get("/move")
|
||||
async def move_handler():
|
||||
"""Demo move endpoint"""
|
||||
return {
|
||||
"message": "Thank you",
|
||||
"metadata": {
|
||||
"timestamp": "demo_response",
|
||||
"source": "move_endpoint"
|
||||
async def move_handler(
|
||||
source: str,
|
||||
destination: str,
|
||||
item_id: str = None
|
||||
):
|
||||
"""Move item between locations"""
|
||||
try:
|
||||
if not source or not destination:
|
||||
raise HTTPException(status_code=400, detail="Source and destination are required")
|
||||
|
||||
if item_id and item_id not in fake_users_db:
|
||||
raise HTTPException(status_code=404, detail="Item not found")
|
||||
|
||||
return {
|
||||
"message": "Move operation successful",
|
||||
"data": {
|
||||
"source": source,
|
||||
"destination": destination,
|
||||
"item_id": item_id
|
||||
},
|
||||
"metadata": {
|
||||
"timestamp": "2024-01-19T12:00:00Z",
|
||||
"status": "completed"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
except ValidationError as e:
|
||||
raise HTTPException(status_code=400, detail=str(e))
|
||||
except Exception as e:
|
||||
raise HTTPException(status_code=500, detail="Internal server error")
|
Loading…
x
Reference in New Issue
Block a user