# coding: utf-8

"""
    Shutterstock API Reference

    The Shutterstock API provides access to Shutterstock's library of media, as well as information about customers' accounts and the contributors that provide the media.  # noqa: E501

    OpenAPI spec version: 1.0.11
    
    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 shutterstock_api.api_client import ApiClient


class EditorialApi(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_editorial_image(self, id, country, **kwargs):  # noqa: E501
        """Get editorial content details  # noqa: E501

        This endpoint shows information about an editorial image, including a URL to a preview image and the sizes that it is available in.  # 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_editorial_image(id, country, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str id: Editorial ID (required)
        :param str country: Returns only if the content is available for distribution in a certain country; specify with 3-letter country code (required)
        :return: EditorialContent
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.get_editorial_image_with_http_info(id, country, **kwargs)  # noqa: E501
        else:
            (data) = self.get_editorial_image_with_http_info(id, country, **kwargs)  # noqa: E501
            return data

    def get_editorial_image_with_http_info(self, id, country, **kwargs):  # noqa: E501
        """Get editorial content details  # noqa: E501

        This endpoint shows information about an editorial image, including a URL to a preview image and the sizes that it is available in.  # 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_editorial_image_with_http_info(id, country, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str id: Editorial ID (required)
        :param str country: Returns only if the content is available for distribution in a certain country; specify with 3-letter country code (required)
        :return: EditorialContent
                 If the method is called asynchronously,
                 returns the request thread.
        """

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

        collection_formats = {}

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

        query_params = []
        if 'country' in params:
            query_params.append(('country', params['country']))  # 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 = ['basic', 'customer_accessCode']  # noqa: E501

        return self.api_client.call_api(
            '/v2/editorial/{id}', 'GET',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='EditorialContent',  # 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_editorial_livefeed(self, id, country, **kwargs):  # noqa: E501
        """Get editorial livefeed  # 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_editorial_livefeed(id, country, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str id: Editorial livefeed ID; must be an URI encoded string (required)
        :param str country: Returns only if the livefeed is available for distribution in a certain country; specify with 3-letter country code (required)
        :return: EditorialLivefeed
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.get_editorial_livefeed_with_http_info(id, country, **kwargs)  # noqa: E501
        else:
            (data) = self.get_editorial_livefeed_with_http_info(id, country, **kwargs)  # noqa: E501
            return data

    def get_editorial_livefeed_with_http_info(self, id, country, **kwargs):  # noqa: E501
        """Get editorial livefeed  # 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_editorial_livefeed_with_http_info(id, country, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str id: Editorial livefeed ID; must be an URI encoded string (required)
        :param str country: Returns only if the livefeed is available for distribution in a certain country; specify with 3-letter country code (required)
        :return: EditorialLivefeed
                 If the method is called asynchronously,
                 returns the request thread.
        """

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

        collection_formats = {}

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

        query_params = []
        if 'country' in params:
            query_params.append(('country', params['country']))  # 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 = ['basic', 'customer_accessCode']  # noqa: E501

        return self.api_client.call_api(
            '/v2/editorial/livefeeds/{id}', 'GET',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='EditorialLivefeed',  # 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_editorial_livefeed_items(self, id, country, **kwargs):  # noqa: E501
        """Get editorial livefeed items  # 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_editorial_livefeed_items(id, country, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str id: Editorial livefeed ID; must be an URI encoded string (required)
        :param str country: Returns only if the livefeed items are available for distribution in a certain country; specify with 3-letter country code (required)
        :return: EditorialContentDataList
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.get_editorial_livefeed_items_with_http_info(id, country, **kwargs)  # noqa: E501
        else:
            (data) = self.get_editorial_livefeed_items_with_http_info(id, country, **kwargs)  # noqa: E501
            return data

    def get_editorial_livefeed_items_with_http_info(self, id, country, **kwargs):  # noqa: E501
        """Get editorial livefeed items  # 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_editorial_livefeed_items_with_http_info(id, country, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str id: Editorial livefeed ID; must be an URI encoded string (required)
        :param str country: Returns only if the livefeed items are available for distribution in a certain country; specify with 3-letter country code (required)
        :return: EditorialContentDataList
                 If the method is called asynchronously,
                 returns the request thread.
        """

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

        collection_formats = {}

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

        query_params = []
        if 'country' in params:
            query_params.append(('country', params['country']))  # 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 = ['basic', 'customer_accessCode']  # noqa: E501

        return self.api_client.call_api(
            '/v2/editorial/livefeeds/{id}/items', 'GET',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='EditorialContentDataList',  # 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_editorial_livefeed_list(self, country, **kwargs):  # noqa: E501
        """Get editorial livefeed list  # 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_editorial_livefeed_list(country, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str country: Returns only livefeeds that are available for distribution in a certain country; specify with 3-letter country code (required)
        :param int page: Page number
        :param int per_page: Number of results per page, defaults to 20
        :return: EditorialLivefeedList
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.get_editorial_livefeed_list_with_http_info(country, **kwargs)  # noqa: E501
        else:
            (data) = self.get_editorial_livefeed_list_with_http_info(country, **kwargs)  # noqa: E501
            return data

    def get_editorial_livefeed_list_with_http_info(self, country, **kwargs):  # noqa: E501
        """Get editorial livefeed list  # 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_editorial_livefeed_list_with_http_info(country, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str country: Returns only livefeeds that are available for distribution in a certain country; specify with 3-letter country code (required)
        :param int page: Page number
        :param int per_page: Number of results per page, defaults to 20
        :return: EditorialLivefeedList
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['country', 'page', 'per_page']  # 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_editorial_livefeed_list" % key
                )
            params[key] = val
        del params['kwargs']
        # verify the required parameter 'country' is set
        if ('country' not in params or
                params['country'] is None):
            raise ValueError("Missing the required parameter `country` when calling `get_editorial_livefeed_list`")  # noqa: E501

        if 'page' in params and params['page'] < 1:  # noqa: E501
            raise ValueError("Invalid value for parameter `page` when calling `get_editorial_livefeed_list`, must be a value greater than or equal to `1`")  # noqa: E501
        if 'per_page' in params and params['per_page'] > 50:  # noqa: E501
            raise ValueError("Invalid value for parameter `per_page` when calling `get_editorial_livefeed_list`, must be a value less than or equal to `50`")  # noqa: E501
        if 'per_page' in params and params['per_page'] < 1:  # noqa: E501
            raise ValueError("Invalid value for parameter `per_page` when calling `get_editorial_livefeed_list`, must be a value greater than or equal to `1`")  # noqa: E501
        collection_formats = {}

        path_params = {}

        query_params = []
        if 'country' in params:
            query_params.append(('country', params['country']))  # noqa: E501
        if 'page' in params:
            query_params.append(('page', params['page']))  # noqa: E501
        if 'per_page' in params:
            query_params.append(('per_page', params['per_page']))  # 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 = ['basic', 'customer_accessCode']  # noqa: E501

        return self.api_client.call_api(
            '/v2/editorial/livefeeds', 'GET',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='EditorialLivefeedList',  # 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 license_editorial_image(self, body, **kwargs):  # noqa: E501
        """License editorial content  # noqa: E501

        This endpoint gets licenses for one or more editorial images. You must specify the country and one or more editorial images to license.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.license_editorial_image(body, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param LicenseEditorialContentRequest body: License editorial content (required)
        :return: LicenseEditorialContentResultDataList
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.license_editorial_image_with_http_info(body, **kwargs)  # noqa: E501
        else:
            (data) = self.license_editorial_image_with_http_info(body, **kwargs)  # noqa: E501
            return data

    def license_editorial_image_with_http_info(self, body, **kwargs):  # noqa: E501
        """License editorial content  # noqa: E501

        This endpoint gets licenses for one or more editorial images. You must specify the country and one or more editorial images to license.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.license_editorial_image_with_http_info(body, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param LicenseEditorialContentRequest body: License editorial content (required)
        :return: LicenseEditorialContentResultDataList
                 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 license_editorial_image" % key
                )
            params[key] = val
        del params['kwargs']
        # verify the required parameter 'body' is set
        if ('body' not in params or
                params['body'] is None):
            raise ValueError("Missing the required parameter `body` when calling `license_editorial_image`")  # noqa: E501

        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 = ['customer_accessCode']  # noqa: E501

        return self.api_client.call_api(
            '/v2/editorial/licenses', 'POST',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='LicenseEditorialContentResultDataList',  # 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 search_editorial(self, country, **kwargs):  # noqa: E501
        """Search editorial content  # noqa: E501

        This endpoint searches for editorial images. If you specify more than one search parameter, the API uses an AND condition. Array parameters can be specified multiple times; in this case, the API uses an AND or an OR condition with those values, depending on the parameter. You can also filter search terms out in the `query` parameter by prefixing the term with NOT.  # 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_editorial(country, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str country: Show only editorial content that is available for distribution in a certain country; specify with 3-letter country code (required)
        :param str query: One or more search terms separated by spaces
        :param str sort: Sort by
        :param str category: Show editorial content within a certain editorial category; specify by category name
        :param list[str] supplier_code: Show only editorial content from certain suppliers
        :param date date_start: Show only editorial content generated on or after a specific date, in the format of YYYY-MM-DD
        :param date date_end: Show only editorial content generated on or before a specific date, in the format of YYYY-MM-DD
        :param int per_page: Number of results per page, defaults to 20
        :param str cursor: The cursor of the page with which to start fetching results; this cursor is returned from previous requests
        :return: EditorialSearchResults
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.search_editorial_with_http_info(country, **kwargs)  # noqa: E501
        else:
            (data) = self.search_editorial_with_http_info(country, **kwargs)  # noqa: E501
            return data

    def search_editorial_with_http_info(self, country, **kwargs):  # noqa: E501
        """Search editorial content  # noqa: E501

        This endpoint searches for editorial images. If you specify more than one search parameter, the API uses an AND condition. Array parameters can be specified multiple times; in this case, the API uses an AND or an OR condition with those values, depending on the parameter. You can also filter search terms out in the `query` parameter by prefixing the term with NOT.  # 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_editorial_with_http_info(country, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str country: Show only editorial content that is available for distribution in a certain country; specify with 3-letter country code (required)
        :param str query: One or more search terms separated by spaces
        :param str sort: Sort by
        :param str category: Show editorial content within a certain editorial category; specify by category name
        :param list[str] supplier_code: Show only editorial content from certain suppliers
        :param date date_start: Show only editorial content generated on or after a specific date, in the format of YYYY-MM-DD
        :param date date_end: Show only editorial content generated on or before a specific date, in the format of YYYY-MM-DD
        :param int per_page: Number of results per page, defaults to 20
        :param str cursor: The cursor of the page with which to start fetching results; this cursor is returned from previous requests
        :return: EditorialSearchResults
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['country', 'query', 'sort', 'category', 'supplier_code', 'date_start', 'date_end', 'per_page', 'cursor']  # 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 search_editorial" % key
                )
            params[key] = val
        del params['kwargs']
        # verify the required parameter 'country' is set
        if ('country' not in params or
                params['country'] is None):
            raise ValueError("Missing the required parameter `country` when calling `search_editorial`")  # noqa: E501

        if 'per_page' in params and params['per_page'] > 50:  # noqa: E501
            raise ValueError("Invalid value for parameter `per_page` when calling `search_editorial`, must be a value less than or equal to `50`")  # noqa: E501
        if 'per_page' in params and params['per_page'] < 1:  # noqa: E501
            raise ValueError("Invalid value for parameter `per_page` when calling `search_editorial`, must be a value greater than or equal to `1`")  # noqa: E501
        collection_formats = {}

        path_params = {}

        query_params = []
        if 'query' in params:
            query_params.append(('query', params['query']))  # noqa: E501
        if 'sort' in params:
            query_params.append(('sort', params['sort']))  # noqa: E501
        if 'category' in params:
            query_params.append(('category', params['category']))  # noqa: E501
        if 'country' in params:
            query_params.append(('country', params['country']))  # noqa: E501
        if 'supplier_code' in params:
            query_params.append(('supplier_code', params['supplier_code']))  # noqa: E501
            collection_formats['supplier_code'] = 'multi'  # noqa: E501
        if 'date_start' in params:
            query_params.append(('date_start', params['date_start']))  # noqa: E501
        if 'date_end' in params:
            query_params.append(('date_end', params['date_end']))  # noqa: E501
        if 'per_page' in params:
            query_params.append(('per_page', params['per_page']))  # noqa: E501
        if 'cursor' in params:
            query_params.append(('cursor', params['cursor']))  # 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 = ['basic', 'customer_accessCode']  # noqa: E501

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