Skip to content

Commit d774fc1

Browse files
author
skamieniarz
committed
API-10478: Add all webhooks data classes for v3.4
1 parent 1eefb3e commit d774fc1

File tree

1 file changed

+351
-0
lines changed

1 file changed

+351
-0
lines changed

livechat/webhooks/v34.py

Lines changed: 351 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,354 @@ class WebhookV34:
1313
organization_id: str
1414
additional_data: dict
1515
payload: dict
16+
17+
def payload_data_class(self):
18+
''' Returns payload's data class for webhook's action. '''
19+
return {
20+
'incoming_chat': IncomingChat,
21+
'chat_deactivated': ChatDeactivated,
22+
'chat_access_updated': ChatAccessUpdated,
23+
'chat_transferred': ChatTransferred,
24+
'user_added_to_chat': UserAddedToChat,
25+
'user_removed_from_chat': UserRemovedFromChat,
26+
'incoming_event': IncomingEvent,
27+
'event_updated': EventUpdated,
28+
'incoming_rich_message_postback': IncomingRichMessagePostback,
29+
'chat_properties_updated': ChatPropertiesUpdated,
30+
'chat_properties_deleted': ChatPropertiesDeleted,
31+
'thread_properties_updated': ThreadPropertiesUpdated,
32+
'thread_properties_deleted': ThreadPropertiesDeleted,
33+
'event_properties_updated': EventPropertiesUpdated,
34+
'event_properties_deleted': EventPropertiesDeleted,
35+
'thread_tagged': ThreadTagged,
36+
'thread_untagged': ThreadUntagged,
37+
'routing_status_set': RoutingStatusSet,
38+
'incoming_customer': IncomingCustomer,
39+
'customer_session_fields_updated': CustomerSessionFieldsUpdated,
40+
'agent_created': AgentCreated,
41+
'agent_approved': AgentApproved,
42+
'agent_updated': AgentUpdated,
43+
'agent_suspended': AgentSuspended,
44+
'agent_unsuspended': AgentUnsuspended,
45+
'agent_deleted': AgentDeleted,
46+
'auto_access_added': AutoAccessAdded,
47+
'auto_access_updated': AutoAccessUpdated,
48+
'auto_access_deleted': AutoAccessDeleted,
49+
'bot_created': BotCreated,
50+
'bot_updated': BotUpdated,
51+
'bot_deleted': BotDeleted,
52+
'group_created': GroupCreated,
53+
'group_deleted': GroupDeleted,
54+
'group_updated': GroupUpdated,
55+
'events_marked_as_seen': EventsMarkedAsSeen,
56+
}[self.action]
57+
58+
59+
# Chats
60+
61+
62+
@dataclass
63+
class IncomingChat:
64+
chat: dict
65+
transferred_from: dict = None
66+
67+
68+
@dataclass
69+
class ChatDeactivated:
70+
chat_id: str
71+
thread_id: str
72+
user_id: str = None
73+
74+
75+
# Chat access
76+
77+
78+
@dataclass
79+
class ChatAccessUpdated:
80+
id: str
81+
access: dict
82+
83+
84+
@dataclass
85+
class ChatTransferred:
86+
chat_id: str
87+
reason: str
88+
transferred_to: dict
89+
thread_id: str = None
90+
requester_id: str = None
91+
queue: dict = None
92+
93+
94+
# Chat users
95+
96+
97+
@dataclass
98+
class UserAddedToChat:
99+
chat_id: str
100+
reason: str
101+
requester_id: str
102+
thread_id: str = None
103+
user_type: str = None
104+
user: dict = None
105+
106+
107+
@dataclass
108+
class UserRemovedFromChat:
109+
chat_id: str
110+
user_id: str
111+
reason: str
112+
requester_id: str
113+
thread_id: str = None
114+
user_type: str = None
115+
116+
117+
# Events
118+
119+
120+
@dataclass
121+
class IncomingEvent:
122+
chat_id: str
123+
thread_id: str
124+
event: dict = None
125+
126+
127+
@dataclass
128+
class EventUpdated:
129+
chat_id: str
130+
thread_id: str
131+
event: dict
132+
133+
134+
@dataclass
135+
class IncomingRichMessagePostback:
136+
user_id: str
137+
chat_id: str
138+
thread_id: str
139+
event_id: str
140+
postback: dict
141+
142+
143+
# Properties
144+
145+
146+
@dataclass
147+
class ChatPropertiesUpdated:
148+
chat_id: str
149+
properties: dict
150+
151+
152+
@dataclass
153+
class ChatPropertiesDeleted:
154+
chat_id: str
155+
properties: dict
156+
157+
158+
@dataclass
159+
class ThreadPropertiesUpdated:
160+
chat_id: str
161+
thread_id: str
162+
properties: dict
163+
164+
165+
@dataclass
166+
class ThreadPropertiesDeleted:
167+
chat_id: str
168+
thread_id: str
169+
properties: dict
170+
171+
172+
@dataclass
173+
class EventPropertiesUpdated:
174+
chat_id: str
175+
thread_id: str
176+
event_id: str
177+
properties: dict
178+
179+
180+
@dataclass
181+
class EventPropertiesDeleted:
182+
chat_id: str
183+
thread_id: str
184+
event_id: str
185+
properties: dict
186+
187+
188+
# Thread tags
189+
190+
191+
@dataclass
192+
class ThreadTagged:
193+
chat_id: str
194+
thread_id: str
195+
tag: str
196+
197+
198+
@dataclass
199+
class ThreadUntagged:
200+
chat_id: str
201+
thread_id: str
202+
tag: str
203+
204+
205+
# Status
206+
207+
208+
@dataclass
209+
class RoutingStatusSet:
210+
agent_id: str
211+
status: str
212+
213+
214+
# Customers
215+
216+
217+
@dataclass
218+
class IncomingCustomer:
219+
customer: dict
220+
221+
222+
@dataclass
223+
class CustomerSessionFieldsUpdated:
224+
id: str
225+
session_fields: list
226+
active_chat: dict = None
227+
228+
229+
# Configuration
230+
231+
232+
@dataclass
233+
class AgentCreated:
234+
id: str
235+
name: str
236+
awaiting_approval: bool
237+
role: str = None
238+
avatar: str = None
239+
job_title: str = None
240+
mobile: str = None
241+
max_chats_count: int = None
242+
groups: list = None
243+
notifications: list = None
244+
email_subscriptions: list = None
245+
work_scheduler: dict = None
246+
247+
248+
@dataclass
249+
class AgentApproved:
250+
id: str
251+
252+
253+
@dataclass
254+
class AgentUpdated:
255+
id: str
256+
name: str = None
257+
role: str = None
258+
avatar: str = None
259+
job_title: str = None
260+
mobile: str = None
261+
max_chats_count: int = None
262+
groups: list = None
263+
notifications: list = None
264+
email_subscriptions: list = None
265+
work_scheduler: dict = None
266+
267+
268+
@dataclass
269+
class AgentSuspended:
270+
id: str
271+
272+
273+
@dataclass
274+
class AgentUnsuspended:
275+
id: str
276+
277+
278+
@dataclass
279+
class AgentDeleted:
280+
id: str
281+
282+
283+
@dataclass
284+
class AutoAccessAdded:
285+
id: str
286+
description: str
287+
access: dict
288+
conditions: dict
289+
next_id: str = None
290+
291+
292+
@dataclass
293+
class AutoAccessUpdated:
294+
id: str
295+
description: str = None
296+
access: dict = None
297+
conditions: dict = None
298+
next_id: str = None
299+
300+
301+
@dataclass
302+
class AutoAccessDeleted:
303+
id: str
304+
305+
306+
@dataclass
307+
class BotCreated:
308+
id: str
309+
name: str
310+
default_group_priority: str
311+
owner_client_id: str
312+
avatar: str = None
313+
max_chats_count: int = None
314+
groups: list = None
315+
work_scheduler: dict = None
316+
timezone: str = None
317+
job_title: str = None
318+
319+
320+
@dataclass
321+
class BotUpdated:
322+
id: str
323+
name: str = None
324+
avatar: str = None
325+
max_chats_count: int = None
326+
default_group_priority: str = None
327+
groups: list = None
328+
work_scheduler: dict = None
329+
timezone: str = None
330+
job_title: str = None
331+
332+
333+
@dataclass
334+
class BotDeleted:
335+
id: str
336+
337+
338+
@dataclass
339+
class GroupCreated:
340+
id: int
341+
name: str
342+
language_code: str
343+
agent_priorities: dict
344+
345+
346+
@dataclass
347+
class GroupDeleted:
348+
id: str
349+
350+
351+
@dataclass
352+
class GroupUpdated:
353+
id: int
354+
name: str = None
355+
language_code: str = None
356+
agent_priorities: dict = None
357+
358+
359+
# Other
360+
361+
362+
@dataclass
363+
class EventsMarkedAsSeen:
364+
user_id: str
365+
chat_id: str
366+
seen_up_to: str

0 commit comments

Comments
 (0)