|
| 1 | +from dataclasses import dataclass |
| 2 | +from datetime import datetime |
| 3 | +from typing import Any, Dict, List, Literal, Optional |
| 4 | +from uuid import UUID |
| 5 | + |
| 6 | +from pydantic import Field |
| 7 | + |
| 8 | +from pybotx.models.api_base import VerifiedPayloadBaseModel |
| 9 | +from pybotx.models.base_command import ( |
| 10 | + BaseBotAPIContext, |
| 11 | + BotAPIBaseCommand, |
| 12 | + BotAPIBaseSystemEventPayload, |
| 13 | + BotCommandBase, |
| 14 | +) |
| 15 | +from pybotx.models.bot_account import BotAccount |
| 16 | +from pybotx.models.enums import ( |
| 17 | + BotAPIConferenceLinkTypes, |
| 18 | + BotAPISystemEventTypes, |
| 19 | + ConferenceLinkTypes, |
| 20 | + convert_conference_link_type_to_domain, |
| 21 | +) |
| 22 | + |
| 23 | + |
| 24 | +@dataclass |
| 25 | +class ConferenceChangedEvent(BotCommandBase): |
| 26 | + """Event `system:conference_changed`. |
| 27 | +
|
| 28 | + Attributes: |
| 29 | + access_code: access code for conference. |
| 30 | + actor: who changes conference. |
| 31 | + added_users: added users to conference. |
| 32 | + admins: admins conference. |
| 33 | + call_id: id conference. |
| 34 | + deleted_users: deleted users to conference. |
| 35 | + end_at: end conference. |
| 36 | + link: conference link. |
| 37 | + link_id: conference link id. |
| 38 | + link_type: link type on conference (public|trusts|corporate|server). |
| 39 | + members: list members. |
| 40 | + name: name conference. |
| 41 | + operation: operation. |
| 42 | + sip_number: sip number conference. |
| 43 | + start_at: end conference. |
| 44 | + """ |
| 45 | + |
| 46 | + access_code: Optional[str] |
| 47 | + actor: Optional[UUID] |
| 48 | + added_users: List[UUID] |
| 49 | + admins: List[UUID] |
| 50 | + call_id: UUID |
| 51 | + deleted_users: List[UUID] |
| 52 | + end_at: Optional[datetime] |
| 53 | + link: str |
| 54 | + link_id: UUID |
| 55 | + link_type: ConferenceLinkTypes |
| 56 | + members: List[UUID] |
| 57 | + name: str |
| 58 | + operation: str |
| 59 | + sip_number: int |
| 60 | + start_at: datetime |
| 61 | + |
| 62 | + |
| 63 | +class BotAPIConferenceChangedData(VerifiedPayloadBaseModel): |
| 64 | + access_code: Optional[str] |
| 65 | + actor: Optional[UUID] |
| 66 | + added_users: List[UUID] |
| 67 | + admins: List[UUID] |
| 68 | + call_id: UUID |
| 69 | + deleted_users: List[UUID] |
| 70 | + end_at: Optional[datetime] |
| 71 | + link: str |
| 72 | + link_id: UUID |
| 73 | + link_type: BotAPIConferenceLinkTypes |
| 74 | + members: List[UUID] |
| 75 | + name: str |
| 76 | + operation: str |
| 77 | + sip_number: int |
| 78 | + start_at: datetime |
| 79 | + |
| 80 | + |
| 81 | +class BotAPIConferenceChangedPayload(BotAPIBaseSystemEventPayload): |
| 82 | + body: Literal[BotAPISystemEventTypes.CONFERENCE_CHANGED] |
| 83 | + data: BotAPIConferenceChangedData |
| 84 | + |
| 85 | + |
| 86 | +class BotAPIConferenceChanged(BotAPIBaseCommand): |
| 87 | + payload: BotAPIConferenceChangedPayload = Field(..., alias="command") |
| 88 | + sender: BaseBotAPIContext = Field(..., alias="from") |
| 89 | + |
| 90 | + def to_domain(self, raw_command: Dict[str, Any]) -> ConferenceChangedEvent: |
| 91 | + return ConferenceChangedEvent( |
| 92 | + bot=BotAccount( |
| 93 | + id=self.bot_id, |
| 94 | + host=self.sender.host, |
| 95 | + ), |
| 96 | + raw_command=raw_command, |
| 97 | + access_code=self.payload.data.access_code, |
| 98 | + actor=self.payload.data.actor, |
| 99 | + added_users=self.payload.data.added_users, |
| 100 | + admins=self.payload.data.admins, |
| 101 | + call_id=self.payload.data.call_id, |
| 102 | + deleted_users=self.payload.data.deleted_users, |
| 103 | + end_at=self.payload.data.end_at, |
| 104 | + link=self.payload.data.link, |
| 105 | + link_id=self.payload.data.link_id, |
| 106 | + link_type=convert_conference_link_type_to_domain( |
| 107 | + self.payload.data.link_type, |
| 108 | + ), |
| 109 | + members=self.payload.data.members, |
| 110 | + name=self.payload.data.name, |
| 111 | + operation=self.payload.data.operation, |
| 112 | + sip_number=self.payload.data.sip_number, |
| 113 | + start_at=self.payload.data.start_at, |
| 114 | + ) |
0 commit comments