"""visaacceptancemergedspec.

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

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


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

    Attributes:
        total_amount (str): Grand total for the order. This value cannot be negative.
            You can include a decimal point (.), but you cannot include any other
            special characters. Visa Acceptance truncates the amount to the correct
            number of decimal places
        currency (str): Currency used for the order
        sub_total_amount (str): Shipping discount amount for the transaction. If this
            amount has changed since the initial sessions request, you must include
            the new value in the order request. You must also include all additional
            amount fields that apply to the order and ensure the total amount equals
            the purchaseTotals_grandTotalAmount value.
        handling_amount (str): Aggregate handling charges for the transaction. If
            this amount has changed since the initial sessions request, you must
            include the new value in the order request. You must also include all
            additional amount fields that apply to the order and ensure the total
            amount equals the purchaseTotals_grandTotalAmount value.
        shipping_amount (str): Aggregate shipping charges for the transaction If this
            amount has changed since the initial sessions request, you must include
            the new value in the order request. You must also include all additional
            amount fields that apply to the order and ensure the total amount equals
            the purchaseTotals_grandTotalAmount value.
        shipping_discount_amount (str): Shipping discount amount for the transaction.
            If this amount has changed since the initial sessions request, you must
            include the new value in the order request. You must also include all
            additional amount fields that apply to the order and ensure the total
            amount equals the purchaseTotals_grandTotalAmount value.
        tax_amount (str): Total tax amount. When the purchaseTotals_ taxAmount and
            ap_subtotalAmount fields are included in the request, do not include the
            tax amount as part of the subtotal amount calculation.
        insurance_amount (str): Amount being charged for the insurance fee. Only
            supported when the payment_method is set to paypal.
        gift_wrap_amount (str): Amount being charged as gift wrap fee.
        additional_properties (Dict[str, Any]): The additional properties for the
            model.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "total_amount": "totalAmount",
        "currency": "currency",
        "sub_total_amount": "subTotalAmount",
        "handling_amount": "handlingAmount",
        "shipping_amount": "shippingAmount",
        "shipping_discount_amount": "shippingDiscountAmount",
        "tax_amount": "taxAmount",
        "insurance_amount": "insuranceAmount",
        "gift_wrap_amount": "giftWrapAmount",
    }

    _optionals = [
        "total_amount",
        "currency",
        "sub_total_amount",
        "handling_amount",
        "shipping_amount",
        "shipping_discount_amount",
        "tax_amount",
        "insurance_amount",
        "gift_wrap_amount",
    ]

    def __init__(
        self,
        total_amount=APIHelper.SKIP,
        currency=APIHelper.SKIP,
        sub_total_amount=APIHelper.SKIP,
        handling_amount=APIHelper.SKIP,
        shipping_amount=APIHelper.SKIP,
        shipping_discount_amount=APIHelper.SKIP,
        tax_amount=APIHelper.SKIP,
        insurance_amount=APIHelper.SKIP,
        gift_wrap_amount=APIHelper.SKIP,
        additional_properties=None):
        """Initialize a Order instance."""
        # Initialize members of the class
        if total_amount is not APIHelper.SKIP:
            self.total_amount = total_amount
        if currency is not APIHelper.SKIP:
            self.currency = currency
        if sub_total_amount is not APIHelper.SKIP:
            self.sub_total_amount = sub_total_amount
        if handling_amount is not APIHelper.SKIP:
            self.handling_amount = handling_amount
        if shipping_amount is not APIHelper.SKIP:
            self.shipping_amount = shipping_amount
        if shipping_discount_amount is not APIHelper.SKIP:
            self.shipping_discount_amount = shipping_discount_amount
        if tax_amount is not APIHelper.SKIP:
            self.tax_amount = tax_amount
        if insurance_amount is not APIHelper.SKIP:
            self.insurance_amount = insurance_amount
        if gift_wrap_amount is not APIHelper.SKIP:
            self.gift_wrap_amount = gift_wrap_amount

        # 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
        total_amount =\
            dictionary.get("totalAmount")\
            if dictionary.get("totalAmount")\
                else APIHelper.SKIP
        currency =\
            dictionary.get("currency")\
            if dictionary.get("currency")\
                else APIHelper.SKIP
        sub_total_amount =\
            dictionary.get("subTotalAmount")\
            if dictionary.get("subTotalAmount")\
                else APIHelper.SKIP
        handling_amount =\
            dictionary.get("handlingAmount")\
            if dictionary.get("handlingAmount")\
                else APIHelper.SKIP
        shipping_amount =\
            dictionary.get("shippingAmount")\
            if dictionary.get("shippingAmount")\
                else APIHelper.SKIP
        shipping_discount_amount =\
            dictionary.get("shippingDiscountAmount")\
            if dictionary.get("shippingDiscountAmount")\
                else APIHelper.SKIP
        tax_amount =\
            dictionary.get("taxAmount")\
            if dictionary.get("taxAmount")\
                else APIHelper.SKIP
        insurance_amount =\
            dictionary.get("insuranceAmount")\
            if dictionary.get("insuranceAmount")\
                else APIHelper.SKIP
        gift_wrap_amount =\
            dictionary.get("giftWrapAmount")\
            if dictionary.get("giftWrapAmount")\
                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(total_amount,
                   currency,
                   sub_total_amount,
                   handling_amount,
                   shipping_amount,
                   shipping_discount_amount,
                   tax_amount,
                   insurance_amount,
                   gift_wrap_amount,
                   additional_properties)

    def __repr__(self):
        """Return a unambiguous string representation."""
        _total_amount=(
            self.total_amount
            if hasattr(self, "total_amount")
            else None
        )
        _currency=(
            self.currency
            if hasattr(self, "currency")
            else None
        )
        _sub_total_amount=(
            self.sub_total_amount
            if hasattr(self, "sub_total_amount")
            else None
        )
        _handling_amount=(
            self.handling_amount
            if hasattr(self, "handling_amount")
            else None
        )
        _shipping_amount=(
            self.shipping_amount
            if hasattr(self, "shipping_amount")
            else None
        )
        _shipping_discount_amount=(
            self.shipping_discount_amount
            if hasattr(self, "shipping_discount_amount")
            else None
        )
        _tax_amount=(
            self.tax_amount
            if hasattr(self, "tax_amount")
            else None
        )
        _insurance_amount=(
            self.insurance_amount
            if hasattr(self, "insurance_amount")
            else None
        )
        _gift_wrap_amount=(
            self.gift_wrap_amount
            if hasattr(self, "gift_wrap_amount")
            else None
        )
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"total_amount={_total_amount!r}, "
            f"currency={_currency!r}, "
            f"sub_total_amount={_sub_total_amount!r}, "
            f"handling_amount={_handling_amount!r}, "
            f"shipping_amount={_shipping_amount!r}, "
            f"shipping_discount_amount={_shipping_discount_amount!r}, "
            f"tax_amount={_tax_amount!r}, "
            f"insurance_amount={_insurance_amount!r}, "
            f"gift_wrap_amount={_gift_wrap_amount!r}, "
            f"additional_properties={_additional_properties!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _total_amount=(
            self.total_amount
            if hasattr(self, "total_amount")
            else None
        )
        _currency=(
            self.currency
            if hasattr(self, "currency")
            else None
        )
        _sub_total_amount=(
            self.sub_total_amount
            if hasattr(self, "sub_total_amount")
            else None
        )
        _handling_amount=(
            self.handling_amount
            if hasattr(self, "handling_amount")
            else None
        )
        _shipping_amount=(
            self.shipping_amount
            if hasattr(self, "shipping_amount")
            else None
        )
        _shipping_discount_amount=(
            self.shipping_discount_amount
            if hasattr(self, "shipping_discount_amount")
            else None
        )
        _tax_amount=(
            self.tax_amount
            if hasattr(self, "tax_amount")
            else None
        )
        _insurance_amount=(
            self.insurance_amount
            if hasattr(self, "insurance_amount")
            else None
        )
        _gift_wrap_amount=(
            self.gift_wrap_amount
            if hasattr(self, "gift_wrap_amount")
            else None
        )
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"total_amount={_total_amount!s}, "
            f"currency={_currency!s}, "
            f"sub_total_amount={_sub_total_amount!s}, "
            f"handling_amount={_handling_amount!s}, "
            f"shipping_amount={_shipping_amount!s}, "
            f"shipping_discount_amount={_shipping_discount_amount!s}, "
            f"tax_amount={_tax_amount!s}, "
            f"insurance_amount={_insurance_amount!s}, "
            f"gift_wrap_amount={_gift_wrap_amount!s}, "
            f"additional_properties={_additional_properties!s}, "
            f")"
        )
