# 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 UsersOfferInformationApi(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 get_offer_using_get(self, offer_id, **kwargs):  # noqa: E501
        """Get all fields of the particular offer  # noqa: E501

        Use this resource to retrieve all fields of the particular offer. More information about this resource you can find <a href=\"../../sale/#similar-offer\" 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_offer_using_get(offer_id, async_req=True)
        >>> result = thread.get()

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

    def get_offer_using_get_with_http_info(self, offer_id, **kwargs):  # noqa: E501
        """Get all fields of the particular offer  # noqa: E501

        Use this resource to retrieve all fields of the particular offer. More information about this resource you can find <a href=\"../../sale/#similar-offer\" 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_offer_using_get_with_http_info(offer_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str offer_id: offerId (required)
        :return: Offer
                 If the method is called asynchronously,
                 returns the request thread.
        """

        local_var_params = locals()

        all_params = ['offer_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_offer_using_get" % key
                )
            local_var_params[key] = val
        del local_var_params['kwargs']
        # verify the required parameter 'offer_id' is set
        if ('offer_id' not in local_var_params or
                local_var_params['offer_id'] is None):
            raise ValueError("Missing the required parameter `offer_id` when calling `get_offer_using_get`")  # noqa: E501

        collection_formats = {}

        path_params = {}
        if 'offer_id' in local_var_params:
            path_params['offerId'] = local_var_params['offer_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/offers/{offerId}', 'GET',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='Offer',  # 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 search_offers_using_get(self, seller_id, **kwargs):  # noqa: E501
        """Get seller's offers  # noqa: E501

        Search seller's offers by given criteria. Accept header should be set to application/vnd.allegro.beta.v1+json  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.search_offers_using_get(seller_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str seller_id: Seller id (required)
        :param str name: Text to search in offer title
        :param float selling_mode_price_amount_gte: Minimal threshold of price
        :param float selling_mode_price_amount_lte: Maximal threshold of price
        :param str publication_status: Publication statuses may contain more than one comma separated value
        :param str selling_mode_format: Selling mode may contain more than one comma separated value
        :param str external_id: ID from external client system
        :param str sort: Sort direction
        :param int limit: Maximum number of seller's offers in response (acceptable values: from 1 to 1000, default is 20).
        :param int offset: Index of first returned seller's offers from all search results.
        :return: OffersSearchResultDtoV1
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.search_offers_using_get_with_http_info(seller_id, **kwargs)  # noqa: E501
        else:
            (data) = self.search_offers_using_get_with_http_info(seller_id, **kwargs)  # noqa: E501
            return data

    def search_offers_using_get_with_http_info(self, seller_id, **kwargs):  # noqa: E501
        """Get seller's offers  # noqa: E501

        Search seller's offers by given criteria. Accept header should be set to application/vnd.allegro.beta.v1+json  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.search_offers_using_get_with_http_info(seller_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str seller_id: Seller id (required)
        :param str name: Text to search in offer title
        :param float selling_mode_price_amount_gte: Minimal threshold of price
        :param float selling_mode_price_amount_lte: Maximal threshold of price
        :param str publication_status: Publication statuses may contain more than one comma separated value
        :param str selling_mode_format: Selling mode may contain more than one comma separated value
        :param str external_id: ID from external client system
        :param str sort: Sort direction
        :param int limit: Maximum number of seller's offers in response (acceptable values: from 1 to 1000, default is 20).
        :param int offset: Index of first returned seller's offers from all search results.
        :return: OffersSearchResultDtoV1
                 If the method is called asynchronously,
                 returns the request thread.
        """

        local_var_params = locals()

        all_params = ['seller_id', 'name', 'selling_mode_price_amount_gte', 'selling_mode_price_amount_lte', 'publication_status', 'selling_mode_format', 'external_id', 'sort', 'limit', 'offset']  # 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 search_offers_using_get" % key
                )
            local_var_params[key] = val
        del local_var_params['kwargs']
        # verify the required parameter 'seller_id' is set
        if ('seller_id' not in local_var_params or
                local_var_params['seller_id'] is None):
            raise ValueError("Missing the required parameter `seller_id` when calling `search_offers_using_get`")  # noqa: E501

        if 'limit' in local_var_params and local_var_params['limit'] > 1000:  # noqa: E501
            raise ValueError("Invalid value for parameter `limit` when calling `search_offers_using_get`, must be a value less than or equal to `1000`")  # noqa: E501
        if 'limit' in local_var_params and local_var_params['limit'] < 1:  # noqa: E501
            raise ValueError("Invalid value for parameter `limit` when calling `search_offers_using_get`, must be a value greater than or equal to `1`")  # noqa: E501
        if 'offset' in local_var_params and local_var_params['offset'] < 0:  # noqa: E501
            raise ValueError("Invalid value for parameter `offset` when calling `search_offers_using_get`, must be a value greater than or equal to `0`")  # noqa: E501
        collection_formats = {}

        path_params = {}

        query_params = []
        if 'seller_id' in local_var_params:
            query_params.append(('seller.id', local_var_params['seller_id']))  # noqa: E501
        if 'name' in local_var_params:
            query_params.append(('name', local_var_params['name']))  # noqa: E501
        if 'selling_mode_price_amount_gte' in local_var_params:
            query_params.append(('sellingMode.price.amount.gte', local_var_params['selling_mode_price_amount_gte']))  # noqa: E501
        if 'selling_mode_price_amount_lte' in local_var_params:
            query_params.append(('sellingMode.price.amount.lte', local_var_params['selling_mode_price_amount_lte']))  # noqa: E501
        if 'publication_status' in local_var_params:
            query_params.append(('publication.status', local_var_params['publication_status']))  # noqa: E501
        if 'selling_mode_format' in local_var_params:
            query_params.append(('sellingMode.format', local_var_params['selling_mode_format']))  # noqa: E501
        if 'external_id' in local_var_params:
            query_params.append(('external.id', local_var_params['external_id']))  # noqa: E501
        if 'sort' in local_var_params:
            query_params.append(('sort', local_var_params['sort']))  # noqa: E501
        if 'limit' in local_var_params:
            query_params.append(('limit', local_var_params['limit']))  # noqa: E501
        if 'offset' in local_var_params:
            query_params.append(('offset', local_var_params['offset']))  # 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.beta.v1+json'])  # noqa: E501

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

        return self.api_client.call_api(
            '/sale/offers', 'GET',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='OffersSearchResultDtoV1',  # 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)
