コード例 #1
0
    def enable_license_webhooks(self,
                                owner_client_id: str = None,
                                payload: dict = None) -> requests.Response:
        ''' Enables the webhooks registered for a given Client ID (application)
            for the license associated with the access token used in the request.

            Args:
                owner_client_id (str): The webhook owner (the Client ID for which the webhook is registered).
                payload (dict): Custom payload to be used as request's data.
                                It overrides all other parameters provided for the method.

            Returns:
                requests.Response: The Response object from `requests` 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}/enable_license_webhooks',
                                 json=payload)
コード例 #2
0
ファイル: client.py プロジェクト: livechat/lc-sdk-python
    def set_customer_session_fields(self,
                                    session_fields: list = None,
                                    payload: dict = None) -> dict:
        ''' Sets customer's session fields.

            Args:
                session_fields (list): List of custom object-enclosed key:value pairs.
                payload (dict): Custom payload to be used as request's data.
                        It overrides all other parameters provided for the method.

            Returns:
                dict: Dictionary with response.
        '''
        if payload is None:
            payload = prepare_payload(locals())
        return self.ws.send({
            'action': 'set_customer_session_fields',
            'payload': payload
        })
コード例 #3
0
    def update_license_properties(self,
                                  properties: dict = None,
                                  payload: dict = None) -> requests.Response:
        ''' Updates a property value within a license. This operation doesn't
            overwrite the existing values.

            Args:
                properties (dict): An object with namespaces as keys and properties (grouped in objects) as values.
                payload (dict): Custom payload to be used as request's data.
                                It overrides all other parameters provided for the method.

            Returns:
                requests.Response: The Response object from `requests` 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}/update_license_properties',
                                 json=payload)
コード例 #4
0
    def get_group(self,
                  id: int = None,
                  fields: list = None,
                  payload: dict = None) -> requests.Response:
        ''' Returns details about a group specified by its id.

            Args:
                id (int): Groups' ID.
                fields (list): Additional fields to include.
                payload (dict): Custom payload to be used as request's data.
                                It overrides all other parameters provided for the method.

            Returns:
                requests.Response: The Response object from `requests` 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_group', json=payload)
コード例 #5
0
    def get_bot(self,
                id: str = None,
                fields: list = None,
                payload: dict = None) -> requests.Response:
        ''' Gets a Bot specified by `id`.

            Args:
                id (str): Bot's ID.
                fields (list): Additional Bot fields to include.
                payload (dict): Custom payload to be used as request's data.
                                It overrides all other parameters provided for the method.

            Returns:
                requests.Response: The Response object from `requests` 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_bot', json=payload)
コード例 #6
0
    def list_bots(self,
                  all: bool = None,
                  fields: list = None,
                  payload: dict = None) -> requests.Response:
        ''' Returns the list of Bots created within a license.

            Args:
                all (bool): `True` gets all Bots within a license. `False` (default) returns only the requester's Bots.
                fields (list): Additional Bot fields to include.
                payload (dict): Custom payload to be used as request's data.
                                It overrides all other parameters provided for the method.

            Returns:
                requests.Response: The Response object from `requests` 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}/list_bots', json=payload)
コード例 #7
0
    def list_agents(self,
                    filters: dict = None,
                    fields: list = None,
                    payload: dict = None) -> requests.Response:
        ''' Returns all Agents within a license.

            Args:
                filters (dict): Possible request filters.
                fields (list): Additional fields to include.
                payload (dict): Custom payload to be used as request's data.
                                It overrides all other parameters provided for the method.

            Returns:
                requests.Response: The Response object from `requests` 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}/list_agents', json=payload)
