File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -457,7 +457,7 @@ def set_pin(
457457 return {"detail" : "PIN updated" }
458458
459459
460- @router .get ("/statement/{target_slug}" )
460+ @router .get ("/statement/{target_slug}" , response_class = Response )
461461def get_statement (
462462 target_slug : str ,
463463 from_year : int = Query (...),
@@ -522,7 +522,7 @@ def get_statement(
522522 raise HTTPException (500 , f"PDF generation failed: { e } " ) from e
523523
524524
525- @router .get ("/statement-all" )
525+ @router .get ("/statement-all" , response_class = Response )
526526def get_statement_all (
527527 from_year : int = Query (...),
528528 from_month : int = Query (...),
Original file line number Diff line number Diff line change 3232 ProductStocktaking ,
3333 ProductUpdate ,
3434 PurchaseBody ,
35+ PurchaseResponse ,
3536)
3637
3738router = APIRouter ()
@@ -333,7 +334,7 @@ def delete_alias(
333334
334335# --- Purchase (checkout device) ---
335336
336- @router .post ("/products/{ean}/purchase" )
337+ @router .post ("/products/{ean}/purchase" , response_model = PurchaseResponse )
337338def purchase_product (
338339 ean : str ,
339340 body : PurchaseBody ,
@@ -373,4 +374,4 @@ def purchase_product(
373374 ))
374375 db .commit ()
375376
376- return { " detail" : " Purchase successful" , " product" : product .name , " new_balance" : float ( user .balance )}
377+ return PurchaseResponse ( detail = " Purchase successful" , product = product .name , new_balance = user .balance )
Original file line number Diff line number Diff line change 1111from app .schemas .common import MessageResponse
1212from app .schemas .rental import (
1313 ActiveRentalResponse ,
14+ RentalAuthorizeResponse ,
1415 RentalCatalogItem ,
1516 RentalItemCreate ,
1617 RentalItemResponse ,
@@ -133,7 +134,7 @@ def item_status(
133134
134135# --- Rental operations ---
135136
136- @router .get ("/authorize/{nfc_id}" )
137+ @router .get ("/authorize/{nfc_id}" , response_model = RentalAuthorizeResponse )
137138def authorize_renter (
138139 nfc_id : int ,
139140 device : Machine = Depends (get_current_device ),
Original file line number Diff line number Diff line change @@ -80,9 +80,10 @@ class PurchaseBody(BaseModel):
8080 nfc_id : int
8181
8282
83- class ProductPurchase (BaseModel ):
84- nfc_id : int
85- ean : str
83+ class PurchaseResponse (BaseModel ):
84+ detail : str
85+ product : str
86+ new_balance : Decimal = Field (ge = 0 , examples = [Decimal ("4.20" )])
8687
8788
8889class ProductPopularityResponse (BaseModel ):
Original file line number Diff line number Diff line change @@ -77,3 +77,9 @@ class RentalCatalogItem(BaseModel):
7777 uhf_tid : str
7878 name : str
7979 is_rented : bool
80+
81+
82+ class RentalAuthorizeResponse (BaseModel ):
83+ authorized : bool
84+ user_id : int
85+ user_name : Optional [str ]
You can’t perform that action at this time.
0 commit comments