2026-06-03 21:40:26 +00:00
|
|
|
"""Pydantic schemas for Contact endpoints."""
|
|
|
|
|
|
|
|
|
|
from __future__ import annotations
|
|
|
|
|
|
|
|
|
|
from datetime import datetime
|
|
|
|
|
|
|
|
|
|
from pydantic import BaseModel, ConfigDict, EmailStr, Field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ContactBase(BaseModel):
|
|
|
|
|
first_name: str = Field(..., min_length=1, max_length=128)
|
|
|
|
|
last_name: str = Field(..., min_length=1, max_length=128)
|
2026-06-10 20:52:56 +00:00
|
|
|
email: EmailStr | None = None
|
|
|
|
|
phone: str | None = Field(None, max_length=64)
|
|
|
|
|
account_id: int | None = None
|
2026-06-03 21:40:26 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
class ContactCreate(ContactBase):
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ContactUpdate(BaseModel):
|
2026-06-10 20:52:56 +00:00
|
|
|
first_name: str | None = Field(None, min_length=1, max_length=128)
|
|
|
|
|
last_name: str | None = Field(None, min_length=1, max_length=128)
|
|
|
|
|
email: EmailStr | None = None
|
|
|
|
|
phone: str | None = Field(None, max_length=64)
|
|
|
|
|
account_id: int | None = None
|
2026-06-03 21:40:26 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
class ContactOut(ContactBase):
|
|
|
|
|
model_config = ConfigDict(from_attributes=True)
|
|
|
|
|
|
|
|
|
|
id: int
|
|
|
|
|
org_id: int
|
|
|
|
|
owner_id: int
|
|
|
|
|
created_at: datetime
|
|
|
|
|
updated_at: datetime
|
2026-06-10 20:52:56 +00:00
|
|
|
deleted_at: datetime | None = None
|
2026-06-03 21:40:26 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
class ContactListItem(ContactOut):
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
__all__ = ["ContactCreate", "ContactListItem", "ContactOut", "ContactUpdate"]
|