# 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 OfferVariantsApi(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 create_or_update_variant_set(self, set_id, variant_set, **kwargs):  # noqa: E501
        """[BETA] Create or update variant set  # noqa: E501

        [BETA] Use this resource to create or update variant set.   A valid variant set must consist of three required elements:  - name:    - it can't be blank and must not be longer than 50 characters  - parameters:    - it should contain parameter identifiers used for offer grouping    - parameter identifiers from the offers and special `color/pattern` value (for grouping via image) are permitted    - it must contain at least one element (up to 2)  - offers:    - it must contain at least 2 offers (500 at most)    - `colorPattern` value must be set for every offer if `color/pattern` parameter is used    - `colorPattern` value can't be blank and must not be longer than 50 characters    - `colorPattern` can take arbitrary string value like `red`, `b323592c-522f-4ec1-b9ea-3764538e0ac4` (UUID), etc.    - offers having the same image should have identical `colorPattern` value    Let's assume we have 4 offers:    - offer with id 2 having an image of a red t-shirt and S as a value of parameter with id 21    - offer with id 3 having an image of a red t-shirt and M as a value of parameter with id 21    - offer with id 4 having an image of a blue t-shirt and S as a value of parameter with id 21    - offer with id 5 having an image of a blue t-shirt and M as a value of parameter with id 21    You can build a variant set by grouping offers using combination of available parameters:    - variant set with offer parameter only    ```      {        \"name\": \"t-shirt\",        \"offers\": [          {            \"id\": \"2\"          },          {            \"id\": \"3\"          }        ],        \"parameters\": [          { \"id\": \"21\" }        ]      }    ```    - variant set with `color/pattern` parameter only    ```      {        \"name\": \"t-shirt\",        \"offers\": [          {            \"id\": \"2\",            \"colorPattern\": \"red\"          },          {            \"id\": \"4\",            \"colorPattern\": \"blue\"          }        ],        \"parameters\": [          {\"id\": \"color/pattern\"}        ]      }    ```    - variant set with offer and `color/pattern` parameters    ```      {        \"name\": \"t-shirt\",        \"offers\": [          {            \"id\": \"2\",            \"colorPattern\": \"red\"          },          {            \"id\": \"3\",            \"colorPattern\": \"red\"          },          {            \"id\": \"4\",            \"colorPattern\": \"blue\"          },          {            \"id\": \"5\",            \"colorPattern\": \"blue\"          }        ],        \"parameters\": [          {\"id\": \"color/pattern\"},          {\"id\": \"21\"}        ]      }    ```      More general information about variant sets can be found [here](https://allegro.pl/pomoc/faq/wielowariantowosc-jak-polaczyc-oferty-xGgaOByGgTb#dodatkowe-informacje),    more information about variant sets API can be found <a href=\"../../news/2018-07-09-wielowariantowosc/#03\" 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_or_update_variant_set(set_id, variant_set, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str set_id: Variant set id (required)
        :param VariantSet variant_set: (required)
        :return: None
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.create_or_update_variant_set_with_http_info(set_id, variant_set, **kwargs)  # noqa: E501
        else:
            (data) = self.create_or_update_variant_set_with_http_info(set_id, variant_set, **kwargs)  # noqa: E501
            return data

    def create_or_update_variant_set_with_http_info(self, set_id, variant_set, **kwargs):  # noqa: E501
        """[BETA] Create or update variant set  # noqa: E501

        [BETA] Use this resource to create or update variant set.   A valid variant set must consist of three required elements:  - name:    - it can't be blank and must not be longer than 50 characters  - parameters:    - it should contain parameter identifiers used for offer grouping    - parameter identifiers from the offers and special `color/pattern` value (for grouping via image) are permitted    - it must contain at least one element (up to 2)  - offers:    - it must contain at least 2 offers (500 at most)    - `colorPattern` value must be set for every offer if `color/pattern` parameter is used    - `colorPattern` value can't be blank and must not be longer than 50 characters    - `colorPattern` can take arbitrary string value like `red`, `b323592c-522f-4ec1-b9ea-3764538e0ac4` (UUID), etc.    - offers having the same image should have identical `colorPattern` value    Let's assume we have 4 offers:    - offer with id 2 having an image of a red t-shirt and S as a value of parameter with id 21    - offer with id 3 having an image of a red t-shirt and M as a value of parameter with id 21    - offer with id 4 having an image of a blue t-shirt and S as a value of parameter with id 21    - offer with id 5 having an image of a blue t-shirt and M as a value of parameter with id 21    You can build a variant set by grouping offers using combination of available parameters:    - variant set with offer parameter only    ```      {        \"name\": \"t-shirt\",        \"offers\": [          {            \"id\": \"2\"          },          {            \"id\": \"3\"          }        ],        \"parameters\": [          { \"id\": \"21\" }        ]      }    ```    - variant set with `color/pattern` parameter only    ```      {        \"name\": \"t-shirt\",        \"offers\": [          {            \"id\": \"2\",            \"colorPattern\": \"red\"          },          {            \"id\": \"4\",            \"colorPattern\": \"blue\"          }        ],        \"parameters\": [          {\"id\": \"color/pattern\"}        ]      }    ```    - variant set with offer and `color/pattern` parameters    ```      {        \"name\": \"t-shirt\",        \"offers\": [          {            \"id\": \"2\",            \"colorPattern\": \"red\"          },          {            \"id\": \"3\",            \"colorPattern\": \"red\"          },          {            \"id\": \"4\",            \"colorPattern\": \"blue\"          },          {            \"id\": \"5\",            \"colorPattern\": \"blue\"          }        ],        \"parameters\": [          {\"id\": \"color/pattern\"},          {\"id\": \"21\"}        ]      }    ```      More general information about variant sets can be found [here](https://allegro.pl/pomoc/faq/wielowariantowosc-jak-polaczyc-oferty-xGgaOByGgTb#dodatkowe-informacje),    more information about variant sets API can be found <a href=\"../../news/2018-07-09-wielowariantowosc/#03\" 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_or_update_variant_set_with_http_info(set_id, variant_set, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str set_id: Variant set id (required)
        :param VariantSet variant_set: (required)
        :return: None
                 If the method is called asynchronously,
                 returns the request thread.
        """

        local_var_params = locals()

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

        collection_formats = {}

        path_params = {}
        if 'set_id' in local_var_params:
            path_params['setId'] = local_var_params['set_id']  # noqa: E501

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        if 'variant_set' in local_var_params:
            body_params = local_var_params['variant_set']
        # HTTP header `Content-Type`
        header_params['Content-Type'] = self.api_client.select_header_content_type(  # noqa: E501
            ['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/offer-variants/{setId}', 'PUT',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type=None,  # 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 delete_variant_set(self, set_id, **kwargs):  # noqa: E501
        """[BETA] Delete a variant set  # noqa: E501

        [BETA] Use this resource to delete variant set by id. Offers included in variant set will not be stopped or modified by this operation. More information about this resource you can find <a href=\"../../news/2018-07-09-wielowariantowosc/#05\" 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.delete_variant_set(set_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str set_id: Variant set id (required)
        :return: None
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.delete_variant_set_with_http_info(set_id, **kwargs)  # noqa: E501
        else:
            (data) = self.delete_variant_set_with_http_info(set_id, **kwargs)  # noqa: E501
            return data

    def delete_variant_set_with_http_info(self, set_id, **kwargs):  # noqa: E501
        """[BETA] Delete a variant set  # noqa: E501

        [BETA] Use this resource to delete variant set by id. Offers included in variant set will not be stopped or modified by this operation. More information about this resource you can find <a href=\"../../news/2018-07-09-wielowariantowosc/#05\" 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.delete_variant_set_with_http_info(set_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str set_id: Variant set id (required)
        :return: None
                 If the method is called asynchronously,
                 returns the request thread.
        """

        local_var_params = locals()

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

        collection_formats = {}

        path_params = {}
        if 'set_id' in local_var_params:
            path_params['setId'] = local_var_params['set_id']  # noqa: E501

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

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

        return self.api_client.call_api(
            '/sale/offer-variants/{setId}', 'DELETE',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type=None,  # 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_variant_set(self, set_id, **kwargs):  # noqa: E501
        """[BETA] Get a variant set  # noqa: E501

        [BETA] Use this resource to get variant set by set id. More information about this resource you can find <a href=\"../../news/2018-07-09-wielowariantowosc/#04\" 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_variant_set(set_id, async_req=True)
        >>> result = thread.get()

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

    def get_variant_set_with_http_info(self, set_id, **kwargs):  # noqa: E501
        """[BETA] Get a variant set  # noqa: E501

        [BETA] Use this resource to get variant set by set id. More information about this resource you can find <a href=\"../../news/2018-07-09-wielowariantowosc/#04\" 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_variant_set_with_http_info(set_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str set_id: setId (required)
        :return: VariantSet
                 If the method is called asynchronously,
                 returns the request thread.
        """

        local_var_params = locals()

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

        collection_formats = {}

        path_params = {}
        if 'set_id' in local_var_params:
            path_params['setId'] = local_var_params['set_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.beta.v1+json'])  # noqa: E501

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

        return self.api_client.call_api(
            '/sale/offer-variants/{setId}', 'GET',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='VariantSet',  # 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_variant_sets(self, user_id, **kwargs):  # noqa: E501
        """[BETA] Get the user's variant sets  # noqa: E501

        [BETA] Use this resource to get created variant sets. The returned variant sets are ordered by name. More information about this resource you can find <a href=\"../../news/2018-07-09-wielowariantowosc/\" 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_variant_sets(user_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str user_id: Filter by user id, you are allowed to get your variant sets only. (required)
        :param int offset: Index of first returned variant set.
        :param int limit: Maximum number of returned variant sets.
        :param str query: Filter variant sets by name or offer id.
        :return: VariantSets
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.get_variant_sets_with_http_info(user_id, **kwargs)  # noqa: E501
        else:
            (data) = self.get_variant_sets_with_http_info(user_id, **kwargs)  # noqa: E501
            return data

    def get_variant_sets_with_http_info(self, user_id, **kwargs):  # noqa: E501
        """[BETA] Get the user's variant sets  # noqa: E501

        [BETA] Use this resource to get created variant sets. The returned variant sets are ordered by name. More information about this resource you can find <a href=\"../../news/2018-07-09-wielowariantowosc/\" 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_variant_sets_with_http_info(user_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str user_id: Filter by user id, you are allowed to get your variant sets only. (required)
        :param int offset: Index of first returned variant set.
        :param int limit: Maximum number of returned variant sets.
        :param str query: Filter variant sets by name or offer id.
        :return: VariantSets
                 If the method is called asynchronously,
                 returns the request thread.
        """

        local_var_params = locals()

        all_params = ['user_id', 'offset', 'limit', 'query']  # 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_variant_sets" % key
                )
            local_var_params[key] = val
        del local_var_params['kwargs']
        # verify the required parameter 'user_id' is set
        if ('user_id' not in local_var_params or
                local_var_params['user_id'] is None):
            raise ValueError("Missing the required parameter `user_id` when calling `get_variant_sets`")  # 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 `get_variant_sets`, must be a value greater than or equal to `0`")  # noqa: E501
        if 'limit' in local_var_params and local_var_params['limit'] > 50:  # noqa: E501
            raise ValueError("Invalid value for parameter `limit` when calling `get_variant_sets`, must be a value less than or equal to `50`")  # 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 `get_variant_sets`, must be a value greater than or equal to `1`")  # noqa: E501
        if ('query' in local_var_params and
                len(local_var_params['query']) > 50):
            raise ValueError("Invalid value for parameter `query` when calling `get_variant_sets`, length must be less than or equal to `50`")  # noqa: E501
        collection_formats = {}

        path_params = {}

        query_params = []
        if 'user_id' in local_var_params:
            query_params.append(('user.id', local_var_params['user_id']))  # noqa: E501
        if 'offset' in local_var_params:
            query_params.append(('offset', local_var_params['offset']))  # noqa: E501
        if 'limit' in local_var_params:
            query_params.append(('limit', local_var_params['limit']))  # noqa: E501
        if 'query' in local_var_params:
            query_params.append(('query', local_var_params['query']))  # 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/offer-variants', 'GET',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='VariantSets',  # 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)
