REFACTOR ALL APIs
This commit is contained in:
@@ -44,7 +44,7 @@ class SalesServiceClient(BaseServiceClient):
|
||||
if product_id:
|
||||
params["product_id"] = product_id
|
||||
|
||||
result = await self.get("sales", tenant_id=tenant_id, params=params)
|
||||
result = await self.get("sales/sales", tenant_id=tenant_id, params=params)
|
||||
return result.get("sales", []) if result else None
|
||||
|
||||
async def get_all_sales_data(
|
||||
@@ -72,7 +72,7 @@ class SalesServiceClient(BaseServiceClient):
|
||||
# Use the inherited paginated request method
|
||||
try:
|
||||
all_records = await self.get_paginated(
|
||||
"sales",
|
||||
"sales/sales",
|
||||
tenant_id=tenant_id,
|
||||
params=params,
|
||||
page_size=page_size,
|
||||
@@ -95,7 +95,7 @@ class SalesServiceClient(BaseServiceClient):
|
||||
) -> Optional[Dict[str, Any]]:
|
||||
"""Upload sales data"""
|
||||
data = {"sales": sales_data}
|
||||
return await self.post("sales", data=data, tenant_id=tenant_id)
|
||||
return await self.post("sales/sales", data=data, tenant_id=tenant_id)
|
||||
|
||||
# ================================================================
|
||||
# PRODUCTS
|
||||
@@ -103,12 +103,12 @@ class SalesServiceClient(BaseServiceClient):
|
||||
|
||||
async def get_products(self, tenant_id: str) -> Optional[List[Dict[str, Any]]]:
|
||||
"""Get all products for a tenant"""
|
||||
result = await self.get("products", tenant_id=tenant_id)
|
||||
result = await self.get("sales/products", tenant_id=tenant_id)
|
||||
return result.get("products", []) if result else None
|
||||
|
||||
|
||||
async def get_product(self, tenant_id: str, product_id: str) -> Optional[Dict[str, Any]]:
|
||||
"""Get a specific product"""
|
||||
return await self.get(f"products/{product_id}", tenant_id=tenant_id)
|
||||
return await self.get(f"sales/products/{product_id}", tenant_id=tenant_id)
|
||||
|
||||
async def create_product(
|
||||
self,
|
||||
@@ -125,8 +125,8 @@ class SalesServiceClient(BaseServiceClient):
|
||||
"price": price,
|
||||
**kwargs
|
||||
}
|
||||
return await self.post("products", data=data, tenant_id=tenant_id)
|
||||
|
||||
return await self.post("sales/products", data=data, tenant_id=tenant_id)
|
||||
|
||||
async def update_product(
|
||||
self,
|
||||
tenant_id: str,
|
||||
@@ -134,7 +134,7 @@ class SalesServiceClient(BaseServiceClient):
|
||||
**updates
|
||||
) -> Optional[Dict[str, Any]]:
|
||||
"""Update a product"""
|
||||
return await self.put(f"products/{product_id}", data=updates, tenant_id=tenant_id)
|
||||
return await self.put(f"sales/products/{product_id}", data=updates, tenant_id=tenant_id)
|
||||
|
||||
# ================================================================
|
||||
# DATA IMPORT
|
||||
@@ -153,4 +153,4 @@ class SalesServiceClient(BaseServiceClient):
|
||||
"format": file_format,
|
||||
"filename": filename
|
||||
}
|
||||
return await self.post("import", data=data, tenant_id=tenant_id)
|
||||
return await self.post("sales/operations/import", data=data, tenant_id=tenant_id)
|
||||
Reference in New Issue
Block a user