diff --git a/app/schemas/address.py b/app/schemas/address.py new file mode 100644 index 0000000..8518c21 --- /dev/null +++ b/app/schemas/address.py @@ -0,0 +1,59 @@ +"""Address schemas — create, update, read, list.""" + +from __future__ import annotations + +from pydantic import BaseModel, Field + + +class AddressCreate(BaseModel): + entity_type: str = Field(..., pattern="^(company|contact)$", description="'company' or 'contact'") + entity_id: str = Field(..., description="UUID of the parent entity") + label: str = Field(..., min_length=1, max_length=100) + address_type: str = Field( + ..., + pattern="^(billing|shipping|headquarters|branch|private|other)$", + ) + street: str | None = Field(None, max_length=255) + street_number: str | None = Field(None, max_length=20) + city: str | None = Field(None, max_length=100) + zip: str | None = Field(None, max_length=20) + state: str | None = Field(None, max_length=100) + country: str | None = Field(None, max_length=2) + is_default: bool = False + + +class AddressUpdate(BaseModel): + label: str | None = Field(None, min_length=1, max_length=100) + address_type: str | None = Field( + None, + pattern="^(billing|shipping|headquarters|branch|private|other)$", + ) + street: str | None = Field(None, max_length=255) + street_number: str | None = Field(None, max_length=20) + city: str | None = Field(None, max_length=100) + zip: str | None = Field(None, max_length=20) + state: str | None = Field(None, max_length=100) + country: str | None = Field(None, max_length=2) + is_default: bool | None = None + + +class AddressResponse(BaseModel): + id: str + entity_type: str + entity_id: str + label: str + address_type: str + street: str | None = None + street_number: str | None = None + city: str | None = None + zip: str | None = None + state: str | None = None + country: str | None = None + is_default: bool + created_at: str | None = None + updated_at: str | None = None + + +class AddressListResponse(BaseModel): + items: list[AddressResponse] + total: int