Skip to content

Commit 805c7f4

Browse files
authored
Merge pull request #157 from livechat/ME-87/deleting_messages
ME-87: Add new method delete_event in customer api v3.6. Fix api vers…
2 parents 4a9a31c + 5180b25 commit 805c7f4

File tree

4 files changed

+56
-2
lines changed

4 files changed

+56
-2
lines changed

changelog.md

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

44
## [0.4.2] - TBA
55

6+
### Added
7+
- New method `delete_event` in customer-api v3.6.
8+
69
### Changed
710
- Improved websocket response collection + extended logging in the websocket client.
811

livechat/customer/rtm/api/v34.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def __init__(
2020
if isinstance(organization_id, str):
2121
self.ws = WebsocketClient(
2222
url=
23-
f'wss://{base_url}/v3.5/customer/rtm/ws?organization_id={organization_id}',
23+
f'wss://{base_url}/v3.4/customer/rtm/ws?organization_id={organization_id}',
2424
header=header)
2525
else:
2626
raise ValueError(

livechat/customer/rtm/api/v36.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def __init__(
2020
if isinstance(organization_id, str):
2121
self.ws = WebsocketClient(
2222
url=
23-
f'wss://{base_url}/v3.5/customer/rtm/ws?organization_id={organization_id}',
23+
f'wss://{base_url}/v3.6/customer/rtm/ws?organization_id={organization_id}',
2424
header=header)
2525
else:
2626
raise ValueError(
@@ -214,6 +214,28 @@ def send_event(self,
214214
payload = prepare_payload(locals())
215215
return self.ws.send({'action': 'send_event', 'payload': payload})
216216

217+
def delete_event(self,
218+
chat_id: str = None,
219+
thread_id: str = None,
220+
event_id: str = None,
221+
payload: dict = None) -> RtmResponse:
222+
''' Deletes an event.
223+
224+
Args:
225+
chat_id (str): ID of the chat from which to delete the event.
226+
thread_id (str): ID of the thread from which to delete the event.
227+
event_id (str): ID of the event to be deleted.
228+
payload (dict): Custom payload to be used as request's data.
229+
It overrides all other parameters provided for the method.
230+
231+
Returns:
232+
RtmResponse: RTM response structure (`request_id`, `action`,
233+
`type`, `success` and `payload` properties)
234+
'''
235+
if payload is None:
236+
payload = prepare_payload(locals())
237+
return self.ws.send({'action': 'delete_event', 'payload': payload})
238+
217239
def send_rich_message_postback(self,
218240
chat_id: str = None,
219241
thread_id: str = None,

livechat/customer/web/api/v36.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,35 @@ def send_event(self,
312312
json=payload,
313313
headers=headers)
314314

315+
def delete_event(self,
316+
chat_id: str = None,
317+
thread_id: str = None,
318+
event_id: str = None,
319+
payload: dict = None,
320+
headers: dict = None) -> httpx.Response:
321+
''' Deletes an event.
322+
323+
Args:
324+
chat_id (str): ID of the chat from which to delete the event.
325+
thread_id (str): ID of the thread from which to delete the event.
326+
event_id (str): ID of the event to be deleted.
327+
328+
payload (dict): Custom payload to be used as request's data.
329+
It overrides all other parameters provided for the method.
330+
headers (dict): Custom headers to be used with session headers.
331+
They will be merged with session-level values that are set,
332+
however, these method-level parameters will not be persisted across requests.
333+
334+
Returns:
335+
httpx.Response: The Response object from `httpx` library,
336+
which contains a server’s response to an HTTP request. '''
337+
if payload is None:
338+
payload = prepare_payload(locals())
339+
return self.session.post(
340+
f'{self.api_url}/delete_event{self.query_string}',
341+
json=payload,
342+
headers=headers)
343+
315344
def upload_file(self,
316345
file: typing.BinaryIO = None,
317346
headers: dict = None) -> httpx.Response:

0 commit comments

Comments
 (0)