Upload app/schemas/account.py
This commit is contained in:
@@ -0,0 +1,59 @@
|
|||||||
|
"""Pydantic schemas for Account endpoints."""
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from datetime import datetime
|
||||||
|
from decimal import Decimal
|
||||||
|
from typing import Any, Optional
|
||||||
|
|
||||||
|
from pydantic import BaseModel, ConfigDict, Field
|
||||||
|
|
||||||
|
from app.models.account import AccountSize, Industry
|
||||||
|
|
||||||
|
|
||||||
|
class AccountBase(BaseModel):
|
||||||
|
"""Shared fields for create/update."""
|
||||||
|
|
||||||
|
name: str = Field(..., min_length=1, max_length=255)
|
||||||
|
website: Optional[str] = Field(None, max_length=512)
|
||||||
|
industry: Optional[Industry] = None
|
||||||
|
size: Optional[AccountSize] = None
|
||||||
|
address: Optional[dict[str, Any]] = None
|
||||||
|
|
||||||
|
|
||||||
|
class AccountCreate(AccountBase):
|
||||||
|
"""Request body for POST /api/v1/accounts/."""
|
||||||
|
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class AccountUpdate(BaseModel):
|
||||||
|
"""Request body for PATCH /api/v1/accounts/{id}. All optional."""
|
||||||
|
|
||||||
|
name: Optional[str] = Field(None, min_length=1, max_length=255)
|
||||||
|
website: Optional[str] = Field(None, max_length=512)
|
||||||
|
industry: Optional[Industry] = None
|
||||||
|
size: Optional[AccountSize] = None
|
||||||
|
address: Optional[dict[str, Any]] = None
|
||||||
|
|
||||||
|
|
||||||
|
class AccountOut(AccountBase):
|
||||||
|
"""Response schema for an account."""
|
||||||
|
|
||||||
|
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 AccountListItem(AccountOut):
|
||||||
|
"""Slim schema for list responses."""
|
||||||
|
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
__all__ = ["AccountCreate", "AccountListItem", "AccountOut", "AccountUpdate"]
|
||||||
Reference in New Issue
Block a user