SysOps: deploy-all — 2026-06-09 10:41 UTC
This commit is contained in:
@@ -25,6 +25,48 @@ class CrmLinkBody(BaseModel):
|
||||
notes: Optional[str] = None
|
||||
|
||||
|
||||
class SupermarketCreateBody(BaseModel):
|
||||
name: str
|
||||
chain: str
|
||||
address: str
|
||||
postcode: str = "0000AA"
|
||||
city: str
|
||||
province: Optional[str] = None
|
||||
phone: Optional[str] = None
|
||||
email: Optional[str] = None
|
||||
website: Optional[str] = None
|
||||
manager_name: Optional[str] = None
|
||||
employee_count: Optional[int] = None
|
||||
store_type: Optional[str] = None
|
||||
partnership_status: str = "none"
|
||||
halal_certified: bool = False
|
||||
has_halal_section: bool = False
|
||||
halal_certifier: Optional[str] = None
|
||||
|
||||
|
||||
class SupermarketPatchBody(BaseModel):
|
||||
name: Optional[str] = None
|
||||
chain: Optional[str] = None
|
||||
address: Optional[str] = None
|
||||
postcode: Optional[str] = None
|
||||
city: Optional[str] = None
|
||||
province: Optional[str] = None
|
||||
phone: Optional[str] = None
|
||||
email: Optional[str] = None
|
||||
website: Optional[str] = None
|
||||
manager_name: Optional[str] = None
|
||||
employee_count: Optional[int] = None
|
||||
store_type: Optional[str] = None
|
||||
size_m2: Optional[int] = None
|
||||
partnership_status: Optional[str] = None
|
||||
halal_certified: Optional[bool] = None
|
||||
has_halal_section: Optional[bool] = None
|
||||
halal_certifier: Optional[str] = None
|
||||
halal_certificate_number: Optional[str] = None
|
||||
organic_section: Optional[bool] = None
|
||||
alcohol_section: Optional[bool] = None
|
||||
|
||||
|
||||
class NoteBody(BaseModel):
|
||||
body: str
|
||||
title: Optional[str] = None
|
||||
@@ -88,6 +130,13 @@ async def _tools_delete(path: str) -> Any:
|
||||
return resp.json()
|
||||
|
||||
|
||||
async def _tools_patch(path: str, json_body: Optional[dict] = None) -> Any:
|
||||
async with httpx.AsyncClient(timeout=120) as client:
|
||||
resp = await client.patch(f"{TOOLS}{path}", json=json_body or {})
|
||||
resp.raise_for_status()
|
||||
return resp.json()
|
||||
|
||||
|
||||
@router.get("/retail")
|
||||
async def retail_page(request: Request):
|
||||
stats = await _tools_get("/retail/stats")
|
||||
@@ -153,6 +202,24 @@ async def api_link_store(store_id: int, body: CrmLinkBody):
|
||||
return JSONResponse(await _tools_post(f"/retail/supermarkets/{store_id}/link", json_body=body.model_dump()))
|
||||
|
||||
|
||||
@router.post("/api/retail/supermarkets")
|
||||
async def api_create_supermarket(body: SupermarketCreateBody):
|
||||
return JSONResponse(await _tools_post("/retail/supermarkets", json_body=body.model_dump()))
|
||||
|
||||
|
||||
@router.patch("/api/retail/supermarkets/{store_id}")
|
||||
async def api_patch_supermarket(store_id: int, body: SupermarketPatchBody):
|
||||
return JSONResponse(await _tools_patch(
|
||||
f"/retail/supermarkets/{store_id}",
|
||||
json_body=body.model_dump(exclude_unset=True),
|
||||
))
|
||||
|
||||
|
||||
@router.delete("/api/retail/supermarkets/{store_id}/link/{client_id}")
|
||||
async def api_unlink_store(store_id: int, client_id: int):
|
||||
return JSONResponse(await _tools_delete(f"/retail/supermarkets/{store_id}/link/{client_id}"))
|
||||
|
||||
|
||||
@router.post("/api/retail/enrich")
|
||||
async def api_retail_enrich(limit: int = Query(100, ge=1, le=200)):
|
||||
return JSONResponse(await _tools_post("/retail/enrich", params={"limit": limit}))
|
||||
|
||||
Reference in New Issue
Block a user