diff --git a/changelog.md b/changelog.md index 270e0c9..959a7f5 100644 --- a/changelog.md +++ b/changelog.md @@ -13,6 +13,7 @@ All notable changes to this project will be documented in this file. - New methods in agent-api v3.6: `send_thinking_indicator`, `send_message_preview`. - New methods in configuration-api v3.7 for canned responses: `create_canned_response`, `update_canned_response`, `list_canned_responses`, `delete_canned_response`. - New method `request_thread_summary` in agent-api v3.6 and v3.7. +- New method `get_thread_transcript` in agent-api v3.6 and v3.7. - New flag `name_is_default` in method `update_customer` in customer-api v3.6 and v3.7. - New field `phone_number` in method `update_customer` in customer-api v3.6 and v3.7. - New method in reports-api v3.7: report `campaigns_conversion`. diff --git a/livechat/agent/rtm/api/v36.py b/livechat/agent/rtm/api/v36.py index b33bf14..65ad387 100644 --- a/livechat/agent/rtm/api/v36.py +++ b/livechat/agent/rtm/api/v36.py @@ -427,6 +427,29 @@ def request_thread_summary(self, 'payload': payload }) + def get_thread_transcript(self, + chat_id: str = None, + thread_id: str = None, + payload: dict = None) -> RtmResponse: + ''' Returns a plain-text transcript of a given thread. + + Args: + chat_id (str): ID of the chat the thread belongs to. + thread_id (str): ID of the thread to return the transcript for. + 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': 'get_thread_transcript', + 'payload': payload + }) + # Properties def update_chat_properties(self, diff --git a/livechat/agent/rtm/api/v37.py b/livechat/agent/rtm/api/v37.py index c62663b..1530671 100644 --- a/livechat/agent/rtm/api/v37.py +++ b/livechat/agent/rtm/api/v37.py @@ -427,6 +427,29 @@ def request_thread_summary(self, 'payload': payload }) + def get_thread_transcript(self, + chat_id: str = None, + thread_id: str = None, + payload: dict = None) -> RtmResponse: + ''' Returns a plain-text transcript of a given thread. + + Args: + chat_id (str): ID of the chat the thread belongs to. + thread_id (str): ID of the thread to return the transcript for. + 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': 'get_thread_transcript', + 'payload': payload + }) + # Properties def update_chat_properties(self, diff --git a/livechat/agent/web/api/v36.py b/livechat/agent/web/api/v36.py index 9b4105f..3240d22 100644 --- a/livechat/agent/web/api/v36.py +++ b/livechat/agent/web/api/v36.py @@ -508,6 +508,31 @@ def request_thread_summary(self, json=payload, headers=headers) + def get_thread_transcript(self, + chat_id: str = None, + thread_id: str = None, + payload: dict = None, + headers: dict = None) -> httpx.Response: + ''' Returns a plain-text transcript of a given thread. + + Args: + chat_id (str): ID of the chat the thread belongs to. + thread_id (str): ID of the thread to return the transcript for. + 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}/get_thread_transcript', + json=payload, + headers=headers) + # Properties def update_chat_properties(self, diff --git a/livechat/agent/web/api/v37.py b/livechat/agent/web/api/v37.py index a6e41c3..b4c84fa 100644 --- a/livechat/agent/web/api/v37.py +++ b/livechat/agent/web/api/v37.py @@ -508,6 +508,31 @@ def request_thread_summary(self, json=payload, headers=headers) + def get_thread_transcript(self, + chat_id: str = None, + thread_id: str = None, + payload: dict = None, + headers: dict = None) -> httpx.Response: + ''' Returns a plain-text transcript of a given thread. + + Args: + chat_id (str): ID of the chat the thread belongs to. + thread_id (str): ID of the thread to return the transcript for. + 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}/get_thread_transcript', + json=payload, + headers=headers) + # Properties def update_chat_properties(self,