コード例 #8
0
    def create_agent(self,
                     id: str = None,
                     name: str = None,
                     role: str = None,
                     avatar_path: str = None,
                     job_title: str = None,
                     mobile: str = None,
                     max_chats_count: int = None,
                     awaiting_approval: bool = None,
                     groups: list = None,
                     notifications: list = None,
                     email_subscriptions: list = None,
                     work_scheduler: dict = None,
                     payload: dict = None) -> requests.Response:
        ''' Creates a new Agent with specified parameters within a license.

            Args:
                id (str): Agent's ID.
                name (str): Agent's name.
                role (str): Agent role, should be one of the following:
                            `viceowner`, `administrator`, `normal` (default).
                avatar_path (str): URL path of the Agent's avatar.
                job_title (str): Agent's job title.
                mobile (str): Agent's mobile number.
                max_chats_count (int): Agent's maximum number of concurrent chats.
                awaiting_approval (bool): Determines if the Agent will be awaiting
                                          approval after creation.
                groups (list): Groups an Agent belongs to.
                notifications (list): Represents which Agent notifications are turned on.
                email_subscriptions (list): Represents which subscriptions will be send to
                                           the Agent via email.
                work_scheduler (dict): Work scheduler options to set for the new Agent.
                payload (dict): Custom payload to be used as request's data.
                                It overrides all other parameters provided for the method.

            Returns:
                requests.Response: The Response object from `requests` 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}/create_agent', json=payload)
コード例 #9
0
    def unregister_webhook(self,
                           id: str = None,
                           owner_client_id: str = None,
                           payload: dict = None) -> requests.Response:
        ''' Unregisters a webhook previously registered for a Client ID (application).

            Args:
                id (str): Webhook's ID.
                owner_client_id (str): The webhook owner (the Client ID for which the webhook is registered).
                payload (dict): Custom payload to be used as request's data.
                                It overrides all other parameters provided for the method.

            Returns:
                requests.Response: The Response object from `requests` 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}/unregister_webhook',
                                 json=payload)
コード例 #10
0
    def delete_group_properties(self,
                                id: int = None,
                                properties: dict = None,
                                payload: dict = None) -> requests.Response:
        ''' Deletes the properties set within a group.

            Args:
                id (int): ID of the group you delete properties from.
                properties (dict): An object with namespaces as keys and property_names (in an array) as values.
                payload (dict): Custom payload to be used as request's data.
                                It overrides all other parameters provided for the method.

            Returns:
                requests.Response: The Response object from `requests` 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_group_properties',
                                 json=payload)
コード例 #11
0
    def list_license_properties(self,
                                namespace: str = None,
                                name_prefix: str = None,
                                payload: dict = None) -> requests.Response:
        ''' Returns the properties set within a license.

            Args:
                namespace (str): Properties namespace.
                name_prefix (str): Properties name prefix.
                payload (dict): Custom payload to be used as request's data.
                                It overrides all other parameters provided for the method.

            Returns:
                requests.Response: The Response object from `requests` 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}/list_license_properties',
                                 json=payload)
