diff --git a/endpoints/move.get.py b/endpoints/move.get.py index 8613771..78e792c 100644 --- a/endpoints/move.get.py +++ b/endpoints/move.get.py @@ -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" + } } - } \ No newline at end of file + + 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") \ No newline at end of file