Upload app/schemas/contact.py
This commit is contained in:
@@ -0,0 +1,46 @@
|
|||||||
|
"""Pydantic schemas for Contact endpoints."""
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from datetime import datetime
|
||||||
|
from typing import Optional
|
||||||
|
|
||||||
|
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)
|
||||||
|
email: Optional[EmailStr] = None
|
||||||
|
phone: Optional[str] = Field(None, max_length=64)
|
||||||
|
account_id: Optional[int] = None
|
||||||
|
|
||||||
|
|
||||||
|
class ContactCreate(ContactBase):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class ContactUpdate(BaseModel):
|
||||||
|
first_name: Optional[str] = Field(None, min_length=1, max_length=128)
|
||||||
|
last_name: Optional[str] = Field(None, min_length=1, max_length=128)
|
||||||
|
email: Optional[EmailStr] = None
|
||||||
|
phone: Optional[str] = Field(None, max_length=64)
|
||||||
|
account_id: Optional[int] = None
|
||||||
|
|
||||||
|
|
||||||
|
class ContactOut(ContactBase):
|
||||||
|
model_config = ConfigDict(from_attributes=True)
|
||||||
|
|
||||||
|
id: int
|
||||||
|
org_id: int
|
||||||
|
owner_id: int
|
||||||
|
created_at: datetime
|
||||||
|
updated_at: datetime
|
||||||
|
deleted_at: Optional[datetime] = None
|
||||||
|
|
||||||
|
|
||||||
|
class ContactListItem(ContactOut):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
__all__ = ["ContactCreate", "ContactListItem", "ContactOut", "ContactUpdate"]
|
||||||
Reference in New Issue
Block a user