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))
|
||||
prices = self.get(Endpoints.prices.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['stock'] = stock
|
||||
product['description'] = description['description']
|
||||
product['composition'] = composition
|
||||
return product
|
||||
|
||||
@serialize()
|
||||
|
|
|
|||
|
|
@ -8,4 +8,6 @@ class Endpoints:
|
|||
recipe: str = 'services/frontend-service/recipe/{recipe_id}'
|
||||
prices: str = 'api/v1/products/{product_id}/prices'
|
||||
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'
|
||||
|
|
@ -57,7 +57,49 @@ class Stock(BaseModel):
|
|||
shelf_life: Optional[str] = Field(..., alias='shelfLife')
|
||||
billable_packaging: Optional[str] = Field(..., alias='billablePackaging')
|
||||
sales: List[SaleStock]
|
||||
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):
|
||||
|
|
@ -82,3 +124,5 @@ class Product(BaseModel):
|
|||
attachments: List
|
||||
prices: ProductPrice
|
||||
stock: Stock
|
||||
description: str
|
||||
composition: Composition
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue