From c896a6ea0ff9eda1b5b208d9fa6e489e3cf85774 Mon Sep 17 00:00:00 2001 From: zman Date: Mon, 10 Feb 2025 20:12:20 -0500 Subject: [PATCH] inventory bug --- app/routes/routes.py | 16 +++++++++------- requests.md | 27 ++++++++++++++++----------- 2 files changed, 25 insertions(+), 18 deletions(-) diff --git a/app/routes/routes.py b/app/routes/routes.py index 4371ce9..0c79bef 100644 --- a/app/routes/routes.py +++ b/app/routes/routes.py @@ -1,4 +1,4 @@ -from fastapi import APIRouter, Depends, HTTPException, UploadFile, File, BackgroundTasks +from fastapi import APIRouter, Depends, HTTPException, UploadFile, File, BackgroundTasks, Request from fastapi.responses import StreamingResponse from typing import Optional, List from io import BytesIO @@ -232,18 +232,20 @@ async def delete_open_box( logger.error(f"Delete open box failed: {str(e)}") raise HTTPException(status_code=400, detail=str(e) ) - + +class InventoryAddRequest(BaseModel): + open_box_ids: List[str] + + @router.post("/tcgplayer/inventory/add", response_class=StreamingResponse) async def create_inventory_add_file( - request: dict, # Just use a dict instead + body: InventoryAddRequest, pricing_service: PricingService = Depends(get_pricing_service), ): """Create a new inventory add file for download.""" try: - # Get IDs directly from the dict - open_box_ids = request.get('open_box_ids', []) - content = pricing_service.generate_tcgplayer_inventory_update_file_with_pricing(open_box_ids) - + content = pricing_service.generate_tcgplayer_inventory_update_file_with_pricing(body.open_box_ids) + stream = BytesIO(content) timestamp = datetime.now().strftime("%Y%m%d_%H%M%S") diff --git a/requests.md b/requests.md index 68ed031..7d3cd90 100644 --- a/requests.md +++ b/requests.md @@ -1,8 +1,9 @@ curl -J http://192.168.1.41:8000/api/tcgplayer/inventory/update --remote-name -curl -J -X POST \ -H "Content-Type: application/json" \ - -d '{"open_box_ids": ["e20cc342-23cb-4593-89cb-56a0cb3ed3f3"]}' \ - http://192.168.1.41:8000/api/tcgplayer/inventory/add --remote-name +curl -J -X POST http://192.168.1.41:8000/api/tcgplayer/inventory/add \ + -H "Content-Type: application/json" \ + -d '{"open_box_ids": ["620fdeec-072d-4dd3-aef0-8a8a66de0c5f"]}' \ + --remote-name curl -X POST http://192.168.1.41:8000/api/boxes \ -F "type=draft" \ @@ -10,11 +11,15 @@ curl -X POST http://192.168.1.41:8000/api/boxes \ -F "sku=195166231631" \ -F "num_cards_expected=540" -curl -X POST http://192.168.1.41:8000/api/boxes/box123/open \ --H "Content-Type: application/json" \ --d '{ - "product_id": "box123", - "file_ids": ["file1", "file2"], - "num_cards_actual": 15, - "date_opened": "2025-02-07T12:00:00Z" -}' \ No newline at end of file +curl -X POST http://192.168.1.41:8000/api/boxes/588dddad-0661-4541-a16c-beba1c564b4f/open \ +-F "product_id=588dddad-0661-4541-a16c-beba1c564b4f" \ +-F "file_ids=b06c8808-d024-4bb4-8b77-89d4f8b92938,8349456c-d588-4c50-bfd4-f5895d3b4a43,33fee9cf-790a-4f50-91b9-dfdf1adc75c7,12f848c7-80b9-4ce2-8be8-1f36e714bd6f,f5b6513c-97e3-423c-9f4d-73f058529e4f,995249ac-97df-40be-a779-3acca32eb186" \ +-F "date_opened=2025-02-10" + + +b06c8808-d024-4bb4-8b77-89d4f8b92938 +8349456c-d588-4c50-bfd4-f5895d3b4a43 +33fee9cf-790a-4f50-91b9-dfdf1adc75c7 +12f848c7-80b9-4ce2-8be8-1f36e714bd6f +f5b6513c-97e3-423c-9f4d-73f058529e4f +995249ac-97df-40be-a779-3acca32eb186 \ No newline at end of file