inventory bug

This commit is contained in:
zman 2025-02-10 20:12:20 -05:00
parent edf76708b3
commit c896a6ea0f
2 changed files with 25 additions and 18 deletions

View File

@ -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 fastapi.responses import StreamingResponse
from typing import Optional, List from typing import Optional, List
from io import BytesIO from io import BytesIO
@ -233,16 +233,18 @@ async def delete_open_box(
raise HTTPException(status_code=400, detail=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) @router.post("/tcgplayer/inventory/add", response_class=StreamingResponse)
async def create_inventory_add_file( async def create_inventory_add_file(
request: dict, # Just use a dict instead body: InventoryAddRequest,
pricing_service: PricingService = Depends(get_pricing_service), pricing_service: PricingService = Depends(get_pricing_service),
): ):
"""Create a new inventory add file for download.""" """Create a new inventory add file for download."""
try: try:
# Get IDs directly from the dict content = pricing_service.generate_tcgplayer_inventory_update_file_with_pricing(body.open_box_ids)
open_box_ids = request.get('open_box_ids', [])
content = pricing_service.generate_tcgplayer_inventory_update_file_with_pricing(open_box_ids)
stream = BytesIO(content) stream = BytesIO(content)
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S") timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")

View File

@ -1,8 +1,9 @@
curl -J http://192.168.1.41:8000/api/tcgplayer/inventory/update --remote-name curl -J http://192.168.1.41:8000/api/tcgplayer/inventory/update --remote-name
curl -J -X POST \ -H "Content-Type: application/json" \ curl -J -X POST http://192.168.1.41:8000/api/tcgplayer/inventory/add \
-d '{"open_box_ids": ["e20cc342-23cb-4593-89cb-56a0cb3ed3f3"]}' \ -H "Content-Type: application/json" \
http://192.168.1.41:8000/api/tcgplayer/inventory/add --remote-name -d '{"open_box_ids": ["620fdeec-072d-4dd3-aef0-8a8a66de0c5f"]}' \
--remote-name
curl -X POST http://192.168.1.41:8000/api/boxes \ curl -X POST http://192.168.1.41:8000/api/boxes \
-F "type=draft" \ -F "type=draft" \
@ -10,11 +11,15 @@ curl -X POST http://192.168.1.41:8000/api/boxes \
-F "sku=195166231631" \ -F "sku=195166231631" \
-F "num_cards_expected=540" -F "num_cards_expected=540"
curl -X POST http://192.168.1.41:8000/api/boxes/box123/open \ curl -X POST http://192.168.1.41:8000/api/boxes/588dddad-0661-4541-a16c-beba1c564b4f/open \
-H "Content-Type: application/json" \ -F "product_id=588dddad-0661-4541-a16c-beba1c564b4f" \
-d '{ -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" \
"product_id": "box123", -F "date_opened=2025-02-10"
"file_ids": ["file1", "file2"],
"num_cards_actual": 15,
"date_opened": "2025-02-07T12:00:00Z" 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