diff --git a/changelog.md b/changelog.md index e7d9a9c..d463978 100644 --- a/changelog.md +++ b/changelog.md @@ -5,6 +5,7 @@ All notable changes to this project will be documented in this file. ### Added - Support for new version 3.7. +- New method `request_welcome_message` in customer-api v3.6 and v3.7. - New method `delete_event` in customer-api v3.6. - New methods in configuration-api v3.6 for greetings: `create_greeting`, `delete_greeting`, `get_greeting`, `update_greeting`, `list_greetings`. - New methods in agent-api v3.6: `send_thinking_indicator`, `send_message_preview`. @@ -25,6 +26,7 @@ All notable changes to this project will be documented in this file. ### Removed - Support for version 3.3. - Removed support for billing-api. +- Support `get_predicted_agent` in customer-api v3.7. - Support for `create_customer` method removed in agent-api v3.6 and later. - Support for `incoming_customer` webhook removed in v3.6 and later. diff --git a/livechat/customer/rtm/api/v36.py b/livechat/customer/rtm/api/v36.py index 33b3e72..8c8d7d0 100644 --- a/livechat/customer/rtm/api/v36.py +++ b/livechat/customer/rtm/api/v36.py @@ -605,6 +605,22 @@ def get_predicted_agent(self, payload: dict = None) -> RtmResponse: 'action': 'get_predicted_agent', 'payload': {} if payload is None else payload }) + + def request_welcome_message(self, payload: dict = None) -> RtmResponse: + ''' Requests a welcome message. + + Args: + 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) + ''' + return self.ws.send({ + 'action': 'request_welcome_message', + 'payload': {} if payload is None else payload + }) def get_url_info(self, url: str = None, diff --git a/livechat/customer/rtm/api/v37.py b/livechat/customer/rtm/api/v37.py index 602c056..48677d6 100644 --- a/livechat/customer/rtm/api/v37.py +++ b/livechat/customer/rtm/api/v37.py @@ -590,8 +590,8 @@ def get_form(self, payload = prepare_payload(locals()) return self.ws.send({'action': 'get_form', 'payload': payload}) - def get_predicted_agent(self, payload: dict = None) -> RtmResponse: - ''' Gets the predicted Agent - the one the Customer will chat with when the chat starts. + def request_welcome_message(self, payload: dict = None) -> RtmResponse: + ''' Requests a welcome message. Args: payload (dict): Custom payload to be used as request's data. @@ -602,7 +602,7 @@ def get_predicted_agent(self, payload: dict = None) -> RtmResponse: `type`, `success` and `payload` properties) ''' return self.ws.send({ - 'action': 'get_predicted_agent', + 'action': 'request_welcome_message', 'payload': {} if payload is None else payload }) diff --git a/livechat/customer/web/api/v36.py b/livechat/customer/web/api/v36.py index 034ec3c..412e9da 100644 --- a/livechat/customer/web/api/v36.py +++ b/livechat/customer/web/api/v36.py @@ -867,6 +867,28 @@ def get_predicted_agent(self, f'{self.api_url}/get_predicted_agent{self.query_string}', json={} if payload is None else payload, headers=headers) + + def request_welcome_message(self, + payload: dict = None, + headers: dict = None) -> httpx.Response: + ''' Requests a welcome message. + To use this method, the Customer needs to be logged in, which can be done via the `login` method. + + Args: + 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. + ''' + return self.session.post( + f'{self.api_url}/request_welcome_message{self.query_string}', + json={} if payload is None else payload, + headers=headers) def get_url_info(self, url: str = None, diff --git a/livechat/customer/web/api/v37.py b/livechat/customer/web/api/v37.py index 2613232..6fc1646 100644 --- a/livechat/customer/web/api/v37.py +++ b/livechat/customer/web/api/v37.py @@ -846,10 +846,10 @@ def get_form(self, json=payload, headers=headers) - def get_predicted_agent(self, + def request_welcome_message(self, payload: dict = None, headers: dict = None) -> httpx.Response: - ''' Gets the predicted Agent - the one the Customer will chat with when the chat starts. + ''' Requests a welcome message. To use this method, the Customer needs to be logged in, which can be done via the `login` method. Args: @@ -864,7 +864,7 @@ def get_predicted_agent(self, which contains a server’s response to an HTTP request. ''' return self.session.post( - f'{self.api_url}/get_predicted_agent{self.query_string}', + f'{self.api_url}/request_welcome_message{self.query_string}', json={} if payload is None else payload, headers=headers)