34 lines
890 B
Python
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
|