2026-05-31 20:36:42 +00:00
|
|
|
"""Pydantic schemas for contacts and tags."""
|
|
|
|
|
|
2026-06-10 21:31:41 +00:00
|
|
|
from pydantic import BaseModel, Field
|
2026-05-31 20:36:42 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
class TagResponse(BaseModel):
|
|
|
|
|
"""Public tag representation."""
|
2026-06-10 21:31:41 +00:00
|
|
|
|
2026-05-31 20:36:42 +00:00
|
|
|
id: str
|
|
|
|
|
name: str
|
|
|
|
|
color: str | None = None
|
|
|
|
|
|
|
|
|
|
model_config = {"from_attributes": True}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ContactCreateRequest(BaseModel):
|
|
|
|
|
"""Request body for creating a new contact."""
|
2026-06-10 21:31:41 +00:00
|
|
|
|
2026-05-31 20:36:42 +00:00
|
|
|
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."""
|
2026-06-10 21:31:41 +00:00
|
|
|
|
2026-05-31 20:36:42 +00:00
|
|
|
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."""
|
2026-06-10 21:31:41 +00:00
|
|
|
|
2026-05-31 20:36:42 +00:00
|
|
|
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."""
|
2026-06-10 21:31:41 +00:00
|
|
|
|
2026-05-31 20:36:42 +00:00
|
|
|
items: list[ContactResponse]
|
|
|
|
|
total: int
|
|
|
|
|
page: int
|
|
|
|
|
size: int
|