add product composition
This commit is contained in:
parent
bd287cfcd1
commit
d7f21cdd81
3 changed files with 51 additions and 1 deletions
|
|
@ -18,8 +18,12 @@ class Rohlik(APIClient):
|
||||||
product = self.get(Endpoints.product.format(product_id=product_id))
|
product = self.get(Endpoints.product.format(product_id=product_id))
|
||||||
prices = self.get(Endpoints.prices.format(product_id=product_id))
|
prices = self.get(Endpoints.prices.format(product_id=product_id))
|
||||||
stock = self.get(Endpoints.stock.format(product_id=product_id))
|
stock = self.get(Endpoints.stock.format(product_id=product_id))
|
||||||
|
description = self.get(Endpoints.description.format(product_id=product_id))
|
||||||
|
composition = self.get(Endpoints.composition.format(product_id=product_id))
|
||||||
product['prices'] = prices
|
product['prices'] = prices
|
||||||
product['stock'] = stock
|
product['stock'] = stock
|
||||||
|
product['description'] = description['description']
|
||||||
|
product['composition'] = composition
|
||||||
return product
|
return product
|
||||||
|
|
||||||
@serialize()
|
@serialize()
|
||||||
|
|
|
||||||
|
|
@ -8,4 +8,6 @@ class Endpoints:
|
||||||
recipe: str = 'services/frontend-service/recipe/{recipe_id}'
|
recipe: str = 'services/frontend-service/recipe/{recipe_id}'
|
||||||
prices: str = 'api/v1/products/{product_id}/prices'
|
prices: str = 'api/v1/products/{product_id}/prices'
|
||||||
stock: str = 'api/v1/products/{product_id}/stock'
|
stock: str = 'api/v1/products/{product_id}/stock'
|
||||||
|
description: str = 'api/v1/products/{product_id}/description'
|
||||||
|
composition: str = 'api/v1/products/{product_id}/composition'
|
||||||
cart: str = 'api/v2/cart'
|
cart: str = 'api/v2/cart'
|
||||||
|
|
@ -60,6 +60,48 @@ class Stock(BaseModel):
|
||||||
in_stock: bool = Field(..., alias='inStock')
|
in_stock: bool = Field(..., alias='inStock')
|
||||||
|
|
||||||
|
|
||||||
|
class Ingredient(BaseModel):
|
||||||
|
type: str
|
||||||
|
ingredients: List['Ingredient']
|
||||||
|
title: str
|
||||||
|
code: Optional[str] = None
|
||||||
|
link: Optional[str] = None
|
||||||
|
|
||||||
|
|
||||||
|
class Allergens(BaseModel):
|
||||||
|
contained: List[str]
|
||||||
|
possibly_contained: List[str] = Field(..., alias='possiblyContained')
|
||||||
|
|
||||||
|
|
||||||
|
class AmountUnit(BaseModel):
|
||||||
|
amount: Decimal
|
||||||
|
unit: str
|
||||||
|
|
||||||
|
|
||||||
|
class NutritionaValues(BaseModel):
|
||||||
|
energy_kj: AmountUnit = Field(..., alias='energyKJ')
|
||||||
|
energy_k_cal: AmountUnit = Field(..., alias='energyKCal')
|
||||||
|
fats: AmountUnit
|
||||||
|
saturated_fats: AmountUnit = Field(..., alias='saturatedFats')
|
||||||
|
carbohydrates: AmountUnit
|
||||||
|
sugars: AmountUnit
|
||||||
|
protein: AmountUnit
|
||||||
|
salt: AmountUnit
|
||||||
|
fiber: AmountUnit
|
||||||
|
|
||||||
|
|
||||||
|
class NutritionalValue(BaseModel):
|
||||||
|
portion: str
|
||||||
|
values: NutritionaValues
|
||||||
|
|
||||||
|
|
||||||
|
class Composition(BaseModel):
|
||||||
|
nutritional_values: List[NutritionalValue] = Field(..., alias='nutritionalValues')
|
||||||
|
ingredients: List[Ingredient]
|
||||||
|
plain_ingredients: Optional[str] = Field(..., alias='plainIngredients')
|
||||||
|
allergens: Optional[Allergens]
|
||||||
|
|
||||||
|
|
||||||
class Product(BaseModel):
|
class Product(BaseModel):
|
||||||
id: int
|
id: int
|
||||||
name: str
|
name: str
|
||||||
|
|
@ -82,3 +124,5 @@ class Product(BaseModel):
|
||||||
attachments: List
|
attachments: List
|
||||||
prices: ProductPrice
|
prices: ProductPrice
|
||||||
stock: Stock
|
stock: Stock
|
||||||
|
description: str
|
||||||
|
composition: Composition
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue