feat: update product
This commit is contained in:
parent
1e6aaf8436
commit
62e7d439c7
4 changed files with 84 additions and 35 deletions
25
views_api.py
25
views_api.py
|
|
@ -29,6 +29,7 @@ from .crud import (
|
|||
get_stalls,
|
||||
get_zone,
|
||||
get_zones,
|
||||
update_product,
|
||||
update_stall,
|
||||
update_zone,
|
||||
)
|
||||
|
|
@ -323,6 +324,30 @@ async def api_create_product(
|
|||
)
|
||||
|
||||
|
||||
@nostrmarket_ext.patch("/api/v1/product/{product_id}")
|
||||
async def api_update_product(
|
||||
product_id: str,
|
||||
product: Product,
|
||||
wallet: WalletTypeInfo = Depends(require_admin_key),
|
||||
) -> Product:
|
||||
try:
|
||||
product.validate_product()
|
||||
product = await update_product(wallet.wallet.user, product)
|
||||
|
||||
return product
|
||||
except ValueError as ex:
|
||||
raise HTTPException(
|
||||
status_code=HTTPStatus.BAD_REQUEST,
|
||||
detail=str(ex),
|
||||
)
|
||||
except Exception as ex:
|
||||
logger.warning(ex)
|
||||
raise HTTPException(
|
||||
status_code=HTTPStatus.INTERNAL_SERVER_ERROR,
|
||||
detail="Cannot update product",
|
||||
)
|
||||
|
||||
|
||||
@nostrmarket_ext.get("/api/v1/product/{stall_id}")
|
||||
async def api_get_product(
|
||||
stall_id: str,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue