Skip to content

ME-87: Add new method delete_event in customer api v3.6. Fix api vers… #157

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ All notable changes to this project will be documented in this file.

## [0.4.2] - TBA

### Added
- New method `delete_event` in customer-api v3.6.

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

Expand Down
2 changes: 1 addition & 1 deletion livechat/customer/rtm/api/v34.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def __init__(
if isinstance(organization_id, str):
self.ws = WebsocketClient(
url=
f'wss://{base_url}/v3.5/customer/rtm/ws?organization_id={organization_id}',
f'wss://{base_url}/v3.4/customer/rtm/ws?organization_id={organization_id}',
header=header)
else:
raise ValueError(
Expand Down
24 changes: 23 additions & 1 deletion livechat/customer/rtm/api/v36.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def __init__(
if isinstance(organization_id, str):
self.ws = WebsocketClient(
url=
f'wss://{base_url}/v3.5/customer/rtm/ws?organization_id={organization_id}',
f'wss://{base_url}/v3.6/customer/rtm/ws?organization_id={organization_id}',
header=header)
else:
raise ValueError(
Expand Down Expand Up @@ -214,6 +214,28 @@ def send_event(self,
payload = prepare_payload(locals())
return self.ws.send({'action': 'send_event', 'payload': payload})

def delete_event(self,
chat_id: str = None,
thread_id: str = None,
event_id: str = None,
payload: dict = None) -> RtmResponse:
''' Deletes an event.

Args:
chat_id (str): ID of the chat from which to delete the event.
thread_id (str): ID of the thread from which to delete the event.
event_id (str): ID of the event to be deleted.
payload (dict): Custom payload to be used as request's data.
It overrides all other parameters provided for the method.

Returns:
RtmResponse: RTM response structure (`request_id`, `action`,
`type`, `success` and `payload` properties)
'''
if payload is None:
payload = prepare_payload(locals())
return self.ws.send({'action': 'delete_event', 'payload': payload})

def send_rich_message_postback(self,
chat_id: str = None,
thread_id: str = None,
Expand Down
29 changes: 29 additions & 0 deletions livechat/customer/web/api/v36.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,35 @@ def send_event(self,
json=payload,
headers=headers)

def delete_event(self,
chat_id: str = None,
thread_id: str = None,
event_id: str = None,
payload: dict = None,
headers: dict = None) -> httpx.Response:
''' Deletes an event.

Args:
chat_id (str): ID of the chat from which to delete the event.
thread_id (str): ID of the thread from which to delete the event.
event_id (str): ID of the event to be deleted.

payload (dict): Custom payload to be used as request's data.
It overrides all other parameters provided for the method.
headers (dict): Custom headers to be used with session headers.
They will be merged with session-level values that are set,
however, these method-level parameters will not be persisted across requests.

Returns:
httpx.Response: The Response object from `httpx` library,
which contains a server’s response to an HTTP request. '''
if payload is None:
payload = prepare_payload(locals())
return self.session.post(
f'{self.api_url}/delete_event{self.query_string}',
json=payload,
headers=headers)

def upload_file(self,
file: typing.BinaryIO = None,
headers: dict = None) -> httpx.Response:
Expand Down