fooder-api/fooder/model/product.py

37 lines
579 B
Python
Raw Normal View History

2023-04-01 16:19:12 +02:00
from typing import List
2024-08-03 22:30:39 +02:00
from pydantic import BaseModel
2023-04-01 16:19:12 +02:00
class Product(BaseModel):
"""Product."""
id: int
name: str
calories: float
protein: float
carb: float
fat: float
2023-07-30 20:18:42 +02:00
fiber: float
2024-08-03 22:30:39 +02:00
barcode: str | None
usage_count_cached: int | None
2023-04-01 16:19:12 +02:00
class Config:
2023-07-30 20:18:42 +02:00
from_attributes = True
2023-04-01 16:19:12 +02:00
class CreateProductPayload(BaseModel):
"""ProductCreatePayload."""
name: str
protein: float
carb: float
fat: float
2023-07-30 20:18:42 +02:00
fiber: float
2023-04-01 16:19:12 +02:00
class ListProductPayload(BaseModel):
"""ProductListPayload."""
products: List[Product]