88 lines
2.0 KiB
Python
88 lines
2.0 KiB
Python
from datetime import datetime, timezone
|
|
from pydantic import BaseModel, ConfigDict, Field
|
|
|
|
|
|
class ImageRecord(BaseModel):
|
|
fullres_image: str
|
|
preview_image: str
|
|
order_index: int = 0
|
|
|
|
|
|
class CarRecord(BaseModel):
|
|
parser_id: str
|
|
brand: str
|
|
model: str
|
|
year: int | None = None
|
|
price: int | None = None
|
|
currency: str = "USD"
|
|
mileage: int = 0
|
|
country: str = "US"
|
|
is_sold: bool = False
|
|
color: str = "other"
|
|
drive: str | None = None
|
|
gearbox: str | None = None
|
|
steering_wheel: str | None = None
|
|
body_type: str = "OTHER"
|
|
engine_volume: int | None = None
|
|
selling_type: str = "AUCTION"
|
|
one_owner: bool = False
|
|
new_car: bool = False
|
|
is_hidden: bool = False
|
|
origin: str = "NA"
|
|
origin_url: str
|
|
origin_id: str
|
|
is_damaged: bool = False
|
|
evaluation: str | None = None
|
|
non_smoking: bool = True
|
|
rental: bool = False
|
|
repair_history: bool = False
|
|
slug: str
|
|
last_seen_at: datetime = Field(default_factory=lambda: datetime.now(timezone.utc))
|
|
images: list[ImageRecord] = Field(default_factory=list)
|
|
|
|
|
|
class ImageRead(BaseModel):
|
|
model_config = ConfigDict(from_attributes=True)
|
|
|
|
id: int
|
|
fullres_image: str
|
|
preview_image: str
|
|
order_index: int = 0
|
|
|
|
|
|
class CarRead(BaseModel):
|
|
model_config = ConfigDict(from_attributes=True)
|
|
|
|
id: int
|
|
parser_id: str
|
|
brand: str
|
|
model: str
|
|
year: int | None = None
|
|
price: int | None = None
|
|
currency: str = "USD"
|
|
mileage: int = 0
|
|
country: str = "US"
|
|
is_sold: bool = False
|
|
color: str = "other"
|
|
drive: str | None = None
|
|
gearbox: str | None = None
|
|
steering_wheel: str | None = None
|
|
body_type: str = "OTHER"
|
|
engine_volume: int | None = None
|
|
selling_type: str = "AUCTION"
|
|
one_owner: bool = False
|
|
new_car: bool = False
|
|
is_hidden: bool = False
|
|
origin: str = "NA"
|
|
origin_url: str = ""
|
|
origin_id: str = ""
|
|
is_damaged: bool = False
|
|
evaluation: str | None = None
|
|
non_smoking: bool = True
|
|
rental: bool = False
|
|
repair_history: bool = False
|
|
slug: str = ""
|
|
last_seen_at: datetime | None = None
|
|
images: list[ImageRead] = Field(default_factory=list)
|
|
|