Files
test_task_crm/app/api/v1/deals/models.py
T
Artem Kashaev e6a3a2cc23
Test / test (push) Successful in 12s
Test / test (pull_request) Successful in 11s
feat: enhance deal management with CRUD operations and improve payload handling
2025-11-27 16:15:47 +05:00

34 lines
890 B
Python

"""Deal API schemas."""
from __future__ import annotations
from decimal import Decimal
from pydantic import BaseModel
from app.models.deal import DealCreate, DealStage, DealStatus
class DealCreatePayload(BaseModel):
contact_id: int
title: str
amount: Decimal | None = None
currency: str | None = None
owner_id: int | None = None
def to_domain(self, *, organization_id: int, fallback_owner: int) -> DealCreate:
return DealCreate(
organization_id=organization_id,
contact_id=self.contact_id,
owner_id=self.owner_id or fallback_owner,
title=self.title,
amount=self.amount,
currency=self.currency,
)
class DealUpdatePayload(BaseModel):
status: DealStatus | None = None
stage: DealStage | None = None
amount: Decimal | None = None
currency: str | None = None