コード例 #12
0
    def unregister_property(self,
                            name: str = None,
                            owner_client_id: str = None,
                            payload: dict = None) -> requests.Response:
        ''' Unregisters a private property.

            Args:
                name (str): Property name.
                owner_client_id (str): Client ID that will own the property; must be owned by your organization.
                payload (dict): Custom payload to be used as request's data.
                                It overrides all other parameters provided for the method.

            Returns:
                requests.Response: The Response object from `requests` 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}/unregister_property',
                                 json=payload)
コード例 #13
0
ファイル: client.py プロジェクト: livechat/lc-sdk-python
    def start_chat(self,
                   chat: dict = None,
                   active: bool = None,
                   continuous: bool = None,
                   payload: dict = None) -> dict:
        ''' Starts a chat.

            Args:
                chat (dict): Chat object.
                active (bool): When set to False, creates an inactive thread; default: True.
                continuous (bool): Starts chat as continuous (online group is not required); default: False.
                payload (dict): Custom payload to be used as request's data.
                        It overrides all other parameters provided for the method.

            Returns:
                dict: Dictionary with response.
        '''
        if payload is None:
            payload = prepare_payload(locals())
        return self.ws.send({'action': 'start_chat', 'payload': payload})
コード例 #14
0
ファイル: client.py プロジェクト: livechat/lc-sdk-python
    def resume_chat(self,
                    chat: dict = None,
                    active: bool = None,
                    continuous: bool = None,
                    payload: dict = None) -> dict:
        ''' Restarts an archived chat.

            Args:
                chat (dict): Chat object.
                active (bool): When set to False, creates an inactive thread; default: True.
                continuous (bool): Sets a chat to the continuous mode. When unset, leaves the mode unchanged.
                payload (dict): Custom payload to be used as request's data.
                        It overrides all other parameters provided for the method.

            Returns:
                dict: Dictionary with response.
        '''
        if payload is None:
            payload = prepare_payload(locals())
        return self.ws.send({'action': 'resume_chat', 'payload': payload})
コード例 #15
0
ファイル: client.py プロジェクト: livechat/lc-sdk-python
    def multicast(self,
                  recipients: dict = None,
                  content: typing.Any = None,
                  type: str = None,
                  payload: dict = None) -> requests.Response:
        ''' Sends a multicast (chat-unrelated communication).

            Args:
                recipients (dict): Object containing filters related to multicast recipients.
                content (typing.Any): A JSON message to be sent.
                type (str): Multicast message type.
                payload (dict): Custom payload to be used as request's data.
                                It overrides all other parameters provided for the method.

            Returns:
                requests.Response: The Response object from `requests` 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}/multicast', json=payload)
コード例 #16
0
ファイル: client.py プロジェクト: livechat/lc-sdk-python
    def revoke_chat_access(self,
                           id: str = None,
                           access: dict = None,
                           payload: dict = None) -> requests.Response:
        ''' Revoke access to a chat.

            Args:
                id (str): chat ID
                access (dict): Dict containing chat access (type and id)
                payload (dict): Custom payload to be used as request's data.
                                It overrides all other parameters provided for the method.

            Returns:
                requests.Response: The Response object from `requests` 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}/revoke_chat_access',
                                 json=payload)
コード例 #17
0
ファイル: client.py プロジェクト: livechat/lc-sdk-python
    def send_event(self,
                   chat_id: str = None,
                   event: dict = None,
                   attach_to_last_thread: bool = None,
                   payload: dict = None) -> dict:
        ''' Sends an Event object.

            Args:
                chat_id (str): ID of the chat you want to send the message to.
                event (dict): Event object.
                attach_to_last_thread (bool): Flag which states if event object should be added to last thread.
                payload (dict): Custom payload to be used as request's data.
                        It overrides all other parameters provided for the method.

            Returns:
                dict: Dictionary with response.
        '''
        if payload is None:
            payload = prepare_payload(locals())
        return self.ws.send({'action': 'send_event', 'payload': payload})
コード例 #18
0
ファイル: client.py プロジェクト: livechat/lc-sdk-python
    def multicast(self,
                  recipients: dict = None,
                  content: typing.Any = None,
                  type: str = None,
                  payload: dict = None) -> dict:
        ''' Sends a multicast (chat-unrelated communication).

            Args:
                recipients (object): Object containing filters related to multicast recipients.
                content (typing.Any): A JSON message to be sent.
                type (str): Multicast message type.
                payload (dict): Custom payload to be used as request's data.
                        It overrides all other parameters provided for the method.

            Returns:
                dict: Dictionary with response.
        '''
        if payload is None:
            payload = prepare_payload(locals())
        return self.ws.send({'action': 'multicast', 'payload': payload})
コード例 #19
0
ファイル: client.py プロジェクト: livechat/lc-sdk-python
    def untag_thread(self,
                     chat_id: str = None,
                     thread_id: str = None,
                     tag: str = None,
                     payload: dict = None) -> dict:
        ''' Untags thread.

            Args:
                chat_id (str): ID of the chat you want to remove a tag from.
                thread_id (str): ID of the thread you want to remove a tag from.
                tag (str): Tag name.
                payload (dict): Custom payload to be used as request's data.
                        It overrides all other parameters provided for the method.

            Returns:
                dict: Dictionary with response.
        '''
        if payload is None:
            payload = prepare_payload(locals())
        return self.ws.send({'action': 'untag_thread', 'payload': payload})
コード例 #20
0
ファイル: client.py プロジェクト: livechat/lc-sdk-python
    def send_typing_indicator(self,
                              chat_id: str = None,
                              recipients: str = None,
                              is_typing: bool = None,
                              payload: dict = None) -> requests.Response:
        ''' Sends typing indicator.

            Args:
                chat_id (str): Id of the chat that to send the typing indicator to.
                recipients (str): Default: all; agents.
                is_typing (bool): A flag that indicates if you are typing.
                payload (dict): Custom payload to be used as request's data.
                                It overrides all other parameters provided for the method.

            Returns:
                requests.Response: The Response object from `requests` 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}/send_typing_indicator',
                                 json=payload)
