# coding: utf-8

"""
    Selling Partner API for Solicitations

    With the Solicitations API you can build applications that send non-critical solicitations to buyers. You can get a list of solicitation types that are available for an order that you specify, then call an operation that sends a solicitation to the buyer for that order. Buyers cannot respond to solicitations sent by this API, and these solicitations do not appear in the Messaging section of Seller Central or in the recipient's Message Center. The Solicitations API returns responses that are formed according to the <a href=https://tools.ietf.org/html/draft-kelly-json-hal-08>JSON Hypertext Application Language</a> (HAL) standard.  # noqa: E501

    OpenAPI spec version: v1
    
    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 api_models.solicitations_api.swagger_client.api_client import ApiClient


class SolicitationsApi(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 create_product_review_and_seller_feedback_solicitation(self, amazon_order_id, marketplace_ids, **kwargs):  # noqa: E501
        """create_product_review_and_seller_feedback_solicitation  # noqa: E501

        Sends a solicitation to a buyer asking for seller feedback and a product review for the specified order. Send only one productReviewAndSellerFeedback or free form proactive message per order.  **Usage Plan:**  | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 5 |  The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The table above indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may see higher rate and burst values than those shown here. For more information, see [Usage Plans and Rate Limits in the Selling Partner API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).  # 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_product_review_and_seller_feedback_solicitation(amazon_order_id, marketplace_ids, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str amazon_order_id: An Amazon order identifier. This specifies the order for which a solicitation is sent. (required)
        :param list[str] marketplace_ids: A marketplace identifier. This specifies the marketplace in which the order was placed. Only one marketplace can be specified. (required)
        :return: CreateProductReviewAndSellerFeedbackSolicitationResponse
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = False
        if kwargs.get('async_req'):
            return self.create_product_review_and_seller_feedback_solicitation_with_http_info(amazon_order_id, marketplace_ids, **kwargs)  # noqa: E501
        else:
            (data) = self.create_product_review_and_seller_feedback_solicitation_with_http_info(amazon_order_id, marketplace_ids, **kwargs)  # noqa: E501
            return data

    def create_product_review_and_seller_feedback_solicitation_with_http_info(self, amazon_order_id, marketplace_ids, **kwargs):  # noqa: E501
        """create_product_review_and_seller_feedback_solicitation  # noqa: E501

        Sends a solicitation to a buyer asking for seller feedback and a product review for the specified order. Send only one productReviewAndSellerFeedback or free form proactive message per order.  **Usage Plan:**  | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 5 |  The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The table above indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may see higher rate and burst values than those shown here. For more information, see [Usage Plans and Rate Limits in the Selling Partner API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).  # 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_product_review_and_seller_feedback_solicitation_with_http_info(amazon_order_id, marketplace_ids, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str amazon_order_id: An Amazon order identifier. This specifies the order for which a solicitation is sent. (required)
        :param list[str] marketplace_ids: A marketplace identifier. This specifies the marketplace in which the order was placed. Only one marketplace can be specified. (required)
        :return: CreateProductReviewAndSellerFeedbackSolicitationResponse
                 If the method is called asynchronously,
                 returns the request thread.
        """

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

        if ('marketplace_ids' in params and
                len(params['marketplace_ids']) > 1):
            raise ValueError("Invalid value for parameter `marketplace_ids` when calling `create_product_review_and_seller_feedback_solicitation`, number of items must be less than or equal to `1`")  # noqa: E501
        collection_formats = {}

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

        query_params = []
        if 'marketplace_ids' in params:
            query_params.append(('marketplaceIds', params['marketplace_ids']))  # noqa: E501
            collection_formats['marketplaceIds'] = 'csv'  # 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/hal+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 = []  # noqa: E501

        return self.api_client.call_api(
            '/solicitations/v1/orders/{amazonOrderId}/solicitations/productReviewAndSellerFeedback', 'POST',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='CreateProductReviewAndSellerFeedbackSolicitationResponse',  # 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_solicitation_actions_for_order(self, amazon_order_id, marketplace_ids, **kwargs):  # noqa: E501
        """get_solicitation_actions_for_order  # noqa: E501

        Returns a list of solicitation types that are available for an order that you specify. A solicitation type is represented by an actions object, which contains a path and query parameter(s). You can use the path and parameter(s) to call an operation that sends a solicitation. Currently only the productReviewAndSellerFeedbackSolicitation solicitation type is available.  **Usage Plan:**  | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 5 |  The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The table above indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may see higher rate and burst values than those shown here. For more information, see [Usage Plans and Rate Limits in the Selling Partner API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).  # 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_solicitation_actions_for_order(amazon_order_id, marketplace_ids, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str amazon_order_id: An Amazon order identifier. This specifies the order for which you want a list of available solicitation types. (required)
        :param list[str] marketplace_ids: A marketplace identifier. This specifies the marketplace in which the order was placed. Only one marketplace can be specified. (required)
        :return: GetSolicitationActionsForOrderResponse
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.get_solicitation_actions_for_order_with_http_info(amazon_order_id, marketplace_ids, **kwargs)  # noqa: E501
        else:
            (data) = self.get_solicitation_actions_for_order_with_http_info(amazon_order_id, marketplace_ids, **kwargs)  # noqa: E501
            return data

    def get_solicitation_actions_for_order_with_http_info(self, amazon_order_id, marketplace_ids, **kwargs):  # noqa: E501
        """get_solicitation_actions_for_order  # noqa: E501

        Returns a list of solicitation types that are available for an order that you specify. A solicitation type is represented by an actions object, which contains a path and query parameter(s). You can use the path and parameter(s) to call an operation that sends a solicitation. Currently only the productReviewAndSellerFeedbackSolicitation solicitation type is available.  **Usage Plan:**  | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 5 |  The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The table above indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may see higher rate and burst values than those shown here. For more information, see [Usage Plans and Rate Limits in the Selling Partner API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).  # 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_solicitation_actions_for_order_with_http_info(amazon_order_id, marketplace_ids, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str amazon_order_id: An Amazon order identifier. This specifies the order for which you want a list of available solicitation types. (required)
        :param list[str] marketplace_ids: A marketplace identifier. This specifies the marketplace in which the order was placed. Only one marketplace can be specified. (required)
        :return: GetSolicitationActionsForOrderResponse
                 If the method is called asynchronously,
                 returns the request thread.
        """

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

        if ('marketplace_ids' in params and
                len(params['marketplace_ids']) > 1):
            raise ValueError("Invalid value for parameter `marketplace_ids` when calling `get_solicitation_actions_for_order`, number of items must be less than or equal to `1`")  # noqa: E501
        collection_formats = {}

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

        query_params = []
        if 'marketplace_ids' in params:
            query_params.append(('marketplaceIds', params['marketplace_ids']))  # noqa: E501
            collection_formats['marketplaceIds'] = 'csv'  # 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/hal+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 = []  # noqa: E501

        return self.api_client.call_api(
            '/solicitations/v1/orders/{amazonOrderId}', 'GET',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='GetSolicitationActionsForOrderResponse',  # 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)
