# coding: utf-8

"""
    The Selling Partner API for Amazon External Fulfillment Shipments Processing

    You can use the External Fulfillment Shipments API to retrieve, manage, and track shipments processed through Amazon's external fulfillment network. Use this API to get shipment details, monitor status changes, and access fulfillment requirements.

    The version of the OpenAPI document: 2024-09-11
    Contact: marketplaceapitest@amazon.com
    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 ShipmentProcessingApi(object):
    """NOTE: This class is auto generated by the openapi generator.

    Do not edit the class manually.
    """

    api_models_module = "spapi.models.external_fulfillment_shipments_v2024_09_11"

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

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

        Provide details about the packages in the specified shipment.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.create_packages(shipment_id, body, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str shipment_id: The ID of the shipment. (required)
        :param Packages body: A list of packages in the shipment. (required)
        :return: None
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.create_packages_with_http_info(shipment_id, body, **kwargs)  # noqa: E501
        else:
            (data) = self.create_packages_with_http_info(shipment_id, body, **kwargs)  # noqa: E501
            return data

    def create_packages_with_http_info(self, shipment_id, body, **kwargs):  # noqa: E501
        """create_packages  # noqa: E501

        Provide details about the packages in the specified shipment.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.create_packages_with_http_info(shipment_id, body, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str shipment_id: The ID of the shipment. (required)
        :param Packages body: A list of packages in the shipment. (required)
        :return: None
                 If the method is called asynchronously,
                 returns the request thread.
        """

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

        collection_formats = {}

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

        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(
            '/externalFulfillment/2024-09-11/shipments/{shipmentId}/packages', 'POST',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type=None,  # 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 generate_invoice(self, shipment_id, **kwargs):  # noqa: E501
        """generate_invoice  # noqa: E501

        Get invoices for the shipment you specify.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.generate_invoice(shipment_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str shipment_id: The ID of the shipment whose invoice you want. (required)
        :return: InvoiceResponse
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.generate_invoice_with_http_info(shipment_id, **kwargs)  # noqa: E501
        else:
            (data) = self.generate_invoice_with_http_info(shipment_id, **kwargs)  # noqa: E501
            return data

    def generate_invoice_with_http_info(self, shipment_id, **kwargs):  # noqa: E501
        """generate_invoice  # noqa: E501

        Get invoices for the shipment you specify.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.generate_invoice_with_http_info(shipment_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str shipment_id: The ID of the shipment whose invoice you want. (required)
        :return: InvoiceResponse
                 If the method is called asynchronously,
                 returns the request thread.
        """

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

        collection_formats = {}

        path_params = {}
        if 'shipment_id' in params:
            path_params['shipmentId'] = params['shipment_id']  # 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(
            '/externalFulfillment/2024-09-11/shipments/{shipmentId}/invoice', 'POST',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='InvoiceResponse',  # 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 generate_ship_labels(self, shipment_id, operation, **kwargs):  # noqa: E501
        """generate_ship_labels  # noqa: E501

        Generate and retrieve all shipping labels for one or more packages in the shipment you specify.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.generate_ship_labels(shipment_id, operation, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str shipment_id: The ID of the shipment whose shipping labels you want to generate and retrieve. (required)
        :param str operation: Specify whether you want to generate or regenerate a label. (required)
        :param str shipping_option_id: The ID of the shipping option whose shipping labels you want.
        :param ShipLabelsInput body: Shipping details for when shipping is not done by the marketplace channel.
        :return: ShipLabelsResponse
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.generate_ship_labels_with_http_info(shipment_id, operation, **kwargs)  # noqa: E501
        else:
            (data) = self.generate_ship_labels_with_http_info(shipment_id, operation, **kwargs)  # noqa: E501
            return data

    def generate_ship_labels_with_http_info(self, shipment_id, operation, **kwargs):  # noqa: E501
        """generate_ship_labels  # noqa: E501

        Generate and retrieve all shipping labels for one or more packages in the shipment you specify.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.generate_ship_labels_with_http_info(shipment_id, operation, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str shipment_id: The ID of the shipment whose shipping labels you want to generate and retrieve. (required)
        :param str operation: Specify whether you want to generate or regenerate a label. (required)
        :param str shipping_option_id: The ID of the shipping option whose shipping labels you want.
        :param ShipLabelsInput body: Shipping details for when shipping is not done by the marketplace channel.
        :return: ShipLabelsResponse
                 If the method is called asynchronously,
                 returns the request thread.
        """

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

        collection_formats = {}

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

        query_params = []
        if 'shipping_option_id' in params:
            query_params.append(('shippingOptionId', params['shipping_option_id']))  # noqa: E501
        if 'operation' in params:
            query_params.append(('operation', params['operation']))  # noqa: E501

        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(
            '/externalFulfillment/2024-09-11/shipments/{shipmentId}/shipLabels', 'PUT',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='ShipLabelsResponse',  # 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 process_shipment(self, shipment_id, operation, **kwargs):  # noqa: E501
        """process_shipment  # noqa: E501

        Confirm or reject the specified shipment.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.process_shipment(shipment_id, operation, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str shipment_id: The ID of the shipment you want to confirm or reject. (required)
        :param str operation: The status of the shipment. (required)
        :param ShipmentAcknowledgementRequest body: Information about the shipment and its line items.
        :return: None
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.process_shipment_with_http_info(shipment_id, operation, **kwargs)  # noqa: E501
        else:
            (data) = self.process_shipment_with_http_info(shipment_id, operation, **kwargs)  # noqa: E501
            return data

    def process_shipment_with_http_info(self, shipment_id, operation, **kwargs):  # noqa: E501
        """process_shipment  # noqa: E501

        Confirm or reject the specified shipment.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.process_shipment_with_http_info(shipment_id, operation, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str shipment_id: The ID of the shipment you want to confirm or reject. (required)
        :param str operation: The status of the shipment. (required)
        :param ShipmentAcknowledgementRequest body: Information about the shipment and its line items.
        :return: None
                 If the method is called asynchronously,
                 returns the request thread.
        """

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

        collection_formats = {}

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

        query_params = []
        if 'operation' in params:
            query_params.append(('operation', params['operation']))  # noqa: E501

        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(
            '/externalFulfillment/2024-09-11/shipments/{shipmentId}', 'POST',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type=None,  # 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 retrieve_invoice(self, shipment_id, **kwargs):  # noqa: E501
        """retrieve_invoice  # noqa: E501

        Retrieve invoices for the shipment you specify.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.retrieve_invoice(shipment_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str shipment_id: The ID of the shipment whose invoice you want to retrieve. (required)
        :return: InvoiceResponse
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.retrieve_invoice_with_http_info(shipment_id, **kwargs)  # noqa: E501
        else:
            (data) = self.retrieve_invoice_with_http_info(shipment_id, **kwargs)  # noqa: E501
            return data

    def retrieve_invoice_with_http_info(self, shipment_id, **kwargs):  # noqa: E501
        """retrieve_invoice  # noqa: E501

        Retrieve invoices for the shipment you specify.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.retrieve_invoice_with_http_info(shipment_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str shipment_id: The ID of the shipment whose invoice you want to retrieve. (required)
        :return: InvoiceResponse
                 If the method is called asynchronously,
                 returns the request thread.
        """

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

        collection_formats = {}

        path_params = {}
        if 'shipment_id' in params:
            path_params['shipmentId'] = params['shipment_id']  # 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(
            '/externalFulfillment/2024-09-11/shipments/{shipmentId}/invoice', 'GET',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='InvoiceResponse',  # 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 retrieve_shipping_options(self, shipment_id, package_id, **kwargs):  # noqa: E501
        """retrieve_shipping_options  # noqa: E501

        Get a list of shipping options for a package in a shipment given the shipment's marketplace and channel. If the marketplace and channel have a pre-determined shipping option, then this operation returns an empty response.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.retrieve_shipping_options(shipment_id, package_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str shipment_id: The ID of the shipment to which the package belongs. (required)
        :param str package_id: The ID of the package for which you want to retrieve shipping options. (required)
        :return: ShippingOptionsResponse
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.retrieve_shipping_options_with_http_info(shipment_id, package_id, **kwargs)  # noqa: E501
        else:
            (data) = self.retrieve_shipping_options_with_http_info(shipment_id, package_id, **kwargs)  # noqa: E501
            return data

    def retrieve_shipping_options_with_http_info(self, shipment_id, package_id, **kwargs):  # noqa: E501
        """retrieve_shipping_options  # noqa: E501

        Get a list of shipping options for a package in a shipment given the shipment's marketplace and channel. If the marketplace and channel have a pre-determined shipping option, then this operation returns an empty response.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.retrieve_shipping_options_with_http_info(shipment_id, package_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str shipment_id: The ID of the shipment to which the package belongs. (required)
        :param str package_id: The ID of the package for which you want to retrieve shipping options. (required)
        :return: ShippingOptionsResponse
                 If the method is called asynchronously,
                 returns the request thread.
        """

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

        collection_formats = {}

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

        query_params = []
        if 'package_id' in params:
            query_params.append(('packageId', params['package_id']))  # 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(
            '/externalFulfillment/2024-09-11/shipments/{shipmentId}/shippingOptions', 'GET',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='ShippingOptionsResponse',  # 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 update_package(self, shipment_id, package_id, body, **kwargs):  # noqa: E501
        """update_package  # noqa: E501

        Updates the details about the packages that will be used to fulfill the specified shipment.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.update_package(shipment_id, package_id, body, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str shipment_id: The ID of the shipment to which the package belongs. (required)
        :param str package_id: The ID of the package whose information you want to update. (required)
        :param Package body: The body of the request. (required)
        :return: None
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.update_package_with_http_info(shipment_id, package_id, body, **kwargs)  # noqa: E501
        else:
            (data) = self.update_package_with_http_info(shipment_id, package_id, body, **kwargs)  # noqa: E501
            return data

    def update_package_with_http_info(self, shipment_id, package_id, body, **kwargs):  # noqa: E501
        """update_package  # noqa: E501

        Updates the details about the packages that will be used to fulfill the specified shipment.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.update_package_with_http_info(shipment_id, package_id, body, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str shipment_id: The ID of the shipment to which the package belongs. (required)
        :param str package_id: The ID of the package whose information you want to update. (required)
        :param Package body: The body of the request. (required)
        :return: None
                 If the method is called asynchronously,
                 returns the request thread.
        """

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

        collection_formats = {}

        path_params = {}
        if 'shipment_id' in params:
            path_params['shipmentId'] = params['shipment_id']  # noqa: E501
        if 'package_id' in params:
            path_params['packageId'] = params['package_id']  # noqa: E501

        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(
            '/externalFulfillment/2024-09-11/shipments/{shipmentId}/packages/{packageId}', 'PUT',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type=None,  # 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 update_package_status(self, shipment_id, package_id, **kwargs):  # noqa: E501
        """update_package_status  # noqa: E501

        Updates the status of the packages.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.update_package_status(shipment_id, package_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str shipment_id: The ID of the shipment to which the package belongs. (required)
        :param str package_id: The ID of the package whose status you want to update. (required)
        :param str status: **DEPRECATED**. Do not use. Package status is defined in the body parameter.
        :param PackageDeliveryStatus body: The body of the request.
        :return: None
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.update_package_status_with_http_info(shipment_id, package_id, **kwargs)  # noqa: E501
        else:
            (data) = self.update_package_status_with_http_info(shipment_id, package_id, **kwargs)  # noqa: E501
            return data

    def update_package_status_with_http_info(self, shipment_id, package_id, **kwargs):  # noqa: E501
        """update_package_status  # noqa: E501

        Updates the status of the packages.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.update_package_status_with_http_info(shipment_id, package_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str shipment_id: The ID of the shipment to which the package belongs. (required)
        :param str package_id: The ID of the package whose status you want to update. (required)
        :param str status: **DEPRECATED**. Do not use. Package status is defined in the body parameter.
        :param PackageDeliveryStatus body: The body of the request.
        :return: None
                 If the method is called asynchronously,
                 returns the request thread.
        """

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

        collection_formats = {}

        path_params = {}
        if 'shipment_id' in params:
            path_params['shipmentId'] = params['shipment_id']  # noqa: E501
        if 'package_id' in params:
            path_params['packageId'] = params['package_id']  # noqa: E501

        query_params = []
        if 'status' in params:
            query_params.append(('status', params['status']))  # noqa: E501

        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(
            '/externalFulfillment/2024-09-11/shipments/{shipmentId}/packages/{packageId}', 'PATCH',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type=None,  # 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)