コード例 #21
0
ファイル: client.py プロジェクト: livechat/lc-sdk-python
    def set_routing_status(self,
                           status: str = None,
                           agent_id: str = None,
                           payload: dict = None) -> requests.Response:
        ''' Changes the status of an Agent or a Bot Agent.

            Args:
                status (str): For Agents: accepting_chats or not_accepting_chats;
                              for Bot Agents: accepting_chats, not_accepting_chats, or offline
                agent_id (str): If not specified, the requester's status will be updated.
                payload (dict): Custom payload to be used as request's data.
                                It overrides all other parameters provided for the method.

            Returns:
                requests.Response: The Response object from `requests` 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}/set_routing_status',
                                 json=payload)
コード例 #22
0
ファイル: client.py プロジェクト: livechat/lc-sdk-python
    def unfollow_customer(self,
                          id: str = None,
                          payload: dict = None) -> requests.Response:
        ''' Removes the agent from the list of customer's followers. Calling this
            method on a customer the agent's chatting with will result in success,
            however, the agent will still receive pushes about the customer's data
            updates. The unfollowing will take effect once the chat ends.

            Args:
                id (str): ID of the Customer.
                payload (dict): Custom payload to be used as request's data.
                                It overrides all other parameters provided for the method.

            Returns:
                requests.Response: The Response object from `requests` 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}/unfollow_customer',
                                 json=payload)
コード例 #23
0
ファイル: client.py プロジェクト: livechat/lc-sdk-python
    def follow_customer(self,
                        id: str = None,
                        payload: dict = None) -> requests.Response:
        ''' Marks a customer as followed. As a result, the requester (an agent)
            will receive the info about all the changes related to that customer
            via pushes. Once the customer leaves the website or is unfollowed,
            the agent will no longer receive that information.

            Args:
                id (str): ID of the Customer.
                payload (dict): Custom payload to be used as request's data.
                                It overrides all other parameters provided for the method.

            Returns:
                requests.Response: The Response object from `requests` 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}/follow_customer',
                                 json=payload)
コード例 #24
0
ファイル: client.py プロジェクト: livechat/lc-sdk-python
    def untag_thread(self,
                     chat_id: str = None,
                     thread_id: str = None,
                     tag: str = None,
                     payload: dict = None) -> requests.Response:
        ''' Untags thread.

            Args:
                chat_id (str): ID of the chat you want to remove a tag from.
                thread_id (str): ID of the thread you want to remove a tag from.
                tag (str): Tag name.
                payload (dict): Custom payload to be used as request's data.
                                It overrides all other parameters provided for the method.

            Returns:
                requests.Response: The Response object from `requests` 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}/untag_thread', json=payload)
