pyrohlik/rohlik/models/recipe.py
2024-11-17 10:38:58 +01:00

103 lines
2 KiB
Python

from typing import List, Optional
from pydantic import BaseModel, Field
class Srcset(BaseModel):
small: str
big: str
class Image(BaseModel):
path: str
alt: str
srcset: Srcset
class Serving(BaseModel):
name: str
default: bool
class Author(BaseModel):
name: str
annotation: str
image_path: str = Field(..., alias='imagePath')
class Tip(BaseModel):
content: str
images: List[str]
class Step(BaseModel):
step_number: int = Field(..., alias='stepNumber')
name: str
content: str
images: List[str]
class Direction(BaseModel):
name: str
position: int
steps: List[Step]
class Tag(BaseModel):
slug: str
label: str
class Breadcrumb(BaseModel):
title: str
link: str
children: List[str]
class Item(BaseModel):
name: str
ingredient_id: int = Field(..., alias='ingredientId')
position: int
products_count: int = Field(..., alias='productsCount')
img_path: str = Field(..., alias='imgPath')
ingredient_name: str = Field(..., alias='ingredientName')
class Ingredient(BaseModel):
name: str
position: int
items: List[Item]
class IngredientsSummaryItem(BaseModel):
name: str
position: int
items: List[str]
class Recipe(BaseModel):
id: int
name: str
annotation: str
servings: List[Serving]
image: Image
author: Author
tips: List[Tip]
directions: List[Direction]
ingredients: List[Ingredient]
breadcrumbs: List[Breadcrumb]
ingredients_summary: List[IngredientsSummaryItem] = Field(
..., alias='ingredientsSummary'
)
tags: List[Tag]
type: str
has_all_ingredients_available: bool = Field(..., alias='hasAllIngredientsAvailable')
link: str
favorite: bool
is_favorite: bool = Field(..., alias='isFavorite')
is_new: bool = Field(..., alias='isNew')
is_best_seller: bool = Field(..., alias='isBestSeller')
class RecipeResponse(BaseModel):
status: int
messages: List
recipe: Recipe