@@ -29,10 +29,10 @@ <h1 class="title">Module <code>livechat.agent.rtm.api.v33</code></h1>
2929</ summary >
3030< pre > < code class ="python "> ''' Module containing Agent RTM API client implementation for v3.3. '''
3131
32- from typing import Any, Optional
32+ from typing import Any, Optional, Union
3333
3434from livechat.utils.helpers import prepare_payload
35- from livechat.utils.structures import RtmResponse
35+ from livechat.utils.structures import AccessToken, RtmResponse
3636from livechat.utils.ws_client import WebsocketClient
3737
3838# 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>
4343 def __init__(self, url: str):
4444 self.ws = WebsocketClient(url=f'wss://{url}/v3.3/agent/rtm/ws')
4545
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)
4966
5067 def close_connection(self) -> None:
5168 ''' Closes WebSocket connection. '''
@@ -407,7 +424,11 @@ <h1 class="title">Module <code>livechat.agent.rtm.api.v33</code></h1>
407424 opts['author_id'] = author_id
408425 if payload is None:
409426 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+ })
411432
412433 def send_rich_message_postback(self,
413434 chat_id: str = None,
@@ -797,7 +818,7 @@ <h1 class="title">Module <code>livechat.agent.rtm.api.v33</code></h1>
797818# Status
798819
799820 def login(self,
800- token: str = None,
821+ token: Union[AccessToken, str] = None,
801822 timezone: str = None,
802823 reconnect: bool = None,
803824 push_notifications: dict = None,
@@ -830,6 +851,8 @@ <h1 class="title">Module <code>livechat.agent.rtm.api.v33</code></h1>
830851 RtmResponse: RTM response structure (`request_id`, `action`,
831852 `type`, `success` and `payload` properties)
832853 '''
854+ if token:
855+ token = str(token)
833856 if payload is None:
834857 payload = prepare_payload(locals())
835858 return self.ws.send({'action': 'login', 'payload': payload})
@@ -1057,9 +1080,26 @@ <h2 class="section-title" id="header-classes">Classes</h2>
10571080 def __init__(self, url: str):
10581081 self.ws = WebsocketClient(url=f'wss://{url}/v3.3/agent/rtm/ws')
10591082
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)
10631103
10641104 def close_connection(self) -> None:
10651105 ''' Closes WebSocket connection. '''
@@ -1421,7 +1461,11 @@ <h2 class="section-title" id="header-classes">Classes</h2>
14211461 opts['author_id'] = author_id
14221462 if payload is None:
14231463 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+ })
14251469
14261470 def send_rich_message_postback(self,
14271471 chat_id: str = None,
@@ -1811,7 +1855,7 @@ <h2 class="section-title" id="header-classes">Classes</h2>
18111855# Status
18121856
18131857 def login(self,
1814- token: str = None,
1858+ token: Union[AccessToken, str] = None,
18151859 timezone: str = None,
18161860 reconnect: bool = None,
18171861 push_notifications: dict = None,
@@ -1844,6 +1888,8 @@ <h2 class="section-title" id="header-classes">Classes</h2>
18441888 RtmResponse: RTM response structure (`request_id`, `action`,
18451889 `type`, `success` and `payload` properties)
18461890 '''
1891+ if token:
1892+ token = str(token)
18471893 if payload is None:
18481894 payload = prepare_payload(locals())
18491895 return self.ws.send({'action': 'login', 'payload': payload})
@@ -3036,7 +3082,7 @@ <h2 id="returns">Returns</h2>
30363082</ details >
30373083</ dd >
30383084< 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 >
30403086</ code > </ dt >
30413087< dd >
30423088< div class ="desc "> < p > Logs in agent.</ p >
@@ -3079,7 +3125,7 @@ <h2 id="returns">Returns</h2>
30793125< span > Expand source code</ span >
30803126</ summary >
30813127< pre > < code class ="python "> def login(self,
3082- token: str = None,
3128+ token: Union[AccessToken, str] = None,
30833129 timezone: str = None,
30843130 reconnect: bool = None,
30853131 push_notifications: dict = None,
@@ -3112,6 +3158,8 @@ <h2 id="returns">Returns</h2>
31123158 RtmResponse: RTM response structure (`request_id`, `action`,
31133159 `type`, `success` and `payload` properties)
31143160 '''
3161+ if token:
3162+ token = str(token)
31153163 if payload is None:
31163164 payload = prepare_payload(locals())
31173165 return self.ws.send({'action': 'login', 'payload': payload})</ code > </ pre >
@@ -3255,17 +3303,49 @@ <h2 id="returns">Returns</h2>
32553303</ details >
32563304</ dd >
32573305< 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 >
32593307</ code > </ dt >
32603308< 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 >
32623325< details class ="source ">
32633326< summary >
32643327< span > Expand source code</ span >
32653328</ 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 >
32693349</ details >
32703350</ dd >
32713351< 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>
34763556 opts['author_id'] = author_id
34773557 if payload is None:
34783558 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 >
34803564</ details >
34813565</ dd >
34823566< 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
42694353< p > Generated by < a href ="https://pdoc3.github.io/pdoc " title ="pdoc: Python API documentation generator "> < cite > pdoc</ cite > 0.10.0</ a > .</ p >
42704354</ footer >
42714355</ body >
4272- </ html >
4356+ </ html >
0 commit comments