コード例 #25
0
ファイル: client.py プロジェクト: livechat/lc-sdk-python
    def delete_thread_properties(self,
                                 chat_id: str = None,
                                 thread_id: str = None,
                                 properties: dict = None,
                                 payload: dict = None) -> requests.Response:
        ''' Deletes chat thread properties.

            Args:
                chat_id (str): ID of the chat you want to delete the properties of.
                thread_id (str): ID of the thread you want to delete the properties of.
                properties (dict): Thread properties to delete.
                payload (dict): Custom payload to be used as request's data.
                                It overrides all other parameters provided for the method.

            Returns:
                requests.Response: The Response object from `requests` 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_thread_properties',
                                 json=payload)
コード例 #26
0
ファイル: client.py プロジェクト: livechat/lc-sdk-python
    def resume_chat(self,
                    chat: dict = None,
                    active: bool = None,
                    continuous: bool = None,
                    payload: dict = None) -> requests.Response:
        ''' Restarts an archived chat.

            Args:
                chat (dict): Dict containing chat properties, access and thread.
                active (bool): When set to False, creates an inactive thread; default: True.
                continuous (bool): Starts chat as continuous (online group is not required); default: False.
                payload (dict): Custom payload to be used as request's data.
                                It overrides all other parameters provided for the method.

            Returns:
                requests.Response: The Response object from `requests` 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}/resume_chat', json=payload)
コード例 #27
0
ファイル: client.py プロジェクト: livechat/lc-sdk-python
    def mark_events_as_seen(self,
                            chat_id: str = None,
                            seen_up_to: str = None,
                            payload: dict = None) -> dict:
        ''' Marks events as seen by agent.

            Args:
                chat_id (str): Chat to mark events.
                seen_up_to (str): Date up to which mark events - RFC 3339 date-time format.
                payload (dict): Custom payload to be used as request's data.
                        It overrides all other parameters provided for the method.

            Returns:
                dict: Dictionary with response.
        '''
        if payload is None:
            payload = prepare_payload(locals())
        return self.ws.send({
            'action': 'mark_events_as_seen',
            'payload': payload
        })
コード例 #28
0
ファイル: client.py プロジェクト: livechat/lc-sdk-python
    def delete_chat_properties(self,
                               id: str = None,
                               properties: dict = None,
                               payload: dict = None) -> dict:
        ''' Deletes chat properties.

            Args:
                id (str): ID of the chat you want to delete properties of.
                properties (dict): Chat properties to delete.
                payload (dict): Custom payload to be used as request's data.
                        It overrides all other parameters provided for the method.

            Returns:
                dict: Dictionary with response.
        '''
        if payload is None:
            payload = prepare_payload(locals())
        return self.ws.send({
            'action': 'delete_chat_properties',
            'payload': payload
        })
コード例 #29
0
ファイル: client.py プロジェクト: livechat/lc-sdk-python
    def revoke_chat_access(self,
                           id: str = None,
                           access: dict = None,
                           payload: dict = None) -> dict:
        ''' Revokes access to a chat.

            Args:
                id (str): Chat ID.
                access (dict): Access object.
                payload (dict): Custom payload to be used as request's data.
                        It overrides all other parameters provided for the method.

            Returns:
                dict: Dictionary with response.
        '''
        if payload is None:
            payload = prepare_payload(locals())
        return self.ws.send({
            'action': 'revoke_chat_access',
            'payload': payload
        })
コード例 #30
0
    def create_group(self,
                     name: str = None,
                     language_code: str = None,
                     agent_priorities: dict = None,
                     payload: dict = None) -> requests.Response:
        ''' Creates a new group.

            Args:
                name (str): Group name (up to 180 chars).
                language_code (str): The code of the group languange.
                agent_priorities (dict): Agents' priorities in a group as a map in the "<id>": "<priority>" format.
                payload (dict): Custom payload to be used as request's data.
                                It overrides all other parameters provided for the method.

            Returns:
                requests.Response: The Response object from `requests` 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}/create_group', json=payload)