"""visaacceptancemergedspec.

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

# ruff: noqa: E501
from visaacceptancemergedspec.api_helper import (
    APIHelper,
)


class ShippingDetails(object):
    """Implementation of the 'ShippingDetails' model.

    Contains shipping information not related to address.

    Attributes:
        gift_wrap (bool): Boolean that indicates whether the customer requested gift
            wrapping for this purchase. This field can contain one of the following
            values: - true: The customer requested gift wrapping. - false: The
            customer did not request gift wrapping.
        shipping_method (str): Shipping method for the product. Possible values:   -
            `lowcost`: Lowest-cost service  - `sameday`: Courier or same-day service
            - `oneday`: Next-day or overnight service  - `twoday`: Two-day service  -
            `threeday`: Three-day service  - `pickup`: Store pick-up  - `other`:
            Other shipping method  - `none`: No shipping method because product is a
            service or subscription
        ship_from_postal_code (str): Postal code for the address from which the goods
            are shipped, which is used to establish nexus. The default is the postal
            code associated with your Visa Acceptance account.  The postal code must
            consist of 5 to 9 digits. When the billing country is the U.S., the
            9-digit postal code must follow this format:  `[5 digits][dash][4
            digits]`  Example 12345-6789  When the billing country is Canada, the
            6-digit postal code must follow this format:
            `[alpha][numeric][alpha][space] [numeric][alpha][numeric]`  Example A1B
            2C3  This field is frequently used for Level II and Level III
            transactions.
        additional_properties (Dict[str, Any]): The additional properties for the
            model.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "gift_wrap": "giftWrap",
        "shipping_method": "shippingMethod",
        "ship_from_postal_code": "shipFromPostalCode",
    }

    _optionals = [
        "gift_wrap",
        "shipping_method",
        "ship_from_postal_code",
    ]

    def __init__(
        self,
        gift_wrap=APIHelper.SKIP,
        shipping_method=APIHelper.SKIP,
        ship_from_postal_code=APIHelper.SKIP,
        additional_properties=None):
        """Initialize a ShippingDetails instance."""
        # Initialize members of the class
        if gift_wrap is not APIHelper.SKIP:
            self.gift_wrap = gift_wrap
        if shipping_method is not APIHelper.SKIP:
            self.shipping_method = shipping_method
        if ship_from_postal_code is not APIHelper.SKIP:
            self.ship_from_postal_code = ship_from_postal_code

        # Add additional model properties to the instance
        if additional_properties is None:
            additional_properties = {}
        self.additional_properties = additional_properties

    @classmethod
    def from_dictionary(cls,
                        dictionary):
        """Create an instance of this model from a dictionary

        Args:
            dictionary (dictionary): A dictionary representation of the object
            as obtained from the deserialization of the server's response. The
            keys MUST match property names in the API description.

        Returns:
            object: An instance of this structure class.

        """
        if not isinstance(dictionary, dict) or dictionary is None:
            return None

        # Extract variables from the dictionary
        gift_wrap =\
            dictionary.get("giftWrap")\
            if "giftWrap" in dictionary.keys()\
                else APIHelper.SKIP
        shipping_method =\
            dictionary.get("shippingMethod")\
            if dictionary.get("shippingMethod")\
                else APIHelper.SKIP
        ship_from_postal_code =\
            dictionary.get("shipFromPostalCode")\
            if dictionary.get("shipFromPostalCode")\
                else APIHelper.SKIP

        additional_properties = APIHelper.get_additional_properties(
            dictionary={k: v for k, v in dictionary.items()
                        if k not in cls._names.values()},
            unboxing_function=lambda value: value)

        # Return an object of this model
        return cls(gift_wrap,
                   shipping_method,
                   ship_from_postal_code,
                   additional_properties)

    def __repr__(self):
        """Return a unambiguous string representation."""
        _gift_wrap=(
            self.gift_wrap
            if hasattr(self, "gift_wrap")
            else None
        )
        _shipping_method=(
            self.shipping_method
            if hasattr(self, "shipping_method")
            else None
        )
        _ship_from_postal_code=(
            self.ship_from_postal_code
            if hasattr(self, "ship_from_postal_code")
            else None
        )
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"gift_wrap={_gift_wrap!r}, "
            f"shipping_method={_shipping_method!r}, "
            f"ship_from_postal_code={_ship_from_postal_code!r}, "
            f"additional_properties={_additional_properties!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _gift_wrap=(
            self.gift_wrap
            if hasattr(self, "gift_wrap")
            else None
        )
        _shipping_method=(
            self.shipping_method
            if hasattr(self, "shipping_method")
            else None
        )
        _ship_from_postal_code=(
            self.ship_from_postal_code
            if hasattr(self, "ship_from_postal_code")
            else None
        )
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"gift_wrap={_gift_wrap!s}, "
            f"shipping_method={_shipping_method!s}, "
            f"ship_from_postal_code={_ship_from_postal_code!s}, "
            f"additional_properties={_additional_properties!s}, "
            f")"
        )
