@@ -29,10 +29,10 @@ <h1 class="title">Module <code>livechat.agent.rtm.api.v33</code></h1>
29
29
</ summary >
30
30
< pre > < code class ="python "> ''' Module containing Agent RTM API client implementation for v3.3. '''
31
31
32
- from typing import Any, Optional
32
+ from typing import Any, Optional, Union
33
33
34
34
from livechat.utils.helpers import prepare_payload
35
- from livechat.utils.structures import RtmResponse
35
+ from livechat.utils.structures import AccessToken, RtmResponse
36
36
from livechat.utils.ws_client import WebsocketClient
37
37
38
38
# pylint: disable=unused-argument, too-many-arguments, invalid-name, redefined-builtin
@@ -43,9 +43,26 @@ <h1 class="title">Module <code>livechat.agent.rtm.api.v33</code></h1>
43
43
def __init__(self, url: str):
44
44
self.ws = WebsocketClient(url=f'wss://{url}/v3.3/agent/rtm/ws')
45
45
46
- def open_connection(self) -> None:
47
- ''' Opens WebSocket connection. '''
48
- self.ws.open()
46
+ def open_connection(self,
47
+ origin: dict = None,
48
+ ping_timeout: float = 3,
49
+ ping_interval: float = 5,
50
+ ws_conn_timeout: float = 10,
51
+ keep_alive: bool = True) -> None:
52
+ ''' Opens WebSocket connection.
53
+
54
+ Args:
55
+ origin (dict): Specifies origin while creating websocket connection.
56
+ ping_timeout (int or float): timeout (in seconds) if the pong message is not received,
57
+ by default sets to 3 seconds.
58
+ ping_interval (int or float): automatically sends "ping" command every specified period (in seconds).
59
+ If set to 0, no ping is sent periodically, by default sets to 5 seconds.
60
+ ws_conn_timeout (int or float): timeout (in seconds) to wait for WebSocket connection,
61
+ by default sets to 10 seconds.
62
+ keep_alive(bool): Bool which states if connection should be kept, by default sets to `True`.
63
+ '''
64
+ self.ws.open(origin, ping_timeout, ping_interval, ws_conn_timeout,
65
+ keep_alive)
49
66
50
67
def close_connection(self) -> None:
51
68
''' Closes WebSocket connection. '''
@@ -407,7 +424,11 @@ <h1 class="title">Module <code>livechat.agent.rtm.api.v33</code></h1>
407
424
opts['author_id'] = author_id
408
425
if payload is None:
409
426
payload = prepare_payload(locals())
410
- return self.ws.send({'action': 'send_event', 'payload': payload, **opts})
427
+ return self.ws.send({
428
+ 'action': 'send_event',
429
+ 'payload': payload,
430
+ **opts
431
+ })
411
432
412
433
def send_rich_message_postback(self,
413
434
chat_id: str = None,
@@ -797,7 +818,7 @@ <h1 class="title">Module <code>livechat.agent.rtm.api.v33</code></h1>
797
818
# Status
798
819
799
820
def login(self,
800
- token: str = None,
821
+ token: Union[AccessToken, str] = None,
801
822
timezone: str = None,
802
823
reconnect: bool = None,
803
824
push_notifications: dict = None,
@@ -830,6 +851,8 @@ <h1 class="title">Module <code>livechat.agent.rtm.api.v33</code></h1>
830
851
RtmResponse: RTM response structure (`request_id`, `action`,
831
852
`type`, `success` and `payload` properties)
832
853
'''
854
+ if token:
855
+ token = str(token)
833
856
if payload is None:
834
857
payload = prepare_payload(locals())
835
858
return self.ws.send({'action': 'login', 'payload': payload})
@@ -1057,9 +1080,26 @@ <h2 class="section-title" id="header-classes">Classes</h2>
1057
1080
def __init__(self, url: str):
1058
1081
self.ws = WebsocketClient(url=f'wss://{url}/v3.3/agent/rtm/ws')
1059
1082
1060
- def open_connection(self) -> None:
1061
- ''' Opens WebSocket connection. '''
1062
- self.ws.open()
1083
+ def open_connection(self,
1084
+ origin: dict = None,
1085
+ ping_timeout: float = 3,
1086
+ ping_interval: float = 5,
1087
+ ws_conn_timeout: float = 10,
1088
+ keep_alive: bool = True) -> None:
1089
+ ''' Opens WebSocket connection.
1090
+
1091
+ Args:
1092
+ origin (dict): Specifies origin while creating websocket connection.
1093
+ ping_timeout (int or float): timeout (in seconds) if the pong message is not received,
1094
+ by default sets to 3 seconds.
1095
+ ping_interval (int or float): automatically sends "ping" command every specified period (in seconds).
1096
+ If set to 0, no ping is sent periodically, by default sets to 5 seconds.
1097
+ ws_conn_timeout (int or float): timeout (in seconds) to wait for WebSocket connection,
1098
+ by default sets to 10 seconds.
1099
+ keep_alive(bool): Bool which states if connection should be kept, by default sets to `True`.
1100
+ '''
1101
+ self.ws.open(origin, ping_timeout, ping_interval, ws_conn_timeout,
1102
+ keep_alive)
1063
1103
1064
1104
def close_connection(self) -> None:
1065
1105
''' Closes WebSocket connection. '''
@@ -1421,7 +1461,11 @@ <h2 class="section-title" id="header-classes">Classes</h2>
1421
1461
opts['author_id'] = author_id
1422
1462
if payload is None:
1423
1463
payload = prepare_payload(locals())
1424
- return self.ws.send({'action': 'send_event', 'payload': payload, **opts})
1464
+ return self.ws.send({
1465
+ 'action': 'send_event',
1466
+ 'payload': payload,
1467
+ **opts
1468
+ })
1425
1469
1426
1470
def send_rich_message_postback(self,
1427
1471
chat_id: str = None,
@@ -1811,7 +1855,7 @@ <h2 class="section-title" id="header-classes">Classes</h2>
1811
1855
# Status
1812
1856
1813
1857
def login(self,
1814
- token: str = None,
1858
+ token: Union[AccessToken, str] = None,
1815
1859
timezone: str = None,
1816
1860
reconnect: bool = None,
1817
1861
push_notifications: dict = None,
@@ -1844,6 +1888,8 @@ <h2 class="section-title" id="header-classes">Classes</h2>
1844
1888
RtmResponse: RTM response structure (`request_id`, `action`,
1845
1889
`type`, `success` and `payload` properties)
1846
1890
'''
1891
+ if token:
1892
+ token = str(token)
1847
1893
if payload is None:
1848
1894
payload = prepare_payload(locals())
1849
1895
return self.ws.send({'action': 'login', 'payload': payload})
@@ -3036,7 +3082,7 @@ <h2 id="returns">Returns</h2>
3036
3082
</ details >
3037
3083
</ dd >
3038
3084
< dt id ="livechat.agent.rtm.api.v33.AgentRtmV33.login "> < code class ="name flex ">
3039
- < span > def < span class ="ident "> login</ span > </ span > (< span > self, token: str = None, timezone: str = None, reconnect: bool = None, push_notifications: dict = None, application: dict = None, away: bool = None, customer_monitoring_level: str = None, pushes: dict = None, payload: dict = None) ‑> livechat.utils.structures.RtmResponse</ span >
3085
+ < span > def < span class ="ident "> login</ span > </ span > (< span > self, token: Union[livechat.utils.structures.AccessToken, str] = None, timezone: str = None, reconnect: bool = None, push_notifications: dict = None, application: dict = None, away: bool = None, customer_monitoring_level: str = None, pushes: dict = None, payload: dict = None) ‑> livechat.utils.structures.RtmResponse</ span >
3040
3086
</ code > </ dt >
3041
3087
< dd >
3042
3088
< div class ="desc "> < p > Logs in agent.</ p >
@@ -3079,7 +3125,7 @@ <h2 id="returns">Returns</h2>
3079
3125
< span > Expand source code</ span >
3080
3126
</ summary >
3081
3127
< pre > < code class ="python "> def login(self,
3082
- token: str = None,
3128
+ token: Union[AccessToken, str] = None,
3083
3129
timezone: str = None,
3084
3130
reconnect: bool = None,
3085
3131
push_notifications: dict = None,
@@ -3112,6 +3158,8 @@ <h2 id="returns">Returns</h2>
3112
3158
RtmResponse: RTM response structure (`request_id`, `action`,
3113
3159
`type`, `success` and `payload` properties)
3114
3160
'''
3161
+ if token:
3162
+ token = str(token)
3115
3163
if payload is None:
3116
3164
payload = prepare_payload(locals())
3117
3165
return self.ws.send({'action': 'login', 'payload': payload})</ code > </ pre >
@@ -3255,17 +3303,49 @@ <h2 id="returns">Returns</h2>
3255
3303
</ details >
3256
3304
</ dd >
3257
3305
< dt id ="livechat.agent.rtm.api.v33.AgentRtmV33.open_connection "> < code class ="name flex ">
3258
- < span > def < span class ="ident "> open_connection</ span > </ span > (< span > self) ‑> None</ span >
3306
+ < span > def < span class ="ident "> open_connection</ span > </ span > (< span > self, origin: dict = None, ping_timeout: float = 3, ping_interval: float = 5, ws_conn_timeout: float = 10, keep_alive: bool = True ) ‑> None</ span >
3259
3307
</ code > </ dt >
3260
3308
< dd >
3261
- < div class ="desc "> < p > Opens WebSocket connection.</ p > </ div >
3309
+ < div class ="desc "> < p > Opens WebSocket connection.</ p >
3310
+ < h2 id ="args "> Args</ h2 >
3311
+ < dl >
3312
+ < dt > < strong > < code > origin</ code > </ strong > : < code > dict</ code > </ dt >
3313
+ < dd > Specifies origin while creating websocket connection.</ dd >
3314
+ < dt > < strong > < code > ping_timeout</ code > </ strong > : < code > int</ code > or < code > float</ code > </ dt >
3315
+ < dd > timeout (in seconds) if the pong message is not received,
3316
+ by default sets to 3 seconds.</ dd >
3317
+ < dt > < strong > < code > ping_interval</ code > </ strong > : < code > int</ code > or < code > float</ code > </ dt >
3318
+ < dd > automatically sends "ping" command every specified period (in seconds).
3319
+ If set to 0, no ping is sent periodically, by default sets to 5 seconds.</ dd >
3320
+ < dt > < strong > < code > ws_conn_timeout</ code > </ strong > : < code > int</ code > or < code > float</ code > </ dt >
3321
+ < dd > timeout (in seconds) to wait for WebSocket connection,
3322
+ by default sets to 10 seconds.</ dd >
3323
+ </ dl >
3324
+ < p > keep_alive(bool): Bool which states if connection should be kept, by default sets to < code > True</ code > .</ p > </ div >
3262
3325
< details class ="source ">
3263
3326
< summary >
3264
3327
< span > Expand source code</ span >
3265
3328
</ summary >
3266
- < pre > < code class ="python "> def open_connection(self) -> None:
3267
- ''' Opens WebSocket connection. '''
3268
- self.ws.open()</ code > </ pre >
3329
+ < pre > < code class ="python "> def open_connection(self,
3330
+ origin: dict = None,
3331
+ ping_timeout: float = 3,
3332
+ ping_interval: float = 5,
3333
+ ws_conn_timeout: float = 10,
3334
+ keep_alive: bool = True) -> None:
3335
+ ''' Opens WebSocket connection.
3336
+
3337
+ Args:
3338
+ origin (dict): Specifies origin while creating websocket connection.
3339
+ ping_timeout (int or float): timeout (in seconds) if the pong message is not received,
3340
+ by default sets to 3 seconds.
3341
+ ping_interval (int or float): automatically sends "ping" command every specified period (in seconds).
3342
+ If set to 0, no ping is sent periodically, by default sets to 5 seconds.
3343
+ ws_conn_timeout (int or float): timeout (in seconds) to wait for WebSocket connection,
3344
+ by default sets to 10 seconds.
3345
+ keep_alive(bool): Bool which states if connection should be kept, by default sets to `True`.
3346
+ '''
3347
+ self.ws.open(origin, ping_timeout, ping_interval, ws_conn_timeout,
3348
+ keep_alive)</ code > </ pre >
3269
3349
</ details >
3270
3350
</ dd >
3271
3351
< dt id ="livechat.agent.rtm.api.v33.AgentRtmV33.remove_user_from_chat "> < code class ="name flex ">
@@ -3476,7 +3556,11 @@ <h2 id="returns">Returns</h2>
3476
3556
opts['author_id'] = author_id
3477
3557
if payload is None:
3478
3558
payload = prepare_payload(locals())
3479
- return self.ws.send({'action': 'send_event', 'payload': payload, **opts})</ code > </ pre >
3559
+ return self.ws.send({
3560
+ 'action': 'send_event',
3561
+ 'payload': payload,
3562
+ **opts
3563
+ })</ code > </ pre >
3480
3564
</ details >
3481
3565
</ dd >
3482
3566
< dt id ="livechat.agent.rtm.api.v33.AgentRtmV33.send_rich_message_postback "> < code class ="name flex ">
@@ -4269,4 +4353,4 @@ <h4><code><a title="livechat.agent.rtm.api.v33.AgentRtmV33" href="#livechat.agen
4269
4353
< p > Generated by < a href ="https://pdoc3.github.io/pdoc " title ="pdoc: Python API documentation generator "> < cite > pdoc</ cite > 0.10.0</ a > .</ p >
4270
4354
</ footer >
4271
4355
</ body >
4272
- </ html >
4356
+ </ html >
0 commit comments