Skip to content

Commit 3c845ef

Browse files
committed
ME-566: Add send_message_preview method
1 parent eba2e47 commit 3c845ef

File tree

3 files changed

+49
-1
lines changed

3 files changed

+49
-1
lines changed

changelog.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ All notable changes to this project will be documented in this file.
66
### Added
77
- New method `delete_event` in customer-api v3.6.
88
- New methods in configuration-api v3.6 for greetings: `create_greeting`, `delete_greeting`, `get_greeting`, `update_greeting`, `list_greetings`.
9-
- New method `send_thinking_indicator` in agent-api v3.6.
9+
- New methods in agent-api v3.6: `send_thinking_indicator`, `send_message_preview`.
1010

1111
### Changed
1212
- Improved websocket response collection + extended logging in the websocket client.

livechat/agent/rtm/api/v36.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -981,6 +981,29 @@ def send_thinking_indicator(self,
981981
'payload': payload
982982
})
983983

984+
def send_event_preview(self,
985+
chat_id: str = None,
986+
event: dict = None,
987+
payload: dict = None) -> RtmResponse:
988+
''' Sends an event preview.
989+
990+
Args:
991+
chat_id (str): ID of the chat you want to send the event preview to.
992+
event (dict): Event object.
993+
payload (dict): Custom payload to be used as request's data.
994+
It overrides all other parameters provided for the method.
995+
996+
Returns:
997+
RtmResponse: RTM response structure (`request_id`, `action`,
998+
`type`, `success` and `payload` properties)
999+
'''
1000+
if payload is None:
1001+
payload = prepare_payload(locals())
1002+
return self.ws.send({
1003+
'action': 'send_event_preview',
1004+
'payload': payload
1005+
})
1006+
9841007
def multicast(self,
9851008
recipients: dict = None,
9861009
content: Any = None,

livechat/agent/web/api/v36.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1018,6 +1018,31 @@ def send_thinking_indicator(self,
10181018
json=payload,
10191019
headers=headers)
10201020

1021+
def send_event_preview(self,
1022+
chat_id: str = None,
1023+
event: dict = None,
1024+
payload: dict = None,
1025+
headers: dict = None) -> httpx.Response:
1026+
''' Sends event preview.
1027+
1028+
Args:
1029+
chat_id (str): ID of the chat to send event preview to.
1030+
event (dict): Event object containing the event data.
1031+
payload (dict): Custom payload to be used as request's data.
1032+
It overrides all other parameters provided for the method.
1033+
headers (dict): Custom headers to be used with session headers.
1034+
They will be merged with session-level values that are set,
1035+
however, these method-level parameters will not be persisted across requests.
1036+
1037+
Returns:
1038+
httpx.Response: The Response object from `httpx` library,
1039+
which contains a server’s response to an HTTP request. '''
1040+
if payload is None:
1041+
payload = prepare_payload(locals())
1042+
return self.session.post(f'{self.api_url}/send_event_preview',
1043+
json=payload,
1044+
headers=headers)
1045+
10211046
def multicast(self,
10221047
recipients: dict = None,
10231048
content: typing.Any = None,

0 commit comments

Comments
 (0)