41 lines
920 B
Python
41 lines
920 B
Python
from __future__ import annotations
|
|
|
|
from typing import ClassVar, List, Optional
|
|
|
|
from common import ApiModel
|
|
from pydantic import PrivateAttr
|
|
|
|
|
|
class Product(ApiModel):
|
|
KEYS: ClassVar[List[str]] = [
|
|
"id",
|
|
"product_id",
|
|
"shop_code",
|
|
"link",
|
|
"name",
|
|
"quantity",
|
|
"unit",
|
|
"img_small",
|
|
"img_large",
|
|
]
|
|
NON_INSERT_KEYS: ClassVar[List[str]] = ["id"]
|
|
|
|
id: int = -1
|
|
product_id: str
|
|
shop_code: str
|
|
link: str
|
|
name: str
|
|
quantity: int
|
|
unit: str
|
|
img_small: str
|
|
img_large: str
|
|
# Non-persisted field used in tests and insert helper (not part of public schema)
|
|
_raw_data: Optional[dict] = PrivateAttr(default=None)
|
|
|
|
@property
|
|
def raw_data(self) -> Optional[dict]:
|
|
return self._raw_data
|
|
|
|
@raw_data.setter
|
|
def raw_data(self, value: Optional[dict]) -> None:
|
|
self._raw_data = value
|