"""visaacceptancemergedspec.

This file was automatically generated by APIMATIC v3.0 ( https://www.apimatic.io ).
"""

# ruff: noqa: D410, E501, E101, D206
from apimatic_core.authentication.multiple.and_auth_group import (
    And,
)
from apimatic_core.authentication.multiple.single_auth import (
    Single,
)
from apimatic_core.request_builder import RequestBuilder
from apimatic_core.response_handler import ResponseHandler
from apimatic_core.types.parameter import Parameter

from visaacceptancemergedspec.api_helper import (
    APIHelper,
)
from visaacceptancemergedspec.apis.base_api import (
    BaseApi,
)
from visaacceptancemergedspec.configuration import (
    Server,
)
from visaacceptancemergedspec.exceptions.delete_customer_shipping_address_exception_1_exception import (  # noqa: E501
    DeleteCustomerShippingAddressException1Exception,
)
from visaacceptancemergedspec.exceptions.delete_customer_shipping_address_exception_21_exception import (  # noqa: E501
    DeleteCustomerShippingAddressException21Exception,
)
from visaacceptancemergedspec.exceptions.delete_customer_shipping_address_exception_31_exception import (  # noqa: E501
    DeleteCustomerShippingAddressException31Exception,
)
from visaacceptancemergedspec.exceptions.delete_customer_shipping_address_exception_41_exception import (  # noqa: E501
    DeleteCustomerShippingAddressException41Exception,
)
from visaacceptancemergedspec.exceptions.delete_customer_shipping_address_exception_51_exception import (  # noqa: E501
    DeleteCustomerShippingAddressException51Exception,
)
from visaacceptancemergedspec.exceptions.delete_customer_shipping_address_exception_71_exception import (  # noqa: E501
    DeleteCustomerShippingAddressException71Exception,
)
from visaacceptancemergedspec.exceptions.get_customer_shipping_address_exception_1_exception import (  # noqa: E501
    GetCustomerShippingAddressException1Exception,
)
from visaacceptancemergedspec.exceptions.get_customer_shipping_address_exception_21_exception import (  # noqa: E501
    GetCustomerShippingAddressException21Exception,
)
from visaacceptancemergedspec.exceptions.get_customer_shipping_address_exception_31_exception import (  # noqa: E501
    GetCustomerShippingAddressException31Exception,
)
from visaacceptancemergedspec.exceptions.get_customer_shipping_address_exception_41_exception import (  # noqa: E501
    GetCustomerShippingAddressException41Exception,
)
from visaacceptancemergedspec.exceptions.get_customer_shipping_address_exception_61_exception import (  # noqa: E501
    GetCustomerShippingAddressException61Exception,
)
from visaacceptancemergedspec.exceptions.get_customer_shipping_addresses_list_exception_1_exception import (  # noqa: E501
    GetCustomerShippingAddressesListException1Exception,
)
from visaacceptancemergedspec.exceptions.get_customer_shipping_addresses_list_exception_21_exception import (  # noqa: E501
    GetCustomerShippingAddressesListException21Exception,
)
from visaacceptancemergedspec.exceptions.get_customer_shipping_addresses_list_exception_31_exception import (  # noqa: E501
    GetCustomerShippingAddressesListException31Exception,
)
from visaacceptancemergedspec.exceptions.get_customer_shipping_addresses_list_exception_41_exception import (  # noqa: E501
    GetCustomerShippingAddressesListException41Exception,
)
from visaacceptancemergedspec.exceptions.get_customer_shipping_addresses_list_exception_61_exception import (  # noqa: E501
    GetCustomerShippingAddressesListException61Exception,
)
from visaacceptancemergedspec.exceptions.patch_customers_shipping_address_exception_1_exception import (  # noqa: E501
    PatchCustomersShippingAddressException1Exception,
)
from visaacceptancemergedspec.exceptions.patch_customers_shipping_address_exception_21_exception import (  # noqa: E501
    PatchCustomersShippingAddressException21Exception,
)
from visaacceptancemergedspec.exceptions.patch_customers_shipping_address_exception_31_exception import (  # noqa: E501
    PatchCustomersShippingAddressException31Exception,
)
from visaacceptancemergedspec.exceptions.patch_customers_shipping_address_exception_41_exception import (  # noqa: E501
    PatchCustomersShippingAddressException41Exception,
)
from visaacceptancemergedspec.exceptions.patch_customers_shipping_address_exception_51_exception import (  # noqa: E501
    PatchCustomersShippingAddressException51Exception,
)
from visaacceptancemergedspec.exceptions.patch_customers_shipping_address_exception_71_exception import (  # noqa: E501
    PatchCustomersShippingAddressException71Exception,
)
from visaacceptancemergedspec.exceptions.post_customer_shipping_address_exception_1_exception import (  # noqa: E501
    PostCustomerShippingAddressException1Exception,
)
from visaacceptancemergedspec.exceptions.post_customer_shipping_address_exception_21_exception import (  # noqa: E501
    PostCustomerShippingAddressException21Exception,
)
from visaacceptancemergedspec.exceptions.post_customer_shipping_address_exception_31_exception import (  # noqa: E501
    PostCustomerShippingAddressException31Exception,
)
from visaacceptancemergedspec.exceptions.post_customer_shipping_address_exception_41_exception import (  # noqa: E501
    PostCustomerShippingAddressException41Exception,
)
from visaacceptancemergedspec.exceptions.post_customer_shipping_address_exception_51_exception import (  # noqa: E501
    PostCustomerShippingAddressException51Exception,
)
from visaacceptancemergedspec.http.http_method_enum import (
    HttpMethodEnum,
)
from visaacceptancemergedspec.models.get_customer_shipping_address_response import (
    GetCustomerShippingAddressResponse,
)
from visaacceptancemergedspec.models.patch_customers_shipping_address_response import (
    PatchCustomersShippingAddressResponse,
)
from visaacceptancemergedspec.models.post_customer_shipping_address_response import (
    PostCustomerShippingAddressResponse,
)
from visaacceptancemergedspec.models.shipping_address_list_for_customer import (
    ShippingAddressListForCustomer,
)


