# coding: utf-8

"""
    Selling Partner API for Direct Fulfillment Orders

    The Selling Partner API for Direct Fulfillment Orders provides programmatic access to a direct fulfillment vendor's order data.

    The version of the OpenAPI document: 2021-12-28
    Generated by OpenAPI Generator (https://openapi-generator.tech)

    Do not edit the class manually.
"""  # noqa: E501


from __future__ import absolute_import

import re  # noqa: F401

# python 2 and python 3 compatibility library
import six

from spapi.api_client import ApiClient


class VendorDfOrdersApi(object):
    """NOTE: This class is auto generated by the openapi generator.

    Do not edit the class manually.
    """

    api_models_module = "spapi.models.vendor_direct_fulfillment_orders_v2021_12_28"

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

    def get_order(self, purchase_order_number, **kwargs):  # noqa: E501
        """get_order  # noqa: E501

        Returns purchase order information for the purchaseOrderNumber that you specify.  **Usage Plan:**  | Rate (requests per second) | Burst | | ---- | ---- | | 10 | 10 |  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 then those shown here. For more information, see [Usage Plans and Rate Limits in the Selling Partner API](doc: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_order(purchase_order_number, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str purchase_order_number: The order identifier for the purchase order that you want. Formatting Notes: alpha-numeric code. (required)
        :return: Order
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.get_order_with_http_info(purchase_order_number, **kwargs)  # noqa: E501
        else:
            (data) = self.get_order_with_http_info(purchase_order_number, **kwargs)  # noqa: E501
            return data

    def get_order_with_http_info(self, purchase_order_number, **kwargs):  # noqa: E501
        """get_order  # noqa: E501

        Returns purchase order information for the purchaseOrderNumber that you specify.  **Usage Plan:**  | Rate (requests per second) | Burst | | ---- | ---- | | 10 | 10 |  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 then those shown here. For more information, see [Usage Plans and Rate Limits in the Selling Partner API](doc: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_order_with_http_info(purchase_order_number, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str purchase_order_number: The order identifier for the purchase order that you want. Formatting Notes: alpha-numeric code. (required)
        :return: Order
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['purchase_order_number']  # 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_order" % key
                )
            params[key] = val
        del params['kwargs']
        # verify the required parameter 'purchase_order_number' is set
        if self.api_client.client_side_validation and ('purchase_order_number' not in params or
                                                       params['purchase_order_number'] is None):  # noqa: E501
            raise ValueError("Missing the required parameter `purchase_order_number` when calling `get_order`")  # noqa: E501

        collection_formats = {}

        path_params = {}
        if 'purchase_order_number' in params:
            path_params['purchaseOrderNumber'] = params['purchase_order_number']  # 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/json'])  # noqa: E501

        # Authentication setting
        auth_settings = []  # noqa: E501

        return self.api_client.call_api(
            '/vendor/directFulfillment/orders/2021-12-28/purchaseOrders/{purchaseOrderNumber}', 'GET',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='Order',  # 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, api_models_module=self.api_models_module)

    def get_orders(self, created_after, created_before, **kwargs):  # noqa: E501
        """get_orders  # noqa: E501

        Returns a list of purchase orders created during the time frame that you specify. You define the time frame using the createdAfter and createdBefore parameters. You must use both parameters. You can choose to get only the purchase order numbers by setting the includeDetails parameter to false. In that case, the operation returns a list of purchase order numbers. You can then call the getOrder operation to return the details of a specific order.  **Usage Plan:**  | Rate (requests per second) | Burst | | ---- | ---- | | 10 | 10 |  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 then those shown here. For more information, see [Usage Plans and Rate Limits in the Selling Partner API](doc: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_orders(created_after, created_before, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param datetime created_after: Purchase orders that became available after this date and time will be included in the result. Must be in ISO-8601 date/time format. (required)
        :param datetime created_before: Purchase orders that became available before this date and time will be included in the result. Must be in ISO-8601 date/time format. (required)
        :param str ship_from_party_id: The vendor warehouse identifier for the fulfillment warehouse. If not specified, the result will contain orders for all warehouses.
        :param str status: Returns only the purchase orders that match the specified status. If not specified, the result will contain orders that match any status.
        :param int limit: The limit to the number of purchase orders returned.
        :param str sort_order: Sort the list in ascending or descending order by order creation date.
        :param str next_token: Used for pagination when there are more orders than the specified result size limit. The token value is returned in the previous API call.
        :param bool include_details: When true, returns the complete purchase order details. Otherwise, only purchase order numbers are returned.
        :return: OrderList
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.get_orders_with_http_info(created_after, created_before, **kwargs)  # noqa: E501
        else:
            (data) = self.get_orders_with_http_info(created_after, created_before, **kwargs)  # noqa: E501
            return data

    def get_orders_with_http_info(self, created_after, created_before, **kwargs):  # noqa: E501
        """get_orders  # noqa: E501

        Returns a list of purchase orders created during the time frame that you specify. You define the time frame using the createdAfter and createdBefore parameters. You must use both parameters. You can choose to get only the purchase order numbers by setting the includeDetails parameter to false. In that case, the operation returns a list of purchase order numbers. You can then call the getOrder operation to return the details of a specific order.  **Usage Plan:**  | Rate (requests per second) | Burst | | ---- | ---- | | 10 | 10 |  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 then those shown here. For more information, see [Usage Plans and Rate Limits in the Selling Partner API](doc: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_orders_with_http_info(created_after, created_before, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param datetime created_after: Purchase orders that became available after this date and time will be included in the result. Must be in ISO-8601 date/time format. (required)
        :param datetime created_before: Purchase orders that became available before this date and time will be included in the result. Must be in ISO-8601 date/time format. (required)
        :param str ship_from_party_id: The vendor warehouse identifier for the fulfillment warehouse. If not specified, the result will contain orders for all warehouses.
        :param str status: Returns only the purchase orders that match the specified status. If not specified, the result will contain orders that match any status.
        :param int limit: The limit to the number of purchase orders returned.
        :param str sort_order: Sort the list in ascending or descending order by order creation date.
        :param str next_token: Used for pagination when there are more orders than the specified result size limit. The token value is returned in the previous API call.
        :param bool include_details: When true, returns the complete purchase order details. Otherwise, only purchase order numbers are returned.
        :return: OrderList
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['created_after', 'created_before', 'ship_from_party_id', 'status', 'limit', 'sort_order', 'next_token', 'include_details']  # 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_orders" % key
                )
            params[key] = val
        del params['kwargs']
        # verify the required parameter 'created_after' is set
        if self.api_client.client_side_validation and ('created_after' not in params or
                                                       params['created_after'] is None):  # noqa: E501
            raise ValueError("Missing the required parameter `created_after` when calling `get_orders`")  # noqa: E501
        # verify the required parameter 'created_before' is set
        if self.api_client.client_side_validation and ('created_before' not in params or
                                                       params['created_before'] is None):  # noqa: E501
            raise ValueError("Missing the required parameter `created_before` when calling `get_orders`")  # noqa: E501

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

        path_params = {}

        query_params = []
        if 'ship_from_party_id' in params:
            query_params.append(('shipFromPartyId', params['ship_from_party_id']))  # noqa: E501
        if 'status' in params:
            query_params.append(('status', params['status']))  # noqa: E501
        if 'limit' in params:
            query_params.append(('limit', params['limit']))  # noqa: E501
        if 'created_after' in params:
            query_params.append(('createdAfter', params['created_after']))  # noqa: E501
        if 'created_before' in params:
            query_params.append(('createdBefore', params['created_before']))  # noqa: E501
        if 'sort_order' in params:
            query_params.append(('sortOrder', params['sort_order']))  # noqa: E501
        if 'next_token' in params:
            query_params.append(('nextToken', params['next_token']))  # noqa: E501
        if 'include_details' in params:
            query_params.append(('includeDetails', params['include_details']))  # 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', 'pagination', 'orders'])  # noqa: E501

        # Authentication setting
        auth_settings = []  # noqa: E501

        return self.api_client.call_api(
            '/vendor/directFulfillment/orders/2021-12-28/purchaseOrders', 'GET',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='OrderList',  # 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, api_models_module=self.api_models_module)

    def submit_acknowledgement(self, body, **kwargs):  # noqa: E501
        """submit_acknowledgement  # noqa: E501

        Submits acknowledgements for one or more purchase orders.  **Usage Plan:**  | Rate (requests per second) | Burst | | ---- | ---- | | 10 | 10 |  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 then those shown here. For more information, see [Usage Plans and Rate Limits in the Selling Partner API](doc: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.submit_acknowledgement(body, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param SubmitAcknowledgementRequest body: The request body containing the acknowledgement to an order (required)
        :return: TransactionId
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.submit_acknowledgement_with_http_info(body, **kwargs)  # noqa: E501
        else:
            (data) = self.submit_acknowledgement_with_http_info(body, **kwargs)  # noqa: E501
            return data

    def submit_acknowledgement_with_http_info(self, body, **kwargs):  # noqa: E501
        """submit_acknowledgement  # noqa: E501

        Submits acknowledgements for one or more purchase orders.  **Usage Plan:**  | Rate (requests per second) | Burst | | ---- | ---- | | 10 | 10 |  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 then those shown here. For more information, see [Usage Plans and Rate Limits in the Selling Partner API](doc: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.submit_acknowledgement_with_http_info(body, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param SubmitAcknowledgementRequest body: The request body containing the acknowledgement to an order (required)
        :return: TransactionId
                 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 submit_acknowledgement" % key
                )
            params[key] = val
        del params['kwargs']
        # verify the required parameter 'body' is set
        if self.api_client.client_side_validation and ('body' not in params or
                                                       params['body'] is None):  # noqa: E501
            raise ValueError("Missing the required parameter `body` when calling `submit_acknowledgement`")  # 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 = []  # noqa: E501

        return self.api_client.call_api(
            '/vendor/directFulfillment/orders/2021-12-28/acknowledgements', 'POST',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='TransactionId',  # 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, api_models_module=self.api_models_module)
