REFACTOR ALL APIs

This commit is contained in:
Urtzi Alfaro
2025-10-06 15:27:01 +02:00
parent dc8221bd2f
commit 38fb98bc27
166 changed files with 18454 additions and 13605 deletions

View File

@@ -29,7 +29,7 @@ class RecipesServiceClient(BaseServiceClient):
async def get_recipe_by_id(self, tenant_id: str, recipe_id: str) -> Optional[Dict[str, Any]]:
"""Get recipe details by ID"""
try:
result = await self.get(f"recipes/{recipe_id}", tenant_id=tenant_id)
result = await self.get(f"recipes/recipes/{recipe_id}", tenant_id=tenant_id)
if result:
logger.info("Retrieved recipe details from recipes service",
recipe_id=recipe_id, tenant_id=tenant_id)
@@ -43,7 +43,7 @@ class RecipesServiceClient(BaseServiceClient):
"""Get recipes for multiple products"""
try:
params = {"product_ids": ",".join(product_ids)}
result = await self.get("recipes/by-products", tenant_id=tenant_id, params=params)
result = await self.get("recipes/recipes/by-products", tenant_id=tenant_id, params=params)
recipes = result.get('recipes', []) if result else []
logger.info("Retrieved recipes by product IDs from recipes service",
product_ids_count=len(product_ids),
@@ -82,7 +82,7 @@ class RecipesServiceClient(BaseServiceClient):
if recipe_ids:
params["recipe_ids"] = ",".join(recipe_ids)
result = await self.get("requirements", tenant_id=tenant_id, params=params)
result = await self.get("recipes/requirements", tenant_id=tenant_id, params=params)
if result:
logger.info("Retrieved recipe requirements from recipes service",
recipe_ids_count=len(recipe_ids) if recipe_ids else 0,
@@ -100,7 +100,7 @@ class RecipesServiceClient(BaseServiceClient):
if product_ids:
params["product_ids"] = ",".join(product_ids)
result = await self.get("ingredient-requirements", tenant_id=tenant_id, params=params)
result = await self.get("recipes/ingredient-requirements", tenant_id=tenant_id, params=params)
if result:
logger.info("Retrieved ingredient requirements from recipes service",
product_ids_count=len(product_ids) if product_ids else 0,
@@ -118,7 +118,7 @@ class RecipesServiceClient(BaseServiceClient):
"recipe_id": recipe_id,
"quantity": quantity
}
result = await self.post("calculate-ingredients", data=data, tenant_id=tenant_id)
result = await self.post("recipes/operations/calculate-ingredients", data=data, tenant_id=tenant_id)
if result:
logger.info("Calculated ingredient quantities from recipes service",
recipe_id=recipe_id, quantity=quantity, tenant_id=tenant_id)
@@ -132,7 +132,7 @@ class RecipesServiceClient(BaseServiceClient):
"""Calculate total ingredient requirements for multiple production batches"""
try:
data = {"production_requests": production_requests}
result = await self.post("calculate-batch-ingredients", data=data, tenant_id=tenant_id)
result = await self.post("recipes/operations/calculate-batch-ingredients", data=data, tenant_id=tenant_id)
if result:
logger.info("Calculated batch ingredient requirements from recipes service",
batches_count=len(production_requests), tenant_id=tenant_id)
@@ -149,7 +149,7 @@ class RecipesServiceClient(BaseServiceClient):
async def get_production_instructions(self, tenant_id: str, recipe_id: str) -> Optional[Dict[str, Any]]:
"""Get detailed production instructions for a recipe"""
try:
result = await self.get(f"recipes/{recipe_id}/production-instructions", tenant_id=tenant_id)
result = await self.get(f"recipes/recipes/{recipe_id}/production-instructions", tenant_id=tenant_id)
if result:
logger.info("Retrieved production instructions from recipes service",
recipe_id=recipe_id, tenant_id=tenant_id)
@@ -162,7 +162,7 @@ class RecipesServiceClient(BaseServiceClient):
async def get_recipe_yield_info(self, tenant_id: str, recipe_id: str) -> Optional[Dict[str, Any]]:
"""Get yield information for a recipe"""
try:
result = await self.get(f"recipes/{recipe_id}/yield", tenant_id=tenant_id)
result = await self.get(f"recipes/recipes/{recipe_id}/yield", tenant_id=tenant_id)
if result:
logger.info("Retrieved recipe yield info from recipes service",
recipe_id=recipe_id, tenant_id=tenant_id)
@@ -179,7 +179,7 @@ class RecipesServiceClient(BaseServiceClient):
"recipe_id": recipe_id,
"quantity": quantity
}
result = await self.post("validate-feasibility", data=data, tenant_id=tenant_id)
result = await self.post("recipes/operations/validate-feasibility", data=data, tenant_id=tenant_id)
if result:
logger.info("Validated recipe feasibility from recipes service",
recipe_id=recipe_id, quantity=quantity, tenant_id=tenant_id)
@@ -196,7 +196,7 @@ class RecipesServiceClient(BaseServiceClient):
async def get_recipe_cost_analysis(self, tenant_id: str, recipe_id: str) -> Optional[Dict[str, Any]]:
"""Get cost analysis for a recipe"""
try:
result = await self.get(f"recipes/{recipe_id}/cost-analysis", tenant_id=tenant_id)
result = await self.get(f"recipes/recipes/{recipe_id}/cost-analysis", tenant_id=tenant_id)
if result:
logger.info("Retrieved recipe cost analysis from recipes service",
recipe_id=recipe_id, tenant_id=tenant_id)
@@ -210,7 +210,7 @@ class RecipesServiceClient(BaseServiceClient):
"""Optimize production batch to minimize waste and cost"""
try:
data = {"requirements": requirements}
result = await self.post("optimize-batch", data=data, tenant_id=tenant_id)
result = await self.post("recipes/operations/optimize-batch", data=data, tenant_id=tenant_id)
if result:
logger.info("Optimized production batch from recipes service",
requirements_count=len(requirements), tenant_id=tenant_id)
@@ -227,7 +227,7 @@ class RecipesServiceClient(BaseServiceClient):
async def get_dashboard_summary(self, tenant_id: str) -> Optional[Dict[str, Any]]:
"""Get recipes dashboard summary data"""
try:
result = await self.get("dashboard-summary", tenant_id=tenant_id)
result = await self.get("recipes/dashboard/summary", tenant_id=tenant_id)
if result:
logger.info("Retrieved recipes dashboard summary",
tenant_id=tenant_id)
@@ -241,7 +241,7 @@ class RecipesServiceClient(BaseServiceClient):
"""Get most popular recipes based on production frequency"""
try:
params = {"period": period}
result = await self.get("popular-recipes", tenant_id=tenant_id, params=params)
result = await self.get("recipes/analytics/popular-recipes", tenant_id=tenant_id, params=params)
recipes = result.get('recipes', []) if result else []
logger.info("Retrieved popular recipes from recipes service",
period=period, recipes_count=len(recipes), tenant_id=tenant_id)