# coding: utf-8

"""
    Prompt.io APIs

    No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)  # noqa: E501

    OpenAPI spec version: 1.0
    
    Generated by: https://github.com/swagger-api/swagger-codegen.git
"""

from __future__ import absolute_import

import re  # noqa: F401

# python 2 and python 3 compatibility library
import six

from swagger_client.api_client import ApiClient


class MessagesApi(object):
    """NOTE: This class is auto generated by the swagger code generator program.

    Do not edit the class manually.
    Ref: https://github.com/swagger-api/swagger-codegen
    """

    def __init__(self, api_client=None):
        if api_client is None:
            api_client = ApiClient()
        self.api_client = api_client

    def get_message(self, message_id, **kwargs):  # noqa: E501
        """Gets a single specific message by its internal id  # noqa: E501

        _in snippets: platform.api.messages.getMessage_  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.get_message(message_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param int message_id: (required)
        :return: MessageModel
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.get_message_with_http_info(message_id, **kwargs)  # noqa: E501
        else:
            (data) = self.get_message_with_http_info(message_id, **kwargs)  # noqa: E501
            return data

    def get_message_with_http_info(self, message_id, **kwargs):  # noqa: E501
        """Gets a single specific message by its internal id  # noqa: E501

        _in snippets: platform.api.messages.getMessage_  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.get_message_with_http_info(message_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param int message_id: (required)
        :return: MessageModel
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['message_id']  # noqa: E501
        all_params.append('async_req')
        all_params.append('_return_http_data_only')
        all_params.append('_preload_content')
        all_params.append('_request_timeout')

        params = locals()
        for key, val in six.iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method get_message" % key
                )
            params[key] = val
        del params['kwargs']
        # verify the required parameter 'message_id' is set
        if ('message_id' not in params or
                params['message_id'] is None):
            raise ValueError("Missing the required parameter `message_id` when calling `get_message`")  # noqa: E501

        collection_formats = {}

        path_params = {}
        if 'message_id' in params:
            path_params['messageId'] = params['message_id']  # noqa: E501

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.select_header_accept(
            ['application/json'])  # noqa: E501

        # Authentication setting
        auth_settings = ['org_token']  # noqa: E501

        return self.api_client.call_api(
            '/messages/{messageId}', 'GET',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='MessageModel',  # noqa: E501
            auth_settings=auth_settings,
            async_req=params.get('async_req'),
            _return_http_data_only=params.get('_return_http_data_only'),
            _preload_content=params.get('_preload_content', True),
            _request_timeout=params.get('_request_timeout'),
            collection_formats=collection_formats)

    def get_message_by_external_id(self, **kwargs):  # noqa: E501
        """Gets a single specific message by its external id  # noqa: E501

        _in snippets: platform.api.messages.getMessageByExternalId_  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.get_message_by_external_id(async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str by_channel_type:
        :param str by_external_message_id:
        :return: MessageModel
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.get_message_by_external_id_with_http_info(**kwargs)  # noqa: E501
        else:
            (data) = self.get_message_by_external_id_with_http_info(**kwargs)  # noqa: E501
            return data

    def get_message_by_external_id_with_http_info(self, **kwargs):  # noqa: E501
        """Gets a single specific message by its external id  # noqa: E501

        _in snippets: platform.api.messages.getMessageByExternalId_  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.get_message_by_external_id_with_http_info(async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str by_channel_type:
        :param str by_external_message_id:
        :return: MessageModel
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['by_channel_type', 'by_external_message_id']  # noqa: E501
        all_params.append('async_req')
        all_params.append('_return_http_data_only')
        all_params.append('_preload_content')
        all_params.append('_request_timeout')

        params = locals()
        for key, val in six.iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method get_message_by_external_id" % key
                )
            params[key] = val
        del params['kwargs']

        collection_formats = {}

        path_params = {}

        query_params = []
        if 'by_channel_type' in params:
            query_params.append(('by_channel_type', params['by_channel_type']))  # noqa: E501
        if 'by_external_message_id' in params:
            query_params.append(('by_external_message_id', params['by_external_message_id']))  # noqa: E501

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.select_header_accept(
            ['application/json'])  # noqa: E501

        # Authentication setting
        auth_settings = ['org_token']  # noqa: E501

        return self.api_client.call_api(
            '/messages', 'GET',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='MessageModel',  # noqa: E501
            auth_settings=auth_settings,
            async_req=params.get('async_req'),
            _return_http_data_only=params.get('_return_http_data_only'),
            _preload_content=params.get('_preload_content', True),
            _request_timeout=params.get('_request_timeout'),
            collection_formats=collection_formats)

    def get_message_history(self, start_timestamp, **kwargs):  # noqa: E501
        """Gets historial messages in bulk  # noqa: E501

        _in snippets: platform.api.messages.getMessageHistory_  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.get_message_history(start_timestamp, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param int start_timestamp: (required)
        :param int end_timestamp:
        :param int first:
        :param int max:
        :return: HistoricalMessageModelPage
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.get_message_history_with_http_info(start_timestamp, **kwargs)  # noqa: E501
        else:
            (data) = self.get_message_history_with_http_info(start_timestamp, **kwargs)  # noqa: E501
            return data

    def get_message_history_with_http_info(self, start_timestamp, **kwargs):  # noqa: E501
        """Gets historial messages in bulk  # noqa: E501

        _in snippets: platform.api.messages.getMessageHistory_  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.get_message_history_with_http_info(start_timestamp, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param int start_timestamp: (required)
        :param int end_timestamp:
        :param int first:
        :param int max:
        :return: HistoricalMessageModelPage
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['start_timestamp', 'end_timestamp', 'first', 'max']  # noqa: E501
        all_params.append('async_req')
        all_params.append('_return_http_data_only')
        all_params.append('_preload_content')
        all_params.append('_request_timeout')

        params = locals()
        for key, val in six.iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method get_message_history" % key
                )
            params[key] = val
        del params['kwargs']
        # verify the required parameter 'start_timestamp' is set
        if ('start_timestamp' not in params or
                params['start_timestamp'] is None):
            raise ValueError("Missing the required parameter `start_timestamp` when calling `get_message_history`")  # noqa: E501

        collection_formats = {}

        path_params = {}

        query_params = []
        if 'start_timestamp' in params:
            query_params.append(('startTimestamp', params['start_timestamp']))  # noqa: E501
        if 'end_timestamp' in params:
            query_params.append(('endTimestamp', params['end_timestamp']))  # noqa: E501
        if 'first' in params:
            query_params.append(('first', params['first']))  # noqa: E501
        if 'max' in params:
            query_params.append(('max', params['max']))  # noqa: E501

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.select_header_accept(
            ['application/json'])  # noqa: E501

        # Authentication setting
        auth_settings = ['org_token']  # noqa: E501

        return self.api_client.call_api(
            '/messages/history', 'GET',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='HistoricalMessageModelPage',  # noqa: E501
            auth_settings=auth_settings,
            async_req=params.get('async_req'),
            _return_http_data_only=params.get('_return_http_data_only'),
            _preload_content=params.get('_preload_content', True),
            _request_timeout=params.get('_request_timeout'),
            collection_formats=collection_formats)

    def send_file_to_customer(self, org_channel_id, customer_channel_key, customer_channel_id, message, ignore_delivery_restrictions, file, **kwargs):  # noqa: E501
        """Sends a file and an optional message to a customer, creating the customer, customer channel and conversation if needed.  # noqa: E501

        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.send_file_to_customer(org_channel_id, customer_channel_key, customer_channel_id, message, ignore_delivery_restrictions, file, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str org_channel_id: (required)
        :param str customer_channel_key: (required)
        :param int customer_channel_id: (required)
        :param str message: (required)
        :param bool ignore_delivery_restrictions: (required)
        :param str file: (required)
        :return: CustomerMessageModel
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.send_file_to_customer_with_http_info(org_channel_id, customer_channel_key, customer_channel_id, message, ignore_delivery_restrictions, file, **kwargs)  # noqa: E501
        else:
            (data) = self.send_file_to_customer_with_http_info(org_channel_id, customer_channel_key, customer_channel_id, message, ignore_delivery_restrictions, file, **kwargs)  # noqa: E501
            return data

    def send_file_to_customer_with_http_info(self, org_channel_id, customer_channel_key, customer_channel_id, message, ignore_delivery_restrictions, file, **kwargs):  # noqa: E501
        """Sends a file and an optional message to a customer, creating the customer, customer channel and conversation if needed.  # noqa: E501

        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.send_file_to_customer_with_http_info(org_channel_id, customer_channel_key, customer_channel_id, message, ignore_delivery_restrictions, file, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str org_channel_id: (required)
        :param str customer_channel_key: (required)
        :param int customer_channel_id: (required)
        :param str message: (required)
        :param bool ignore_delivery_restrictions: (required)
        :param str file: (required)
        :return: CustomerMessageModel
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['org_channel_id', 'customer_channel_key', 'customer_channel_id', 'message', 'ignore_delivery_restrictions', 'file']  # noqa: E501
        all_params.append('async_req')
        all_params.append('_return_http_data_only')
        all_params.append('_preload_content')
        all_params.append('_request_timeout')

        params = locals()
        for key, val in six.iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method send_file_to_customer" % key
                )
            params[key] = val
        del params['kwargs']
        # verify the required parameter 'org_channel_id' is set
        if ('org_channel_id' not in params or
                params['org_channel_id'] is None):
            raise ValueError("Missing the required parameter `org_channel_id` when calling `send_file_to_customer`")  # noqa: E501
        # verify the required parameter 'customer_channel_key' is set
        if ('customer_channel_key' not in params or
                params['customer_channel_key'] is None):
            raise ValueError("Missing the required parameter `customer_channel_key` when calling `send_file_to_customer`")  # noqa: E501
        # verify the required parameter 'customer_channel_id' is set
        if ('customer_channel_id' not in params or
                params['customer_channel_id'] is None):
            raise ValueError("Missing the required parameter `customer_channel_id` when calling `send_file_to_customer`")  # noqa: E501
        # verify the required parameter 'message' is set
        if ('message' not in params or
                params['message'] is None):
            raise ValueError("Missing the required parameter `message` when calling `send_file_to_customer`")  # noqa: E501
        # verify the required parameter 'ignore_delivery_restrictions' is set
        if ('ignore_delivery_restrictions' not in params or
                params['ignore_delivery_restrictions'] is None):
            raise ValueError("Missing the required parameter `ignore_delivery_restrictions` when calling `send_file_to_customer`")  # noqa: E501
        # verify the required parameter 'file' is set
        if ('file' not in params or
                params['file'] is None):
            raise ValueError("Missing the required parameter `file` when calling `send_file_to_customer`")  # noqa: E501

        collection_formats = {}

        path_params = {}

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}
        if 'org_channel_id' in params:
            form_params.append(('orgChannelId', params['org_channel_id']))  # noqa: E501
        if 'customer_channel_key' in params:
            form_params.append(('customerChannelKey', params['customer_channel_key']))  # noqa: E501
        if 'customer_channel_id' in params:
            form_params.append(('customerChannelId', params['customer_channel_id']))  # noqa: E501
        if 'message' in params:
            form_params.append(('message', params['message']))  # noqa: E501
        if 'ignore_delivery_restrictions' in params:
            form_params.append(('ignoreDeliveryRestrictions', params['ignore_delivery_restrictions']))  # noqa: E501
        if 'file' in params:
            local_var_files['file'] = params['file']  # noqa: E501

        body_params = None
        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.select_header_accept(
            ['application/json'])  # noqa: E501

        # HTTP header `Content-Type`
        header_params['Content-Type'] = self.api_client.select_header_content_type(  # noqa: E501
            ['multipart/form-data'])  # noqa: E501

        # Authentication setting
        auth_settings = ['org_token']  # noqa: E501

        return self.api_client.call_api(
            '/messages/send_file_to_customer', 'POST',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='CustomerMessageModel',  # noqa: E501
            auth_settings=auth_settings,
            async_req=params.get('async_req'),
            _return_http_data_only=params.get('_return_http_data_only'),
            _preload_content=params.get('_preload_content', True),
            _request_timeout=params.get('_request_timeout'),
            collection_formats=collection_formats)

    def send_to_customer(self, **kwargs):  # noqa: E501
        """Sends a message and an optional instant app to a customer using API Ids, creating the customer, customer channel and conversation if needed.  # noqa: E501

        _in snippets: platform.api.messages.sendToCustomer_  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.send_to_customer(async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param SendToCustomerMessageModel body:
        :return: CustomerMessageModel
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.send_to_customer_with_http_info(**kwargs)  # noqa: E501
        else:
            (data) = self.send_to_customer_with_http_info(**kwargs)  # noqa: E501
            return data

    def send_to_customer_with_http_info(self, **kwargs):  # noqa: E501
        """Sends a message and an optional instant app to a customer using API Ids, creating the customer, customer channel and conversation if needed.  # noqa: E501

        _in snippets: platform.api.messages.sendToCustomer_  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.send_to_customer_with_http_info(async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param SendToCustomerMessageModel body:
        :return: CustomerMessageModel
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['body']  # noqa: E501
        all_params.append('async_req')
        all_params.append('_return_http_data_only')
        all_params.append('_preload_content')
        all_params.append('_request_timeout')

        params = locals()
        for key, val in six.iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method send_to_customer" % key
                )
            params[key] = val
        del params['kwargs']

        collection_formats = {}

        path_params = {}

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        if 'body' in params:
            body_params = params['body']
        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.select_header_accept(
            ['application/json'])  # noqa: E501

        # HTTP header `Content-Type`
        header_params['Content-Type'] = self.api_client.select_header_content_type(  # noqa: E501
            ['application/json'])  # noqa: E501

        # Authentication setting
        auth_settings = ['org_token']  # noqa: E501

        return self.api_client.call_api(
            '/messages/send_to_customer', 'POST',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='CustomerMessageModel',  # noqa: E501
            auth_settings=auth_settings,
            async_req=params.get('async_req'),
            _return_http_data_only=params.get('_return_http_data_only'),
            _preload_content=params.get('_preload_content', True),
            _request_timeout=params.get('_request_timeout'),
            collection_formats=collection_formats)