class CustomerShippingAddressApi(BaseApi):
    """A Controller to access Endpoints in the visaacceptancemergedspec API."""

    def __init__(self, config):
        """Initialize CustomerShippingAddressApi object."""
        super(CustomerShippingAddressApi, self).__init__(config)

    def post_customer_shipping_address(self,
                                       customer_id,
                                       body,
                                       profile_id=None):
        """Perform a POST request to
        /tms/v2/customers/{customerId}/shipping-addresses.

        |  |  |  |
        | --- | --- | --- |
        |**Customer Shipping Address**<br>A Customer Shipping Address represents
        tokenized customer shipping information.<br>A
        [Customer](#token-management_customer_create-a-customer) can have [one or
        more Shipping
        Addresses](#token-management_customer-shipping-address_list-shipping-addresses
        -for-a-customer), with one allocated as the Customers default for use in
        payments.|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|**Creating a Customer Shipping
        Address**<br>Your system can use this API to create an existing Customers
        default or non default Shipping Address.<br>You can also create additional
        Customer Shipping Addresses via the [Payments
        API](#payments_payments_process-a-payment_samplerequests-dropdown_authorizatio
        n-with-token-create_authorization-create-default-payment-instrument-shipping-a
        ddress-for-existing-customer_liveconsole-tab-request-body).

        Args:
            customer_id (str): The Id of a Customer.
            body (PostCustomerShippingAddressRequest): The request body parameter.
            profile_id (str, optional): The Id of a profile containing user specific
                TMS configuration.

        Returns:
            ApiResponse: An object with the response value as well as other useful
                information such as status codes and headers. A new Shipping Address
                has been created.

        Raises:
            ApiException: When an error occurs while fetching the data from the
                remote API. This exception includes the HTTP Response code, an error
                message, and the HTTP body that was received in the request.

        """
        return super().new_api_call_builder.request(
            RequestBuilder().server(Server.DEFAULT)
            .path("/tms/v2/customers/{customerId}/shipping-addresses")
            .http_method(HttpMethodEnum.POST)
            .template_param(Parameter()
                .key("customerId")
                .value(customer_id)
                .is_required(True)
                .should_encode(True))
            .header_param(Parameter()
                .key("Content-Type")
                .value("application/json;charset=utf-8"))
            .body_param(Parameter()
                .value(body)
                .is_required(True))
            .header_param(Parameter()
                .key("profile-id")
                .value(profile_id))
            .header_param(Parameter()
                .key("accept")
                .value("application/json"))
            .body_serializer(APIHelper.json_serialize)
            .auth(And(Single("BearerAuth"), Single("Accept"))),
        ).response(
            ResponseHandler()
            .deserializer(APIHelper.json_deserialize)
            .deserialize_into(PostCustomerShippingAddressResponse.from_dictionary)
            .is_api_response(True)
            .local_error("400",
                "Bad Request: e.g. A required header value could be missing.",
                PostCustomerShippingAddressException1Exception)
            .local_error("403",
                "Forbidden: e.g. The profile might not have permission to perform the"
                " operation.",
                PostCustomerShippingAddressException21Exception)
            .local_error("409",
                "Conflict. The token is linked to a Payment Instrument.",
                PostCustomerShippingAddressException31Exception)
            .local_error("424",
                "Failed Dependency: e.g. The profile represented by the profile-id ma"
                "y not exist or the profile-id was entered incorrectly.",
                PostCustomerShippingAddressException41Exception)
            .local_error("500",
                "Unexpected error.",
                PostCustomerShippingAddressException51Exception),
        ).execute()

    def get_customer_shipping_addresses_list(self,
                                             customer_id,
                                             profile_id=None,
                                             offset=0,
                                             limit=20):
        """Perform a GET request to
        /tms/v2/customers/{customerId}/shipping-addresses.

        |  |  |  |
        | --- | --- | --- |
        |**Customer Shipping Address**<br>A Customer Shipping Address represents
        tokenized customer shipping information.<br>A
        [Customer](#token-management_customer_create-a-customer) can have [one or
        more Shipping
        Addresses](#token-management_customer-shipping-address_list-shipping-addresses
        -for-a-customer), with one allocated as the Customers default for use in
        payments.|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|**Retrieving all Customer
        Shipping Addresses**<br>Your system can use this API to retrieve all existing
        Shipping Addresses for a Customer.

        Args:
            customer_id (str): The Id of a Customer.
            profile_id (str, optional): The Id of a profile containing user specific
                TMS configuration.
            offset (int, optional): Starting record in zero-based dataset that should
                be returned as the first object in the array. Default is 0.
            limit (int, optional): The maximum number that can be returned in the
                array starting from the offset record in zero-based dataset. Default
                is 20, maximum is 100.

        Returns:
            ApiResponse: An object with the response value as well as other useful
                information such as status codes and headers. Returns all existing
                Shipping Addresses associated with the supplied Id.

        Raises:
            ApiException: When an error occurs while fetching the data from the
                remote API. This exception includes the HTTP Response code, an error
                message, and the HTTP body that was received in the request.

        """
        return super().new_api_call_builder.request(
            RequestBuilder().server(Server.DEFAULT)
            .path("/tms/v2/customers/{customerId}/shipping-addresses")
            .http_method(HttpMethodEnum.GET)
            .template_param(Parameter()
                .key("customerId")
                .value(customer_id)
                .is_required(True)
                .should_encode(True))
            .header_param(Parameter()
                .key("profile-id")
                .value(profile_id))
            .query_param(Parameter()
                .key("offset")
                .value(offset))
            .query_param(Parameter()
                .key("limit")
                .value(limit))
            .header_param(Parameter()
                .key("accept")
                .value("application/json"))
            .auth(And(Single("BearerAuth"), Single("Accept"))),
        ).response(
            ResponseHandler()
            .deserializer(APIHelper.json_deserialize)
            .deserialize_into(ShippingAddressListForCustomer.from_dictionary)
            .is_api_response(True)
            .local_error("400",
                "Bad Request: e.g. A required header value could be missing.",
                GetCustomerShippingAddressesListException1Exception)
            .local_error("403",
                "Forbidden: e.g. The profile might not have permission to perform the"
                " operation.",
                GetCustomerShippingAddressesListException21Exception)
            .local_error("404",
                "Token Not Found. The Id may not exist or was entered incorrectly.",
                GetCustomerShippingAddressesListException31Exception)
            .local_error("410",
                "Token Not Available. The token has been deleted.",
                GetCustomerShippingAddressesListException41Exception)
            .local_error("424",
                "Failed Dependency: e.g. The profile represented by the profile-id ma"
                "y not exist or the profile-id was entered incorrectly.",
                GetCustomerShippingAddressesListException31Exception)
            .local_error("500",
                "Unexpected error.",
                GetCustomerShippingAddressesListException61Exception),
        ).execute()

    def get_customer_shipping_address(self,
                                      customer_id,
                                      shipping_address_id,
                                      profile_id=None):
        """Perform a GET request to
        /tms/v2/customers/{customerId}/shipping-addresses/{shippingAddressId}.

        |  |  |  |
        | --- | --- | --- |
        |**Customer Shipping Address**<br>A Customer Shipping Address represents
        tokenized customer shipping information.<br>A
        [Customer](#token-management_customer_create-a-customer) can have [one or
        more Shipping
        Addresses](#token-management_customer-shipping-address_list-shipping-addresses
        -for-a-customer), with one allocated as the Customers default for use in
        payments.|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|**Retrieving a Customer
        Shipping Address**<br>Your system can use this API to retrieve an existing
        Shipping Address for a Customer.<br>To perform a payment with a particular
        Shipping Address simply specify the [Shipping Address Id in the payments
        request](#payments_payments_process-a-payment_samplerequests-dropdown_authoriz
        ation-using-tokens_authorization-with-customer-payment-instrument-and-shipping
        -address-token-id_liveconsole-tab-request-body).

        Args:
            customer_id (str): The Id of a Customer.
            shipping_address_id (str): The Id of a shipping address.
            profile_id (str, optional): The Id of a profile containing user specific
                TMS configuration.

        Returns:
            ApiResponse: An object with the response value as well as other useful
                information such as status codes and headers. Returns an existing
                Shipping Address associated with the supplied Id.

        Raises:
            ApiException: When an error occurs while fetching the data from the
                remote API. This exception includes the HTTP Response code, an error
                message, and the HTTP body that was received in the request.

        """
        return super().new_api_call_builder.request(
            RequestBuilder().server(Server.DEFAULT)
            .path("/tms/v2/customers/{customerId}/shipping-addresses/{shippingAddressId}")
            .http_method(HttpMethodEnum.GET)
            .template_param(Parameter()
                .key("customerId")
                .value(customer_id)
                .is_required(True)
                .should_encode(True))
            .template_param(Parameter()
                .key("shippingAddressId")
                .value(shipping_address_id)
                .is_required(True)
                .should_encode(True))
            .header_param(Parameter()
                .key("profile-id")
                .value(profile_id))
            .header_param(Parameter()
                .key("accept")
                .value("application/json"))
            .auth(And(Single("BearerAuth"), Single("Accept"))),
        ).response(
            ResponseHandler()
            .deserializer(APIHelper.json_deserialize)
            .deserialize_into(GetCustomerShippingAddressResponse.from_dictionary)
            .is_api_response(True)
            .local_error("400",
                "Bad Request: e.g. A required header value could be missing.",
                GetCustomerShippingAddressException1Exception)
            .local_error("403",
                "Forbidden: e.g. The profile might not have permission to perform the"
                " operation.",
                GetCustomerShippingAddressException21Exception)
            .local_error("404",
                "Token Not Found. The Id may not exist or was entered incorrectly.",
                GetCustomerShippingAddressException31Exception)
            .local_error("410",
                "Token Not Available. The token has been deleted.",
                GetCustomerShippingAddressException41Exception)
            .local_error("424",
                "Failed Dependency: e.g. The profile represented by the profile-id ma"
                "y not exist or the profile-id was entered incorrectly.",
                GetCustomerShippingAddressException31Exception)
            .local_error("500",
                "Unexpected error.",
                GetCustomerShippingAddressException61Exception),
        ).execute()

    def patch_customers_shipping_address(self,
                                         customer_id,
                                         shipping_address_id,
                                         body,
                                         profile_id=None,
                                         if_match=None):
        """Perform a PATCH request to
        /tms/v2/customers/{customerId}/shipping-addresses/{shippingAddressId}.

        |  |  |  |
        | --- | --- | --- |
        |**Customer Shipping Address**<br>A Customer Shipping Address represents
        tokenized customer shipping information.<br>A
        [Customer](#token-management_customer_create-a-customer) can have [one or
        more Shipping
        Addresses](#token-management_customer-shipping-address_list-shipping-addresses
        -for-a-customer), with one allocated as the Customers default for use in
        payments.|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|**Updating a Customers
        Shipping Address**<br>Your system can use this API to update an existing
        Shipping Addresses for a Customer, including selecting a [default Shipping
        Address](#token-management_customer-shipping-address_update-a-customer-shippin
        g-address_samplerequests-dropdown_make-customer-shipping-address-the-default_l
        iveconsole-tab-request-body) for use in payments.

        Args:
            customer_id (str): The Id of a Customer.
            shipping_address_id (str): The Id of a shipping address.
            body (PatchCustomerShippingAddressRequest): The request body parameter.
            profile_id (str, optional): The Id of a profile containing user specific
                TMS configuration.
            if_match (str, optional): Contains an ETag value from a GET request to
                make the request conditional.

        Returns:
            ApiResponse: An object with the response value as well as other useful
                information such as status codes and headers. Returns an existing
                Shipping Address associated with the supplied Id.

        Raises:
            ApiException: When an error occurs while fetching the data from the
                remote API. This exception includes the HTTP Response code, an error
                message, and the HTTP body that was received in the request.

        """
        return super().new_api_call_builder.request(
            RequestBuilder().server(Server.DEFAULT)
            .path("/tms/v2/customers/{customerId}/shipping-addresses/{shippingAddressId}")
            .http_method(HttpMethodEnum.PATCH)
            .template_param(Parameter()
                .key("customerId")
                .value(customer_id)
                .is_required(True)
                .should_encode(True))
            .template_param(Parameter()
                .key("shippingAddressId")
                .value(shipping_address_id)
                .is_required(True)
                .should_encode(True))
            .header_param(Parameter()
                .key("Content-Type")
                .value("application/json;charset=utf-8"))
            .body_param(Parameter()
                .value(body)
                .is_required(True))
            .header_param(Parameter()
                .key("profile-id")
                .value(profile_id))
            .header_param(Parameter()
                .key("if-match")
                .value(if_match))
            .header_param(Parameter()
                .key("accept")
                .value("application/json"))
            .body_serializer(APIHelper.json_serialize)
            .auth(And(Single("BearerAuth"), Single("Accept"))),
        ).response(
            ResponseHandler()
            .deserializer(APIHelper.json_deserialize)
            .deserialize_into(PatchCustomersShippingAddressResponse.from_dictionary)
            .is_api_response(True)
            .local_error("400",
                "Bad Request: e.g. A required header value could be missing.",
                PatchCustomersShippingAddressException1Exception)
            .local_error("403",
                "Forbidden: e.g. The profile might not have permission to perform the"
                " operation.",
                PatchCustomersShippingAddressException21Exception)
            .local_error("404",
                "Token Not Found. The Id may not exist or was entered incorrectly.",
                PatchCustomersShippingAddressException31Exception)
            .local_error("410",
                "Token Not Available. The token has been deleted.",
                PatchCustomersShippingAddressException41Exception)
            .local_error("412",
                "Precondition Failed: The If-Match request header value does not matc"
                "h the current resources ETag",
                PatchCustomersShippingAddressException51Exception)
            .local_error("424",
                "Failed Dependency: e.g. The profile represented by the profile-id ma"
                "y not exist or the profile-id was entered incorrectly.",
                PatchCustomersShippingAddressException31Exception)
            .local_error("500",
                "Unexpected error.",
                PatchCustomersShippingAddressException71Exception),
        ).execute()

    def delete_customer_shipping_address(self,
                                         customer_id,
                                         shipping_address_id,
                                         profile_id=None):
        """Perform a DELETE request to
        /tms/v2/customers/{customerId}/shipping-addresses/{shippingAddressId}.

        |  |  |  |
        | --- | --- | --- |
        |**Customer Shipping Address**<br>A Customer Shipping Address represents
        tokenized customer shipping information.<br>A
        [Customer](#token-management_customer_create-a-customer) can have [one or
        more Shipping
        Addresses](#token-management_customer-shipping-address_list-shipping-addresses
        -for-a-customer), with one allocated as the Customers default for use in
        payments.|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|**Deleting a Customers
        Shipping Address**<br>Your system can use this API to delete an existing
        Shipping Address for a Customer.<br>If a customer has more than one Shipping
        Address then the default Shipping Address cannot be deleted without first
        selecting a [new default Shipping
        Address](#token-management_customer-shipping-address_update-a-customer-shippin
        g-address_samplerequests-dropdown_make-customer-shipping-address-the-default_l
        iveconsole-tab-request-body).

        Args:
            customer_id (str): The Id of a Customer.
            shipping_address_id (str): The Id of a shipping address.
            profile_id (str, optional): The Id of a profile containing user specific
                TMS configuration.

        Returns:
            ApiResponse: An object with the response value as well as other useful
                information such as status codes and headers. The request is
                fulfilled but does not need to return a body

        Raises:
            ApiException: When an error occurs while fetching the data from the
                remote API. This exception includes the HTTP Response code, an error
                message, and the HTTP body that was received in the request.

        """
        return super().new_api_call_builder.request(
            RequestBuilder().server(Server.DEFAULT)
            .path("/tms/v2/customers/{customerId}/shipping-addresses/{shippingAddressId}")
            .http_method(HttpMethodEnum.DELETE)
            .template_param(Parameter()
                .key("customerId")
                .value(customer_id)
                .is_required(True)
                .should_encode(True))
            .template_param(Parameter()
                .key("shippingAddressId")
                .value(shipping_address_id)
                .is_required(True)
                .should_encode(True))
            .header_param(Parameter()
                .key("profile-id")
                .value(profile_id))
            .header_param(Parameter()
                .key("accept")
                .value("application/json"))
            .auth(And(Single("BearerAuth"), Single("Accept"))),
        ).response(
            ResponseHandler()
            .is_api_response(True)
            .local_error("400",
                "Bad Request: e.g. A required header value could be missing.",
                DeleteCustomerShippingAddressException1Exception)
            .local_error("403",
                "Forbidden: e.g. The profile might not have permission to perform the"
                " operation.",
                DeleteCustomerShippingAddressException21Exception)
            .local_error("404",
                "Token Not Found. The Id may not exist or was entered incorrectly.",
                DeleteCustomerShippingAddressException31Exception)
            .local_error("409",
                "Conflict. The token is linked to a Payment Instrument.",
                DeleteCustomerShippingAddressException41Exception)
            .local_error("410",
                "Token Not Available. The token has been deleted.",
                DeleteCustomerShippingAddressException51Exception)
            .local_error("424",
                "Failed Dependency: e.g. The profile represented by the profile-id ma"
                "y not exist or the profile-id was entered incorrectly.",
                DeleteCustomerShippingAddressException31Exception)
            .local_error("500",
                "Unexpected error.",
                DeleteCustomerShippingAddressException71Exception),
        ).execute()
