Files

107 lines
3.8 KiB
Python
Raw Permalink Normal View History

"""Pydantic schemas for contacts and tags."""
from pydantic import BaseModel, Field
class TagResponse(BaseModel):
"""Public tag representation."""
id: str
name: str
color: str | None = None
model_config = {"from_attributes": True}
class ContactCreateRequest(BaseModel):
"""Request body for creating a new contact."""
type: str = Field(..., pattern="^(company|person)$")
company_name: str | None = Field(None, max_length=255)
first_name: str | None = Field(None, max_length=100)
last_name: str | None = Field(None, max_length=100)
email: str | None = Field(None, max_length=255)
phone: str | None = Field(None, max_length=50)
mobile: str | None = Field(None, max_length=50)
website: str | None = Field(None, max_length=500)
billing_street: str | None = Field(None, max_length=255)
billing_number: str | None = Field(None, max_length=20)
billing_postalcode: str | None = Field(None, max_length=20)
billing_city: str | None = Field(None, max_length=100)
billing_country: str | None = Field(None, max_length=100)
shipping_street: str | None = Field(None, max_length=255)
shipping_number: str | None = Field(None, max_length=20)
shipping_postalcode: str | None = Field(None, max_length=20)
shipping_city: str | None = Field(None, max_length=100)
shipping_country: str | None = Field(None, max_length=100)
tax_number: str | None = Field(None, max_length=50)
note: str | None = None
tag_ids: list[str] = []
class ContactUpdateRequest(BaseModel):
"""Request body for updating an existing contact."""
type: str | None = Field(None, pattern="^(company|person)$")
company_name: str | None = Field(None, max_length=255)
first_name: str | None = Field(None, max_length=100)
last_name: str | None = Field(None, max_length=100)
email: str | None = Field(None, max_length=255)
phone: str | None = Field(None, max_length=50)
mobile: str | None = Field(None, max_length=50)
website: str | None = Field(None, max_length=500)
billing_street: str | None = Field(None, max_length=255)
billing_number: str | None = Field(None, max_length=20)
billing_postalcode: str | None = Field(None, max_length=20)
billing_city: str | None = Field(None, max_length=100)
billing_country: str | None = Field(None, max_length=100)
shipping_street: str | None = Field(None, max_length=255)
shipping_number: str | None = Field(None, max_length=20)
shipping_postalcode: str | None = Field(None, max_length=20)
shipping_city: str | None = Field(None, max_length=100)
shipping_country: str | None = Field(None, max_length=100)
tax_number: str | None = Field(None, max_length=50)
note: str | None = None
tag_ids: list[str] | None = None
class ContactResponse(BaseModel):
"""Public contact representation with tags."""
id: str
account_id: str
type: str
company_name: str | None = None
first_name: str | None = None
last_name: str | None = None
email: str | None = None
phone: str | None = None
mobile: str | None = None
website: str | None = None
billing_street: str | None = None
billing_number: str | None = None
billing_postalcode: str | None = None
billing_city: str | None = None
billing_country: str | None = None
shipping_street: str | None = None
shipping_number: str | None = None
shipping_postalcode: str | None = None
shipping_city: str | None = None
shipping_country: str | None = None
tax_number: str | None = None
note: str | None = None
created_at: str
updated_at: str
tags: list[TagResponse] = []
model_config = {"from_attributes": True}
class ContactListResponse(BaseModel):
"""Paginated list of contacts."""
items: list[ContactResponse]
total: int
page: int
size: int