Files
BitrixDealsBot/apps/bot/domain.py
T

74 lines
1.3 KiB
Python

from dataclasses import dataclass
from datetime import datetime
DEALS_PER_PAGE = 5
MAX_DEAL_MESSAGE_LENGTH = 3900
@dataclass(frozen=True)
class Binding:
member_id: str
domain: str
bitrix_user_id: int
telegram_user_id: int
@dataclass(frozen=True)
class OAuthCredentials:
member_id: str
domain: str
bitrix_user_id: int
access_token: bytes
refresh_token: bytes
expires_at: datetime
version: int
@dataclass(frozen=True)
class ClientInfo:
name: str | None = None
company: str | None = None
phone: str | None = None
@dataclass(frozen=True)
class DealStageFilter:
key: str
title: str
stage_id: str | None
assigned_to_viewer: bool = False
@dataclass(frozen=True)
class DealStage:
stage_id: str
title: str
semantics: str
@property
def is_final(self) -> bool:
return self.semantics in {"S", "F"}
@dataclass(frozen=True)
class DealStageAdvance:
deal_id: str
current_stage_id: str
target_stage_id: str
target_stage_title: str
is_final: bool
@dataclass(frozen=True)
class DealPage:
deals: list[dict]
page: int
total_deals: int
total_pages: int
stage_filter: DealStageFilter
stage_filters: tuple[DealStageFilter, ...]
@property
def has_next(self) -> bool:
return self.page + 1 < self.total_pages