# coding: utf-8

"""
Copyright 2017 Square, Inc.

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

        http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
"""


from __future__ import absolute_import

import sys
import os
import re

# python 2 and python 3 compatibility library
from six import iteritems

from ..api_client import ApiClient


class V1TransactionsApi(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_refund(self, location_id, body, **kwargs):
        """
        Issues a refund for a previously processed payment. You must issue a refund within 60 days of the associated payment.
        Issues a refund for a previously processed payment. You must issue a refund within 60 days of the associated payment.

        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please define a `callback` function
        to be invoked when receiving the response.
        >>> def callback_function(response):
        >>>     pprint(response)
        >>>
        >>> thread = api.create_refund(location_id, body, callback=callback_function)

        :param callback function: The callback function
            for asynchronous request. (optional)
        :param str location_id: The ID of the original payment's associated location. (required)
        :param V1CreateRefundRequest body: An object containing the fields to POST for the request.  See the corresponding object definition for field details. (required)
        :return: V1Refund
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['location_id', 'body']
        all_params.append('callback')

        params = locals()
        for key, val in iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method create_refund" % key
                )
            params[key] = val
        del params['kwargs']

        # verify the required parameter 'location_id' is set
        if ('location_id' not in params) or (params['location_id'] is None):
            raise ValueError("Missing the required parameter `location_id` when calling `create_refund`")
        # 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 `create_refund`")


        resource_path = '/v1/{location_id}/refunds'.replace('{format}', 'json')
        path_params = {}
        if 'location_id' in params:
            path_params['location_id'] = params['location_id']

        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'])
        if not header_params['Accept']:
            del header_params['Accept']

        # HTTP header `Content-Type`
        header_params['Content-Type'] = self.api_client.\
            select_header_content_type(['application/json'])

        # Authentication setting
        auth_settings = ['oauth2']

        return self.api_client.call_api(resource_path, 'POST',
                                            path_params,
                                            query_params,
                                            header_params,
                                            body=body_params,
                                            post_params=form_params,
                                            files=local_var_files,
                                            response_type='V1Refund',
                                            auth_settings=auth_settings,
                                            callback=params.get('callback'))
        

    def list_bank_accounts(self, location_id, **kwargs):
        """
        Provides non-confidential details for all of a location's associated bank accounts. This endpoint does not provide full bank account numbers, and there is no way to obtain a full bank account number with the Connect API.
        Provides non-confidential details for all of a location's associated bank accounts. This endpoint does not provide full bank account numbers, and there is no way to obtain a full bank account number with the Connect API.

        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please define a `callback` function
        to be invoked when receiving the response.
        >>> def callback_function(response):
        >>>     pprint(response)
        >>>
        >>> thread = api.list_bank_accounts(location_id, callback=callback_function)

        :param callback function: The callback function
            for asynchronous request. (optional)
        :param str location_id: The ID of the location to list bank accounts for. (required)
        :return: list[V1BankAccount]
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['location_id']
        all_params.append('callback')

        params = locals()
        for key, val in iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method list_bank_accounts" % key
                )
            params[key] = val
        del params['kwargs']

        # verify the required parameter 'location_id' is set
        if ('location_id' not in params) or (params['location_id'] is None):
            raise ValueError("Missing the required parameter `location_id` when calling `list_bank_accounts`")


        resource_path = '/v1/{location_id}/bank-accounts'.replace('{format}', 'json')
        path_params = {}
        if 'location_id' in params:
            path_params['location_id'] = params['location_id']

        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'])
        if not header_params['Accept']:
            del header_params['Accept']

        # HTTP header `Content-Type`
        header_params['Content-Type'] = self.api_client.\
            select_header_content_type(['application/json'])

        # Authentication setting
        auth_settings = ['oauth2']

        return self.api_client.call_api(resource_path, 'GET',
                                            path_params,
                                            query_params,
                                            header_params,
                                            body=body_params,
                                            post_params=form_params,
                                            files=local_var_files,
                                            response_type='list[V1BankAccount]',
                                            auth_settings=auth_settings,
                                            callback=params.get('callback'))
        

    def list_orders(self, location_id, **kwargs):
        """
        Provides summary information for a merchant's online store orders.
        Provides summary information for a merchant's online store orders.

        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please define a `callback` function
        to be invoked when receiving the response.
        >>> def callback_function(response):
        >>>     pprint(response)
        >>>
        >>> thread = api.list_orders(location_id, callback=callback_function)

        :param callback function: The callback function
            for asynchronous request. (optional)
        :param str location_id: The ID of the location to list online store orders for. (required)
        :param str order: TThe order in which payments are listed in the response.
        :param int limit: The maximum number of payments to return in a single response. This value cannot exceed 200.
        :param str batch_token: A pagination cursor to retrieve the next set of results for your original query to the endpoint.
        :return: list[V1Order]
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['location_id', 'order', 'limit', 'batch_token']
        all_params.append('callback')

        params = locals()
        for key, val in iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method list_orders" % key
                )
            params[key] = val
        del params['kwargs']

        # verify the required parameter 'location_id' is set
        if ('location_id' not in params) or (params['location_id'] is None):
            raise ValueError("Missing the required parameter `location_id` when calling `list_orders`")

        if 'limit' in params and params['limit'] > 200:
            raise ValueError("Invalid value for parameter `limit` when calling `list_orders`, must be a value less than or equal to  `200`")

        resource_path = '/v1/{location_id}/orders'.replace('{format}', 'json')
        path_params = {}
        if 'location_id' in params:
            path_params['location_id'] = params['location_id']

        query_params = {}
        if 'order' in params and params['order'] is not None:
            query_params['order'] = params['order']
        if 'limit' in params and params['limit'] is not None:
            query_params['limit'] = params['limit']
        if 'batch_token' in params and params['batch_token'] is not None:
            query_params['batch_token'] = params['batch_token']

        header_params = {}
        form_params = []
        local_var_files = {}

        body_params = None

        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.\
            select_header_accept(['application/json'])
        if not header_params['Accept']:
            del header_params['Accept']

        # HTTP header `Content-Type`
        header_params['Content-Type'] = self.api_client.\
            select_header_content_type(['application/json'])

        # Authentication setting
        auth_settings = ['oauth2']

        return self.api_client.call_api(resource_path, 'GET',
                                            path_params,
                                            query_params,
                                            header_params,
                                            body=body_params,
                                            post_params=form_params,
                                            files=local_var_files,
                                            response_type='list[V1Order]',
                                            auth_settings=auth_settings,
                                            callback=params.get('callback'))
        

    def list_payments(self, location_id, **kwargs):
        """
        Provides summary information for all payments taken by a merchant or any of the merchant's mobile staff during a date range. Date ranges cannot exceed one year in length. See Date ranges for details of inclusive and exclusive dates.
        Provides summary information for all payments taken by a merchant or any of the merchant's mobile staff during a date range. Date ranges cannot exceed one year in length. See Date ranges for details of inclusive and exclusive dates.

        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please define a `callback` function
        to be invoked when receiving the response.
        >>> def callback_function(response):
        >>>     pprint(response)
        >>>
        >>> thread = api.list_payments(location_id, callback=callback_function)

        :param callback function: The callback function
            for asynchronous request. (optional)
        :param str location_id: The ID of the location to list payments for. If you specify me, this endpoint returns payments aggregated from all of the business's locations. (required)
        :param str order: The order in which payments are listed in the response.
        :param str begin_time: The beginning of the requested reporting period, in ISO 8601 format. If this value is before January 1, 2013 (2013-01-01T00:00:00Z), this endpoint returns an error. Default value: The current time minus one year.
        :param str end_time: The end of the requested reporting period, in ISO 8601 format. If this value is more than one year greater than begin_time, this endpoint returns an error. Default value: The current time.
        :param int limit: The maximum number of payments to return in a single response. This value cannot exceed 200.
        :param str batch_token: A pagination cursor to retrieve the next set of results for your original query to the endpoint.
        :param bool include_partial: Indicates whether or not to include partial payments in the response. Partial payments will have the tenders collected so far, but the itemizations will be empty until the payment is completed.
        :return: list[V1Payment]
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['location_id', 'order', 'begin_time', 'end_time', 'limit', 'batch_token', 'include_partial']
        all_params.append('callback')

        params = locals()
        for key, val in iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method list_payments" % key
                )
            params[key] = val
        del params['kwargs']

        # verify the required parameter 'location_id' is set
        if ('location_id' not in params) or (params['location_id'] is None):
            raise ValueError("Missing the required parameter `location_id` when calling `list_payments`")

        if 'limit' in params and params['limit'] > 200:
            raise ValueError("Invalid value for parameter `limit` when calling `list_payments`, must be a value less than or equal to  `200`")

        resource_path = '/v1/{location_id}/payments'.replace('{format}', 'json')
        path_params = {}
        if 'location_id' in params:
            path_params['location_id'] = params['location_id']

        query_params = {}
        if 'order' in params and params['order'] is not None:
            query_params['order'] = params['order']
        if 'begin_time' in params and params['begin_time'] is not None:
            query_params['begin_time'] = params['begin_time']
        if 'end_time' in params and params['end_time'] is not None:
            query_params['end_time'] = params['end_time']
        if 'limit' in params and params['limit'] is not None:
            query_params['limit'] = params['limit']
        if 'batch_token' in params and params['batch_token'] is not None:
            query_params['batch_token'] = params['batch_token']
        if 'include_partial' in params and params['include_partial'] is not None:
            query_params['include_partial'] = params['include_partial']

        header_params = {}
        form_params = []
        local_var_files = {}

        body_params = None

        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.\
            select_header_accept(['application/json'])
        if not header_params['Accept']:
            del header_params['Accept']

        # HTTP header `Content-Type`
        header_params['Content-Type'] = self.api_client.\
            select_header_content_type(['application/json'])

        # Authentication setting
        auth_settings = ['oauth2']

        return self.api_client.call_api(resource_path, 'GET',
                                            path_params,
                                            query_params,
                                            header_params,
                                            body=body_params,
                                            post_params=form_params,
                                            files=local_var_files,
                                            response_type='list[V1Payment]',
                                            auth_settings=auth_settings,
                                            callback=params.get('callback'))
        

    def list_refunds(self, location_id, **kwargs):
        """
        Provides the details for all refunds initiated by a merchant or any of the merchant's mobile staff during a date range. Date ranges cannot exceed one year in length.
        Provides the details for all refunds initiated by a merchant or any of the merchant's mobile staff during a date range. Date ranges cannot exceed one year in length.

        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please define a `callback` function
        to be invoked when receiving the response.
        >>> def callback_function(response):
        >>>     pprint(response)
        >>>
        >>> thread = api.list_refunds(location_id, callback=callback_function)

        :param callback function: The callback function
            for asynchronous request. (optional)
        :param str location_id: The ID of the location to list refunds for. (required)
        :param str order: TThe order in which payments are listed in the response.
        :param str begin_time: The beginning of the requested reporting period, in ISO 8601 format. If this value is before January 1, 2013 (2013-01-01T00:00:00Z), this endpoint returns an error. Default value: The current time minus one year.
        :param str end_time: The end of the requested reporting period, in ISO 8601 format. If this value is more than one year greater than begin_time, this endpoint returns an error. Default value: The current time.
        :param int limit: The approximate number of refunds to return in a single response. Default: 100. Max: 200. Response may contain more results than the prescribed limit when refunds are made simultaneously to multiple tenders in a payment or when refunds are generated in an exchange to account for the value of returned goods.
        :param str batch_token: A pagination cursor to retrieve the next set of results for your original query to the endpoint.
        :return: list[V1Refund]
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['location_id', 'order', 'begin_time', 'end_time', 'limit', 'batch_token']
        all_params.append('callback')

        params = locals()
        for key, val in iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method list_refunds" % key
                )
            params[key] = val
        del params['kwargs']

        # verify the required parameter 'location_id' is set
        if ('location_id' not in params) or (params['location_id'] is None):
            raise ValueError("Missing the required parameter `location_id` when calling `list_refunds`")

        if 'limit' in params and params['limit'] > 200:
            raise ValueError("Invalid value for parameter `limit` when calling `list_refunds`, must be a value less than or equal to  `200`")

        resource_path = '/v1/{location_id}/refunds'.replace('{format}', 'json')
        path_params = {}
        if 'location_id' in params:
            path_params['location_id'] = params['location_id']

        query_params = {}
        if 'order' in params and params['order'] is not None:
            query_params['order'] = params['order']
        if 'begin_time' in params and params['begin_time'] is not None:
            query_params['begin_time'] = params['begin_time']
        if 'end_time' in params and params['end_time'] is not None:
            query_params['end_time'] = params['end_time']
        if 'limit' in params and params['limit'] is not None:
            query_params['limit'] = params['limit']
        if 'batch_token' in params and params['batch_token'] is not None:
            query_params['batch_token'] = params['batch_token']

        header_params = {}
        form_params = []
        local_var_files = {}

        body_params = None

        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.\
            select_header_accept(['application/json'])
        if not header_params['Accept']:
            del header_params['Accept']

        # HTTP header `Content-Type`
        header_params['Content-Type'] = self.api_client.\
            select_header_content_type(['application/json'])

        # Authentication setting
        auth_settings = ['oauth2']

        return self.api_client.call_api(resource_path, 'GET',
                                            path_params,
                                            query_params,
                                            header_params,
                                            body=body_params,
                                            post_params=form_params,
                                            files=local_var_files,
                                            response_type='list[V1Refund]',
                                            auth_settings=auth_settings,
                                            callback=params.get('callback'))
        

    def list_settlements(self, location_id, **kwargs):
        """
        Provides summary information for all deposits and withdrawals initiated by Square to a merchant's bank account during a date range. Date ranges cannot exceed one year in length.
        Provides summary information for all deposits and withdrawals initiated by Square to a merchant's bank account during a date range. Date ranges cannot exceed one year in length. 

        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please define a `callback` function
        to be invoked when receiving the response.
        >>> def callback_function(response):
        >>>     pprint(response)
        >>>
        >>> thread = api.list_settlements(location_id, callback=callback_function)

        :param callback function: The callback function
            for asynchronous request. (optional)
        :param str location_id: The ID of the location to list settlements for. If you specify me, this endpoint returns payments aggregated from all of the business's locations. (required)
        :param str order: TThe order in which payments are listed in the response.
        :param str begin_time: The beginning of the requested reporting period, in ISO 8601 format. If this value is before January 1, 2013 (2013-01-01T00:00:00Z), this endpoint returns an error. Default value: The current time minus one year.
        :param str end_time: The end of the requested reporting period, in ISO 8601 format. If this value is more than one year greater than begin_time, this endpoint returns an error. Default value: The current time.
        :param int limit: The maximum number of payments to return in a single response. This value cannot exceed 200.
        :param str status: Provide this parameter to retrieve only settlements with a particular status (SENT or FAILED).
        :param str batch_token: A pagination cursor to retrieve the next set of results for your original query to the endpoint.
        :return: list[V1Settlement]
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['location_id', 'order', 'begin_time', 'end_time', 'limit', 'status', 'batch_token']
        all_params.append('callback')

        params = locals()
        for key, val in iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method list_settlements" % key
                )
            params[key] = val
        del params['kwargs']

        # verify the required parameter 'location_id' is set
        if ('location_id' not in params) or (params['location_id'] is None):
            raise ValueError("Missing the required parameter `location_id` when calling `list_settlements`")

        if 'limit' in params and params['limit'] > 200:
            raise ValueError("Invalid value for parameter `limit` when calling `list_settlements`, must be a value less than or equal to  `200`")

        resource_path = '/v1/{location_id}/settlements'.replace('{format}', 'json')
        path_params = {}
        if 'location_id' in params:
            path_params['location_id'] = params['location_id']

        query_params = {}
        if 'order' in params and params['order'] is not None:
            query_params['order'] = params['order']
        if 'begin_time' in params and params['begin_time'] is not None:
            query_params['begin_time'] = params['begin_time']
        if 'end_time' in params and params['end_time'] is not None:
            query_params['end_time'] = params['end_time']
        if 'limit' in params and params['limit'] is not None:
            query_params['limit'] = params['limit']
        if 'status' in params and params['status'] is not None:
            query_params['status'] = params['status']
        if 'batch_token' in params and params['batch_token'] is not None:
            query_params['batch_token'] = params['batch_token']

        header_params = {}
        form_params = []
        local_var_files = {}

        body_params = None

        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.\
            select_header_accept(['application/json'])
        if not header_params['Accept']:
            del header_params['Accept']

        # HTTP header `Content-Type`
        header_params['Content-Type'] = self.api_client.\
            select_header_content_type(['application/json'])

        # Authentication setting
        auth_settings = ['oauth2']

        return self.api_client.call_api(resource_path, 'GET',
                                            path_params,
                                            query_params,
                                            header_params,
                                            body=body_params,
                                            post_params=form_params,
                                            files=local_var_files,
                                            response_type='list[V1Settlement]',
                                            auth_settings=auth_settings,
                                            callback=params.get('callback'))
        

    def retrieve_bank_account(self, location_id, bank_account_id, **kwargs):
        """
        Provides non-confidential details for a merchant's associated bank account. This endpoint does not provide full bank account numbers, and there is no way to obtain a full bank account number with the Connect API.
        Provides non-confidential details for a merchant's associated bank account. This endpoint does not provide full bank account numbers, and there is no way to obtain a full bank account number with the Connect API.

        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please define a `callback` function
        to be invoked when receiving the response.
        >>> def callback_function(response):
        >>>     pprint(response)
        >>>
        >>> thread = api.retrieve_bank_account(location_id, bank_account_id, callback=callback_function)

        :param callback function: The callback function
            for asynchronous request. (optional)
        :param str location_id: The ID of the bank account's associated location. (required)
        :param str bank_account_id: The bank account's Square-issued ID. You obtain this value from Settlement objects returned. (required)
        :return: V1BankAccount
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['location_id', 'bank_account_id']
        all_params.append('callback')

        params = locals()
        for key, val in iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method retrieve_bank_account" % key
                )
            params[key] = val
        del params['kwargs']

        # verify the required parameter 'location_id' is set
        if ('location_id' not in params) or (params['location_id'] is None):
            raise ValueError("Missing the required parameter `location_id` when calling `retrieve_bank_account`")
        # verify the required parameter 'bank_account_id' is set
        if ('bank_account_id' not in params) or (params['bank_account_id'] is None):
            raise ValueError("Missing the required parameter `bank_account_id` when calling `retrieve_bank_account`")


        resource_path = '/v1/{location_id}/bank-accounts/{bank_account_id}'.replace('{format}', 'json')
        path_params = {}
        if 'location_id' in params:
            path_params['location_id'] = params['location_id']
        if 'bank_account_id' in params:
            path_params['bank_account_id'] = params['bank_account_id']

        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'])
        if not header_params['Accept']:
            del header_params['Accept']

        # HTTP header `Content-Type`
        header_params['Content-Type'] = self.api_client.\
            select_header_content_type(['application/json'])

        # Authentication setting
        auth_settings = ['oauth2']

        return self.api_client.call_api(resource_path, 'GET',
                                            path_params,
                                            query_params,
                                            header_params,
                                            body=body_params,
                                            post_params=form_params,
                                            files=local_var_files,
                                            response_type='V1BankAccount',
                                            auth_settings=auth_settings,
                                            callback=params.get('callback'))
        

    def retrieve_order(self, location_id, order_id, **kwargs):
        """
        Provides comprehensive information for a single online store order, including the order's history.
        Provides comprehensive information for a single online store order, including the order's history.

        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please define a `callback` function
        to be invoked when receiving the response.
        >>> def callback_function(response):
        >>>     pprint(response)
        >>>
        >>> thread = api.retrieve_order(location_id, order_id, callback=callback_function)

        :param callback function: The callback function
            for asynchronous request. (optional)
        :param str location_id: The ID of the order's associated location. (required)
        :param str order_id: The order's Square-issued ID. You obtain this value from Order objects returned by the List Orders endpoint (required)
        :return: V1Order
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['location_id', 'order_id']
        all_params.append('callback')

        params = locals()
        for key, val in iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method retrieve_order" % key
                )
            params[key] = val
        del params['kwargs']

        # verify the required parameter 'location_id' is set
        if ('location_id' not in params) or (params['location_id'] is None):
            raise ValueError("Missing the required parameter `location_id` when calling `retrieve_order`")
        # verify the required parameter 'order_id' is set
        if ('order_id' not in params) or (params['order_id'] is None):
            raise ValueError("Missing the required parameter `order_id` when calling `retrieve_order`")


        resource_path = '/v1/{location_id}/orders/{order_id}'.replace('{format}', 'json')
        path_params = {}
        if 'location_id' in params:
            path_params['location_id'] = params['location_id']
        if 'order_id' in params:
            path_params['order_id'] = params['order_id']

        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'])
        if not header_params['Accept']:
            del header_params['Accept']

        # HTTP header `Content-Type`
        header_params['Content-Type'] = self.api_client.\
            select_header_content_type(['application/json'])

        # Authentication setting
        auth_settings = ['oauth2']

        return self.api_client.call_api(resource_path, 'GET',
                                            path_params,
                                            query_params,
                                            header_params,
                                            body=body_params,
                                            post_params=form_params,
                                            files=local_var_files,
                                            response_type='V1Order',
                                            auth_settings=auth_settings,
                                            callback=params.get('callback'))
        

    def retrieve_payment(self, location_id, payment_id, **kwargs):
        """
        Provides comprehensive information for a single payment.
        Provides comprehensive information for a single payment.

        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please define a `callback` function
        to be invoked when receiving the response.
        >>> def callback_function(response):
        >>>     pprint(response)
        >>>
        >>> thread = api.retrieve_payment(location_id, payment_id, callback=callback_function)

        :param callback function: The callback function
            for asynchronous request. (optional)
        :param str location_id: The ID of the payment's associated location. (required)
        :param str payment_id: The Square-issued payment ID. payment_id comes from Payment objects returned by the List Payments endpoint, Settlement objects returned by the List Settlements endpoint, or Refund objects returned by the List Refunds endpoint. (required)
        :return: V1Payment
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['location_id', 'payment_id']
        all_params.append('callback')

        params = locals()
        for key, val in iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method retrieve_payment" % key
                )
            params[key] = val
        del params['kwargs']

        # verify the required parameter 'location_id' is set
        if ('location_id' not in params) or (params['location_id'] is None):
            raise ValueError("Missing the required parameter `location_id` when calling `retrieve_payment`")
        # verify the required parameter 'payment_id' is set
        if ('payment_id' not in params) or (params['payment_id'] is None):
            raise ValueError("Missing the required parameter `payment_id` when calling `retrieve_payment`")


        resource_path = '/v1/{location_id}/payments/{payment_id}'.replace('{format}', 'json')
        path_params = {}
        if 'location_id' in params:
            path_params['location_id'] = params['location_id']
        if 'payment_id' in params:
            path_params['payment_id'] = params['payment_id']

        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'])
        if not header_params['Accept']:
            del header_params['Accept']

        # HTTP header `Content-Type`
        header_params['Content-Type'] = self.api_client.\
            select_header_content_type(['application/json'])

        # Authentication setting
        auth_settings = ['oauth2']

        return self.api_client.call_api(resource_path, 'GET',
                                            path_params,
                                            query_params,
                                            header_params,
                                            body=body_params,
                                            post_params=form_params,
                                            files=local_var_files,
                                            response_type='V1Payment',
                                            auth_settings=auth_settings,
                                            callback=params.get('callback'))
        

    def retrieve_settlement(self, location_id, settlement_id, **kwargs):
        """
        Provides comprehensive information for a single settlement, including the entries that contribute to the settlement's total.
        Provides comprehensive information for a single settlement, including the entries that contribute to the settlement's total.

        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please define a `callback` function
        to be invoked when receiving the response.
        >>> def callback_function(response):
        >>>     pprint(response)
        >>>
        >>> thread = api.retrieve_settlement(location_id, settlement_id, callback=callback_function)

        :param callback function: The callback function
            for asynchronous request. (optional)
        :param str location_id: The ID of the settlements's associated location. (required)
        :param str settlement_id: The settlement's Square-issued ID. You obtain this value from Settlement objects returned by the List Settlements endpoint. (required)
        :return: V1Settlement
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['location_id', 'settlement_id']
        all_params.append('callback')

        params = locals()
        for key, val in iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method retrieve_settlement" % key
                )
            params[key] = val
        del params['kwargs']

        # verify the required parameter 'location_id' is set
        if ('location_id' not in params) or (params['location_id'] is None):
            raise ValueError("Missing the required parameter `location_id` when calling `retrieve_settlement`")
        # verify the required parameter 'settlement_id' is set
        if ('settlement_id' not in params) or (params['settlement_id'] is None):
            raise ValueError("Missing the required parameter `settlement_id` when calling `retrieve_settlement`")


        resource_path = '/v1/{location_id}/settlements/{settlement_id}'.replace('{format}', 'json')
        path_params = {}
        if 'location_id' in params:
            path_params['location_id'] = params['location_id']
        if 'settlement_id' in params:
            path_params['settlement_id'] = params['settlement_id']

        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'])
        if not header_params['Accept']:
            del header_params['Accept']

        # HTTP header `Content-Type`
        header_params['Content-Type'] = self.api_client.\
            select_header_content_type(['application/json'])

        # Authentication setting
        auth_settings = ['oauth2']

        return self.api_client.call_api(resource_path, 'GET',
                                            path_params,
                                            query_params,
                                            header_params,
                                            body=body_params,
                                            post_params=form_params,
                                            files=local_var_files,
                                            response_type='V1Settlement',
                                            auth_settings=auth_settings,
                                            callback=params.get('callback'))
        

    def update_order(self, location_id, order_id, body, **kwargs):
        """
        Updates the details of an online store order. Every update you perform on an order corresponds to one of three actions:
        Updates the details of an online store order. Every update you perform on an order corresponds to one of three actions:

        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please define a `callback` function
        to be invoked when receiving the response.
        >>> def callback_function(response):
        >>>     pprint(response)
        >>>
        >>> thread = api.update_order(location_id, order_id, body, callback=callback_function)

        :param callback function: The callback function
            for asynchronous request. (optional)
        :param str location_id: The ID of the order's associated location. (required)
        :param str order_id: The order's Square-issued ID. You obtain this value from Order objects returned by the List Orders endpoint (required)
        :param V1UpdateOrderRequest body: An object containing the fields to POST for the request.  See the corresponding object definition for field details. (required)
        :return: V1Order
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['location_id', 'order_id', 'body']
        all_params.append('callback')

        params = locals()
        for key, val in iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method update_order" % key
                )
            params[key] = val
        del params['kwargs']

        # verify the required parameter 'location_id' is set
        if ('location_id' not in params) or (params['location_id'] is None):
            raise ValueError("Missing the required parameter `location_id` when calling `update_order`")
        # verify the required parameter 'order_id' is set
        if ('order_id' not in params) or (params['order_id'] is None):
            raise ValueError("Missing the required parameter `order_id` when calling `update_order`")
        # 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 `update_order`")


        resource_path = '/v1/{location_id}/orders/{order_id}'.replace('{format}', 'json')
        path_params = {}
        if 'location_id' in params:
            path_params['location_id'] = params['location_id']
        if 'order_id' in params:
            path_params['order_id'] = params['order_id']

        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'])
        if not header_params['Accept']:
            del header_params['Accept']

        # HTTP header `Content-Type`
        header_params['Content-Type'] = self.api_client.\
            select_header_content_type(['application/json'])

        # Authentication setting
        auth_settings = ['oauth2']

        return self.api_client.call_api(resource_path, 'PUT',
                                            path_params,
                                            query_params,
                                            header_params,
                                            body=body_params,
                                            post_params=form_params,
                                            files=local_var_files,
                                            response_type='V1Order',
                                            auth_settings=auth_settings,
                                            callback=params.get('callback'))
        
