# coding: utf-8

"""
    Selling Partner API for Finances

    The Selling Partner API for Finances helps you obtain financial information relevant to a seller's business. You can obtain financial events for a given order, financial event group, or date range without having to wait until a statement period closes. You can also obtain financial event groups for a given date range.

    The version of the OpenAPI document: v0
    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 FinancesV0Api(object):
    """NOTE: This class is auto generated by the openapi generator.

    Do not edit the class manually.
    """

    api_models_module = "spapi.models.finances_v0"

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

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

        Returns financial event groups for a given date range. It may take up to 48 hours for orders to appear in your financial events.  **Usage Plan:**  | Rate (requests per second) | Burst | | ---- | ---- | | 0.5 | 30 |  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.list_financial_event_groups(async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param int max_results_per_page: The maximum number of results to return per page. If the response exceeds the maximum number of transactions or 10 MB, the API responds with 'InvalidInput'.
        :param datetime financial_event_group_started_before: A date used for selecting financial event groups that opened before (but not at) a specified date and time, in [ISO 8601](https://developer-docs.amazon.com/sp-api/docs/iso-8601) format. The date-time  must be later than FinancialEventGroupStartedAfter and no later than two minutes before the request was submitted. If FinancialEventGroupStartedAfter and FinancialEventGroupStartedBefore are more than 180 days apart, no financial event groups are returned.
        :param datetime financial_event_group_started_after: A date used for selecting financial event groups that opened after (or at) a specified date and time, in [ISO 8601](https://developer-docs.amazon.com/sp-api/docs/iso-8601) format. The date-time must be no later than two minutes before the request was submitted.
        :param str next_token: A string token returned in the response of your previous request.
        :return: ListFinancialEventGroupsResponse
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.list_financial_event_groups_with_http_info(**kwargs)  # noqa: E501
        else:
            (data) = self.list_financial_event_groups_with_http_info(**kwargs)  # noqa: E501
            return data

    def list_financial_event_groups_with_http_info(self, **kwargs):  # noqa: E501
        """list_financial_event_groups  # noqa: E501

        Returns financial event groups for a given date range. It may take up to 48 hours for orders to appear in your financial events.  **Usage Plan:**  | Rate (requests per second) | Burst | | ---- | ---- | | 0.5 | 30 |  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.list_financial_event_groups_with_http_info(async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param int max_results_per_page: The maximum number of results to return per page. If the response exceeds the maximum number of transactions or 10 MB, the API responds with 'InvalidInput'.
        :param datetime financial_event_group_started_before: A date used for selecting financial event groups that opened before (but not at) a specified date and time, in [ISO 8601](https://developer-docs.amazon.com/sp-api/docs/iso-8601) format. The date-time  must be later than FinancialEventGroupStartedAfter and no later than two minutes before the request was submitted. If FinancialEventGroupStartedAfter and FinancialEventGroupStartedBefore are more than 180 days apart, no financial event groups are returned.
        :param datetime financial_event_group_started_after: A date used for selecting financial event groups that opened after (or at) a specified date and time, in [ISO 8601](https://developer-docs.amazon.com/sp-api/docs/iso-8601) format. The date-time must be no later than two minutes before the request was submitted.
        :param str next_token: A string token returned in the response of your previous request.
        :return: ListFinancialEventGroupsResponse
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['max_results_per_page', 'financial_event_group_started_before', 'financial_event_group_started_after', 'next_token']  # 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 list_financial_event_groups" % key
                )
            params[key] = val
        del params['kwargs']

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

        path_params = {}

        query_params = []
        if 'max_results_per_page' in params:
            query_params.append(('MaxResultsPerPage', params['max_results_per_page']))  # noqa: E501
        if 'financial_event_group_started_before' in params:
            query_params.append(('FinancialEventGroupStartedBefore', params['financial_event_group_started_before']))  # noqa: E501
        if 'financial_event_group_started_after' in params:
            query_params.append(('FinancialEventGroupStartedAfter', params['financial_event_group_started_after']))  # noqa: E501
        if 'next_token' in params:
            query_params.append(('NextToken', params['next_token']))  # 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 = []  # noqa: E501

        return self.api_client.call_api(
            '/finances/v0/financialEventGroups', 'GET',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='ListFinancialEventGroupsResponse',  # 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 list_financial_events(self, **kwargs):  # noqa: E501
        """list_financial_events  # noqa: E501

        Returns financial events for the specified data range. It may take up to 48 hours for orders to appear in your financial events. **Note:** in `ListFinancialEvents`, deferred events don't show up in responses until in they are released.  **Usage Plan:**  | Rate (requests per second) | Burst | | ---- | ---- | | 0.5 | 30 |  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.list_financial_events(async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param int max_results_per_page: The maximum number of results to return per page. If the response exceeds the maximum number of transactions or 10 MB, the API responds with 'InvalidInput'.
        :param datetime posted_after: A date used for selecting financial events posted after (or at) a specified time. The date-time must be no later than two minutes before the request was submitted, in [ISO 8601](https://developer-docs.amazon.com/sp-api/docs/iso-8601) date time format.
        :param datetime posted_before: A date used for selecting financial events posted before (but not at) a specified time. The date-time must be later than PostedAfter and no later than two minutes before the request was submitted, in [ISO 8601](https://developer-docs.amazon.com/sp-api/docs/iso-8601) date time format. If PostedAfter and PostedBefore are more than 180 days apart, no financial events are returned. You must specify the PostedAfter parameter if you specify the PostedBefore parameter. Default: Now minus two minutes.
        :param str next_token: A string token returned in the response of your previous request.
        :return: ListFinancialEventsResponse
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.list_financial_events_with_http_info(**kwargs)  # noqa: E501
        else:
            (data) = self.list_financial_events_with_http_info(**kwargs)  # noqa: E501
            return data

    def list_financial_events_with_http_info(self, **kwargs):  # noqa: E501
        """list_financial_events  # noqa: E501

        Returns financial events for the specified data range. It may take up to 48 hours for orders to appear in your financial events. **Note:** in `ListFinancialEvents`, deferred events don't show up in responses until in they are released.  **Usage Plan:**  | Rate (requests per second) | Burst | | ---- | ---- | | 0.5 | 30 |  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.list_financial_events_with_http_info(async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param int max_results_per_page: The maximum number of results to return per page. If the response exceeds the maximum number of transactions or 10 MB, the API responds with 'InvalidInput'.
        :param datetime posted_after: A date used for selecting financial events posted after (or at) a specified time. The date-time must be no later than two minutes before the request was submitted, in [ISO 8601](https://developer-docs.amazon.com/sp-api/docs/iso-8601) date time format.
        :param datetime posted_before: A date used for selecting financial events posted before (but not at) a specified time. The date-time must be later than PostedAfter and no later than two minutes before the request was submitted, in [ISO 8601](https://developer-docs.amazon.com/sp-api/docs/iso-8601) date time format. If PostedAfter and PostedBefore are more than 180 days apart, no financial events are returned. You must specify the PostedAfter parameter if you specify the PostedBefore parameter. Default: Now minus two minutes.
        :param str next_token: A string token returned in the response of your previous request.
        :return: ListFinancialEventsResponse
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['max_results_per_page', 'posted_after', 'posted_before', 'next_token']  # 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 list_financial_events" % key
                )
            params[key] = val
        del params['kwargs']

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

        path_params = {}

        query_params = []
        if 'max_results_per_page' in params:
            query_params.append(('MaxResultsPerPage', params['max_results_per_page']))  # noqa: E501
        if 'posted_after' in params:
            query_params.append(('PostedAfter', params['posted_after']))  # noqa: E501
        if 'posted_before' in params:
            query_params.append(('PostedBefore', params['posted_before']))  # noqa: E501
        if 'next_token' in params:
            query_params.append(('NextToken', params['next_token']))  # 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 = []  # noqa: E501

        return self.api_client.call_api(
            '/finances/v0/financialEvents', 'GET',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='ListFinancialEventsResponse',  # 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 list_financial_events_by_group_id(self, event_group_id, **kwargs):  # noqa: E501
        """list_financial_events_by_group_id  # noqa: E501

        Returns all financial events for the specified financial event group. It may take up to 48 hours for orders to appear in your financial events.  **Note:** This operation will only retrieve group's data for the past two years. If a request is submitted for data spanning more than two years, an empty response is returned.  **Usage Plan:**  | Rate (requests per second) | Burst | | ---- | ---- | | 0.5 | 30 |  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.list_financial_events_by_group_id(event_group_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str event_group_id: The identifier of the financial event group to which the events belong. (required)
        :param int max_results_per_page: The maximum number of results to return per page. If the response exceeds the maximum number of transactions or 10 MB, the API responds with 'InvalidInput'.
        :param datetime posted_after: A date used for selecting financial events posted after (or at) a specified time. The date-time **must** be more than two minutes before the time of the request, in [ISO 8601](https://developer-docs.amazon.com/sp-api/docs/iso-8601) date time format.
        :param datetime posted_before: A date used for selecting financial events posted before (but not at) a specified time. The date-time must be later than `PostedAfter` and no later than two minutes before the request was submitted, in [ISO 8601](https://developer-docs.amazon.com/sp-api/docs/iso-8601) date time format. If `PostedAfter` and `PostedBefore` are more than 180 days apart, no financial events are returned. You must specify the `PostedAfter` parameter if you specify the `PostedBefore` parameter. Default: Now minus two minutes.
        :param str next_token: A string token returned in the response of your previous request.
        :return: ListFinancialEventsResponse
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.list_financial_events_by_group_id_with_http_info(event_group_id, **kwargs)  # noqa: E501
        else:
            (data) = self.list_financial_events_by_group_id_with_http_info(event_group_id, **kwargs)  # noqa: E501
            return data

    def list_financial_events_by_group_id_with_http_info(self, event_group_id, **kwargs):  # noqa: E501
        """list_financial_events_by_group_id  # noqa: E501

        Returns all financial events for the specified financial event group. It may take up to 48 hours for orders to appear in your financial events.  **Note:** This operation will only retrieve group's data for the past two years. If a request is submitted for data spanning more than two years, an empty response is returned.  **Usage Plan:**  | Rate (requests per second) | Burst | | ---- | ---- | | 0.5 | 30 |  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.list_financial_events_by_group_id_with_http_info(event_group_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str event_group_id: The identifier of the financial event group to which the events belong. (required)
        :param int max_results_per_page: The maximum number of results to return per page. If the response exceeds the maximum number of transactions or 10 MB, the API responds with 'InvalidInput'.
        :param datetime posted_after: A date used for selecting financial events posted after (or at) a specified time. The date-time **must** be more than two minutes before the time of the request, in [ISO 8601](https://developer-docs.amazon.com/sp-api/docs/iso-8601) date time format.
        :param datetime posted_before: A date used for selecting financial events posted before (but not at) a specified time. The date-time must be later than `PostedAfter` and no later than two minutes before the request was submitted, in [ISO 8601](https://developer-docs.amazon.com/sp-api/docs/iso-8601) date time format. If `PostedAfter` and `PostedBefore` are more than 180 days apart, no financial events are returned. You must specify the `PostedAfter` parameter if you specify the `PostedBefore` parameter. Default: Now minus two minutes.
        :param str next_token: A string token returned in the response of your previous request.
        :return: ListFinancialEventsResponse
                 If the method is called asynchronously,
                 returns the request thread.
        """

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

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

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

        query_params = []
        if 'max_results_per_page' in params:
            query_params.append(('MaxResultsPerPage', params['max_results_per_page']))  # noqa: E501
        if 'posted_after' in params:
            query_params.append(('PostedAfter', params['posted_after']))  # noqa: E501
        if 'posted_before' in params:
            query_params.append(('PostedBefore', params['posted_before']))  # noqa: E501
        if 'next_token' in params:
            query_params.append(('NextToken', params['next_token']))  # 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 = []  # noqa: E501

        return self.api_client.call_api(
            '/finances/v0/financialEventGroups/{eventGroupId}/financialEvents', 'GET',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='ListFinancialEventsResponse',  # 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 list_financial_events_by_order_id(self, order_id, **kwargs):  # noqa: E501
        """list_financial_events_by_order_id  # noqa: E501

        Returns all financial events for the specified order. It may take up to 48 hours for orders to appear in your financial events.  **Usage Plan:**  | Rate (requests per second) | Burst | | ---- | ---- | | 0.5 | 30 |  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.list_financial_events_by_order_id(order_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str order_id: An Amazon-defined order identifier, in 3-7-7 format. (required)
        :param int max_results_per_page: The maximum number of results to return per page. If the response exceeds the maximum number of transactions or 10 MB, the API responds with 'InvalidInput'.
        :param str next_token: A string token returned in the response of your previous request.
        :return: ListFinancialEventsResponse
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.list_financial_events_by_order_id_with_http_info(order_id, **kwargs)  # noqa: E501
        else:
            (data) = self.list_financial_events_by_order_id_with_http_info(order_id, **kwargs)  # noqa: E501
            return data

    def list_financial_events_by_order_id_with_http_info(self, order_id, **kwargs):  # noqa: E501
        """list_financial_events_by_order_id  # noqa: E501

        Returns all financial events for the specified order. It may take up to 48 hours for orders to appear in your financial events.  **Usage Plan:**  | Rate (requests per second) | Burst | | ---- | ---- | | 0.5 | 30 |  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.list_financial_events_by_order_id_with_http_info(order_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str order_id: An Amazon-defined order identifier, in 3-7-7 format. (required)
        :param int max_results_per_page: The maximum number of results to return per page. If the response exceeds the maximum number of transactions or 10 MB, the API responds with 'InvalidInput'.
        :param str next_token: A string token returned in the response of your previous request.
        :return: ListFinancialEventsResponse
                 If the method is called asynchronously,
                 returns the request thread.
        """

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

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

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

        query_params = []
        if 'max_results_per_page' in params:
            query_params.append(('MaxResultsPerPage', params['max_results_per_page']))  # noqa: E501
        if 'next_token' in params:
            query_params.append(('NextToken', params['next_token']))  # 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 = []  # noqa: E501

        return self.api_client.call_api(
            '/finances/v0/orders/{orderId}/financialEvents', 'GET',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='ListFinancialEventsResponse',  # 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)
