135 lines
3.7 KiB
Python
135 lines
3.7 KiB
Python
from decimal import Decimal
|
|
from datetime import datetime
|
|
from typing import List, Optional
|
|
from pydantic import BaseModel, Field
|
|
|
|
|
|
class Price(BaseModel):
|
|
amount: Decimal
|
|
currency: str
|
|
|
|
|
|
class Badge(BaseModel):
|
|
type: str
|
|
title: str
|
|
subtitle: Optional[str]
|
|
tooltip: Optional[str]
|
|
|
|
|
|
class Country(BaseModel):
|
|
name: str
|
|
name_id: str = Field(..., alias='nameId')
|
|
code: str
|
|
|
|
|
|
class SalePrice(BaseModel):
|
|
id: int
|
|
type: str
|
|
trigger_amount: int = Field(..., alias='triggerAmount')
|
|
price: Price
|
|
price_per_unit: Price = Field(..., alias='pricePerUnit')
|
|
badges: List[Badge]
|
|
valid_till: str = Field(..., alias='validTill')
|
|
active: bool
|
|
|
|
class ProductPrice(BaseModel):
|
|
price: Price
|
|
price_per_unit: Price = Field(..., alias='pricePerUnit')
|
|
sales: List[SalePrice]
|
|
|
|
|
|
class SaleStock(BaseModel):
|
|
id: int
|
|
amount: int
|
|
unlimited_amount: bool = Field(..., alias='unlimitedAmount')
|
|
shelf_life: Optional[str] = Field(..., alias='shelfLife')
|
|
|
|
|
|
class ShelfLife(BaseModel):
|
|
average: int
|
|
minimal: int
|
|
type: str
|
|
bestBefore: Optional[str]
|
|
|
|
|
|
class Stock(BaseModel):
|
|
warehouse_id: int = Field(..., alias='warehouseId')
|
|
unavailability_reason: Optional[str] = Field(..., alias='unavailabilityReason')
|
|
preorder_enabled: bool = Field(..., alias='preorderEnabled')
|
|
max_basket_amount: int = Field(..., alias='maxBasketAmount')
|
|
max_basket_amount_reason: str = Field(..., alias='maxBasketAmountReason')
|
|
delivery_restriction: Optional[str] = Field(..., alias='deliveryRestriction')
|
|
expected_replenishment: Optional[datetime] = Field(..., alias='expectedReplenishment')
|
|
availability_dimension: int = Field(..., alias='availabilityDimension')
|
|
shelf_life: Optional[ShelfLife] = Field(..., alias='shelfLife')
|
|
billable_packaging: Optional[str] = Field(..., alias='billablePackaging')
|
|
sales: List[SaleStock]
|
|
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: Optional[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):
|
|
id: int
|
|
name: str
|
|
slug: str
|
|
main_category_id: int = Field(..., alias='mainCategoryId')
|
|
unit: str
|
|
textual_amount: str = Field(..., alias='textualAmount')
|
|
badges: List[Badge]
|
|
archived: bool
|
|
premium_only: bool = Field(..., alias='premiumOnly')
|
|
brand: Optional[str]
|
|
images: List[str]
|
|
countries: List[Country]
|
|
can_be_favorite: bool = Field(..., alias='canBeFavorite')
|
|
information: List
|
|
weighted_item: bool = Field(..., alias='weightedItem')
|
|
package_ratio: int = Field(..., alias='packageRatio')
|
|
seller_id: int = Field(..., alias='sellerId')
|
|
flag: Optional[str]
|
|
attachments: List
|
|
prices: ProductPrice
|
|
stock: Stock
|
|
description: str
|
|
composition: Composition
|