# coding: utf-8

"""
    Allegro REST API

    https://developer.allegro.pl/about  # noqa: E501

    OpenAPI spec version: latest
    Generated by: https://openapi-generator.tech
"""


from __future__ import absolute_import

import re  # noqa: F401

# python 2 and python 3 compatibility library
import six

from allegro_api.api_client import ApiClient


class DisputesApi(object):
    """NOTE: This class is auto generated by OpenAPI Generator
    Ref: https://openapi-generator.tech

    Do not edit the class manually.
    """

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

    def add_message_to_dispute_using_post(self, dispute_id, message_request, **kwargs):  # noqa: E501
        """Add a message to a dispute  # noqa: E501

        Use this resource to post a message in certain dispute. At least one of fields: 'text', 'attachment' has to be present. More information about this resource you can find <a href=\"../../news/2018-09-18-dyskusje/#PostMessage\" target=\"_blank\">here</a>.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.add_message_to_dispute_using_post(dispute_id, message_request, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str dispute_id: Id of the dispute (required)
        :param MessageRequest message_request: Message request (required)
        :return: DisputeMessage
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.add_message_to_dispute_using_post_with_http_info(dispute_id, message_request, **kwargs)  # noqa: E501
        else:
            (data) = self.add_message_to_dispute_using_post_with_http_info(dispute_id, message_request, **kwargs)  # noqa: E501
            return data

    def add_message_to_dispute_using_post_with_http_info(self, dispute_id, message_request, **kwargs):  # noqa: E501
        """Add a message to a dispute  # noqa: E501

        Use this resource to post a message in certain dispute. At least one of fields: 'text', 'attachment' has to be present. More information about this resource you can find <a href=\"../../news/2018-09-18-dyskusje/#PostMessage\" target=\"_blank\">here</a>.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.add_message_to_dispute_using_post_with_http_info(dispute_id, message_request, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str dispute_id: Id of the dispute (required)
        :param MessageRequest message_request: Message request (required)
        :return: DisputeMessage
                 If the method is called asynchronously,
                 returns the request thread.
        """

        local_var_params = locals()

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

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

        collection_formats = {}

        path_params = {}
        if 'dispute_id' in local_var_params:
            path_params['disputeId'] = local_var_params['dispute_id']  # noqa: E501

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        if 'message_request' in local_var_params:
            body_params = local_var_params['message_request']
        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.select_header_accept(
            ['application/vnd.allegro.public.v1+json'])  # noqa: E501

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

        # Authentication setting
        auth_settings = ['bearer-token-for-user']  # noqa: E501

        return self.api_client.call_api(
            '/sale/disputes/{disputeId}/messages', 'POST',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='DisputeMessage',  # noqa: E501
            auth_settings=auth_settings,
            async_req=local_var_params.get('async_req'),
            _return_http_data_only=local_var_params.get('_return_http_data_only'),  # noqa: E501
            _preload_content=local_var_params.get('_preload_content', True),
            _request_timeout=local_var_params.get('_request_timeout'),
            collection_formats=collection_formats)

    def create_an_attachment_using_post(self, attachment_declaration, **kwargs):  # noqa: E501
        """Create an attachment declaration  # noqa: E501

        Use this resource to post an attachment declaration. More information about this resource you can find <a href=\"../../news/2018-09-18-dyskusje/#PostAttach\" target=\"_blank\">here</a>.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.create_an_attachment_using_post(attachment_declaration, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param AttachmentDeclaration attachment_declaration: A detailed declaration of a file to be uploaded (required)
        :return: DisputeAttachmentId
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.create_an_attachment_using_post_with_http_info(attachment_declaration, **kwargs)  # noqa: E501
        else:
            (data) = self.create_an_attachment_using_post_with_http_info(attachment_declaration, **kwargs)  # noqa: E501
            return data

    def create_an_attachment_using_post_with_http_info(self, attachment_declaration, **kwargs):  # noqa: E501
        """Create an attachment declaration  # noqa: E501

        Use this resource to post an attachment declaration. More information about this resource you can find <a href=\"../../news/2018-09-18-dyskusje/#PostAttach\" target=\"_blank\">here</a>.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.create_an_attachment_using_post_with_http_info(attachment_declaration, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param AttachmentDeclaration attachment_declaration: A detailed declaration of a file to be uploaded (required)
        :return: DisputeAttachmentId
                 If the method is called asynchronously,
                 returns the request thread.
        """

        local_var_params = locals()

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

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

        collection_formats = {}

        path_params = {}

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        if 'attachment_declaration' in local_var_params:
            body_params = local_var_params['attachment_declaration']
        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.select_header_accept(
            ['application/vnd.allegro.public.v1+json'])  # noqa: E501

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

        # Authentication setting
        auth_settings = ['bearer-token-for-user']  # noqa: E501

        return self.api_client.call_api(
            '/sale/dispute-attachments', 'POST',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='DisputeAttachmentId',  # noqa: E501
            auth_settings=auth_settings,
            async_req=local_var_params.get('async_req'),
            _return_http_data_only=local_var_params.get('_return_http_data_only'),  # noqa: E501
            _preload_content=local_var_params.get('_preload_content', True),
            _request_timeout=local_var_params.get('_request_timeout'),
            collection_formats=collection_formats)

    def get_attachment_using_get(self, attachment_id, **kwargs):  # noqa: E501
        """Get an attachment  # noqa: E501

        Use this resource to get an attachment. More information about this resource you can find <a href=\"../../news/2018-09-18-dyskusje/#GetAttach\" target=\"_blank\">here</a>.  # 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_attachment_using_get(attachment_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str attachment_id: Id of the attachment resource (required)
        :return: file
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.get_attachment_using_get_with_http_info(attachment_id, **kwargs)  # noqa: E501
        else:
            (data) = self.get_attachment_using_get_with_http_info(attachment_id, **kwargs)  # noqa: E501
            return data

    def get_attachment_using_get_with_http_info(self, attachment_id, **kwargs):  # noqa: E501
        """Get an attachment  # noqa: E501

        Use this resource to get an attachment. More information about this resource you can find <a href=\"../../news/2018-09-18-dyskusje/#GetAttach\" target=\"_blank\">here</a>.  # 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_attachment_using_get_with_http_info(attachment_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str attachment_id: Id of the attachment resource (required)
        :return: file
                 If the method is called asynchronously,
                 returns the request thread.
        """

        local_var_params = locals()

        all_params = ['attachment_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')

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

        collection_formats = {}

        path_params = {}
        if 'attachment_id' in local_var_params:
            path_params['attachmentId'] = local_var_params['attachment_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(
            ['*/*'])  # noqa: E501

        # Authentication setting
        auth_settings = ['bearer-token-for-user']  # noqa: E501

        return self.api_client.call_api(
            '/sale/dispute-attachments/{attachmentId}', 'GET',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='file',  # noqa: E501
            auth_settings=auth_settings,
            async_req=local_var_params.get('async_req'),
            _return_http_data_only=local_var_params.get('_return_http_data_only'),  # noqa: E501
            _preload_content=local_var_params.get('_preload_content', True),
            _request_timeout=local_var_params.get('_request_timeout'),
            collection_formats=collection_formats)

    def get_dispute_using_get(self, dispute_id, **kwargs):  # noqa: E501
        """Get a single dispute  # noqa: E501

        Use this resource to get a single dispute. More information about this resource you can find <a href=\"../../news/2018-09-18-dyskusje/#GetOne\" target=\"_blank\">here</a>.  # 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_dispute_using_get(dispute_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str dispute_id: Id of the dispute (required)
        :return: Dispute
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.get_dispute_using_get_with_http_info(dispute_id, **kwargs)  # noqa: E501
        else:
            (data) = self.get_dispute_using_get_with_http_info(dispute_id, **kwargs)  # noqa: E501
            return data

    def get_dispute_using_get_with_http_info(self, dispute_id, **kwargs):  # noqa: E501
        """Get a single dispute  # noqa: E501

        Use this resource to get a single dispute. More information about this resource you can find <a href=\"../../news/2018-09-18-dyskusje/#GetOne\" target=\"_blank\">here</a>.  # 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_dispute_using_get_with_http_info(dispute_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str dispute_id: Id of the dispute (required)
        :return: Dispute
                 If the method is called asynchronously,
                 returns the request thread.
        """

        local_var_params = locals()

        all_params = ['dispute_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')

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

        collection_formats = {}

        path_params = {}
        if 'dispute_id' in local_var_params:
            path_params['disputeId'] = local_var_params['dispute_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/vnd.allegro.public.v1+json'])  # noqa: E501

        # Authentication setting
        auth_settings = ['bearer-token-for-user']  # noqa: E501

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

    def get_list_of_disputes_using_get(self, **kwargs):  # noqa: E501
        """Get the user's disputes  # noqa: E501

        Use this resource to get the list of your disputes. More information about this resource you can find <a href=\"../../news/2018-09-18-dyskusje/#GetAll\" target=\"_blank\">here</a>.  # 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_list_of_disputes_using_get(async_req=True)
        >>> result = thread.get()

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

    def get_list_of_disputes_using_get_with_http_info(self, **kwargs):  # noqa: E501
        """Get the user's disputes  # noqa: E501

        Use this resource to get the list of your disputes. More information about this resource you can find <a href=\"../../news/2018-09-18-dyskusje/#GetAll\" target=\"_blank\">here</a>.  # 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_list_of_disputes_using_get_with_http_info(async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str checkout_form_id: CheckoutForm id
        :return: DisputeListResponse
                 If the method is called asynchronously,
                 returns the request thread.
        """

        local_var_params = locals()

        all_params = ['checkout_form_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')

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

        collection_formats = {}

        path_params = {}

        query_params = []
        if 'checkout_form_id' in local_var_params:
            query_params.append(('checkoutForm.id', local_var_params['checkout_form_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/vnd.allegro.public.v1+json'])  # noqa: E501

        # Authentication setting
        auth_settings = ['bearer-token-for-user']  # noqa: E501

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

    def get_messages_from_dispute_using_get(self, dispute_id, **kwargs):  # noqa: E501
        """Get the messages within a dispute  # noqa: E501

        Use this resource to get the list of messages within dispute. More information about this resource you can find <a href=\"../../news/2018-09-18-dyskusje/#GetMessage\" target=\"_blank\">here</a>.  # 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_messages_from_dispute_using_get(dispute_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str dispute_id: Id of the dispute (required)
        :return: DisputeMessageList
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.get_messages_from_dispute_using_get_with_http_info(dispute_id, **kwargs)  # noqa: E501
        else:
            (data) = self.get_messages_from_dispute_using_get_with_http_info(dispute_id, **kwargs)  # noqa: E501
            return data

    def get_messages_from_dispute_using_get_with_http_info(self, dispute_id, **kwargs):  # noqa: E501
        """Get the messages within a dispute  # noqa: E501

        Use this resource to get the list of messages within dispute. More information about this resource you can find <a href=\"../../news/2018-09-18-dyskusje/#GetMessage\" target=\"_blank\">here</a>.  # 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_messages_from_dispute_using_get_with_http_info(dispute_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str dispute_id: Id of the dispute (required)
        :return: DisputeMessageList
                 If the method is called asynchronously,
                 returns the request thread.
        """

        local_var_params = locals()

        all_params = ['dispute_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')

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

        collection_formats = {}

        path_params = {}
        if 'dispute_id' in local_var_params:
            path_params['disputeId'] = local_var_params['dispute_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/vnd.allegro.public.v1+json'])  # noqa: E501

        # Authentication setting
        auth_settings = ['bearer-token-for-user']  # noqa: E501

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