Skip to content

Commit de0f457

Browse files
authored
Merge pull request #118 from livechat/LC-1065-add-logout-method-in-agent-web-api
LC-1065: Add logout method in Agent Web API v3.6
2 parents 571120b + 293c2fb commit de0f457

File tree

3 files changed

+40
-7
lines changed

3 files changed

+40
-7
lines changed

changelog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file.
33

44
## [0.3.8] - TBA
55

6+
### Added
7+
- Support for `logout` method in agent-api v3.6 web class.
8+
- Support for `agent_id` parameter in agent-api v3.6 `logout` method.
9+
610
### Changed
711
- Implemented truncation of request params in logging for large data.
812

livechat/agent/rtm/api/v36.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,11 @@ def send_event(self,
344344
opts['author_id'] = author_id
345345
if payload is None:
346346
payload = prepare_payload(locals())
347-
return self.ws.send({'action': 'send_event', 'payload': payload, **opts})
347+
return self.ws.send({
348+
'action': 'send_event',
349+
'payload': payload,
350+
**opts
351+
})
348352

349353
def send_rich_message_postback(self,
350354
chat_id: str = None,
@@ -810,21 +814,23 @@ def set_away_status(self,
810814
payload = prepare_payload(locals())
811815
return self.ws.send({'action': 'set_away_status', 'payload': payload})
812816

813-
def logout(self, payload: dict = None) -> RtmResponse:
814-
''' Logs out agent.
817+
def logout(self,
818+
agent_id: str = None,
819+
payload: dict = None) -> RtmResponse:
820+
''' Logs the Agent out.
815821
816822
Args:
823+
agent_id (str): Login of the agent to logout.
817824
payload (dict): Custom payload to be used as request's data.
818825
It overrides all other parameters provided for the method.
819826
820827
Returns:
821828
RtmResponse: RTM response structure (`request_id`, `action`,
822829
`type`, `success` and `payload` properties)
823830
'''
824-
return self.ws.send({
825-
'action': 'logout',
826-
'payload': {} if payload is None else payload
827-
})
831+
if payload is None:
832+
payload = prepare_payload(locals())
833+
return self.ws.send({'action': 'logout', 'payload': payload})
828834

829835
def list_routing_statuses(self,
830836
filters: dict = None,

livechat/agent/web/api/v36.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1034,3 +1034,26 @@ def list_agents_for_transfer(self,
10341034
return self.session.post(f'{self.api_url}/list_agents_for_transfer',
10351035
json=payload,
10361036
headers=headers)
1037+
1038+
def logout(self,
1039+
agent_id: str = None,
1040+
payload: dict = None,
1041+
headers: dict = None) -> httpx.Response:
1042+
''' Logs the Agent out.
1043+
1044+
Args:
1045+
agent_id (str): Login of the agent to logout.
1046+
payload (dict): Custom payload to be used as request's data.
1047+
It overrides all other parameters provided for the method.
1048+
headers (dict): Custom headers to be used with session headers.
1049+
They will be merged with session-level values that are set,
1050+
however, these method-level parameters will not be persisted across requests.
1051+
1052+
Returns:
1053+
httpx.Response: The Response object from `httpx` library,
1054+
which contains a server’s response to an HTTP request. '''
1055+
if payload is None:
1056+
payload = prepare_payload(locals())
1057+
return self.session.post(f'{self.api_url}/logout',
1058+
json=payload,
1059+
headers=headers)

0 commit comments

Comments
 (0)