"""paypalserversdk.

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

# ruff: noqa: E501
from paypalserversdk.api_helper import APIHelper
from paypalserversdk.models.money import Money


class OneTimeCharge(object):
    """Implementation of the 'One Time Charge' model.

    The one-time charge info at the time of checkout.

    Attributes:
        setup_fee (Money): The currency and amount for a financial transaction, such
            as a balance or payment due.
        shipping_amount (Money): The currency and amount for a financial transaction,
            such as a balance or payment due.
        taxes (Money): The currency and amount for a financial transaction, such as a
            balance or payment due.
        product_price (Money): The currency and amount for a financial transaction,
            such as a balance or payment due.
        subtotal (Money): The currency and amount for a financial transaction, such
            as a balance or payment due.
        total_amount (Money): The currency and amount for a financial transaction,
            such as a balance or payment due.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "total_amount": "total_amount",
        "setup_fee": "setup_fee",
        "shipping_amount": "shipping_amount",
        "taxes": "taxes",
        "product_price": "product_price",
        "subtotal": "subtotal",
    }

    _optionals = [
        "setup_fee",
        "shipping_amount",
        "taxes",
        "product_price",
        "subtotal",
    ]

    def __init__(
        self,
        total_amount=None,
        setup_fee=APIHelper.SKIP,
        shipping_amount=APIHelper.SKIP,
        taxes=APIHelper.SKIP,
        product_price=APIHelper.SKIP,
        subtotal=APIHelper.SKIP):
        """Initialize a OneTimeCharge instance."""
        # Initialize members of the class
        if setup_fee is not APIHelper.SKIP:
            self.setup_fee = setup_fee
        if shipping_amount is not APIHelper.SKIP:
            self.shipping_amount = shipping_amount
        if taxes is not APIHelper.SKIP:
            self.taxes = taxes
        if product_price is not APIHelper.SKIP:
            self.product_price = product_price
        if subtotal is not APIHelper.SKIP:
            self.subtotal = subtotal
        self.total_amount = total_amount

    @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 =\
            Money.from_dictionary(
                dictionary.get("total_amount"))\
                if dictionary.get("total_amount") else None
        setup_fee =\
            Money.from_dictionary(
                dictionary.get("setup_fee"))\
                if "setup_fee" in dictionary.keys()\
                else APIHelper.SKIP
        shipping_amount =\
            Money.from_dictionary(
                dictionary.get("shipping_amount"))\
                if "shipping_amount" in dictionary.keys()\
                else APIHelper.SKIP
        taxes =\
            Money.from_dictionary(
                dictionary.get("taxes"))\
                if "taxes" in dictionary.keys()\
                else APIHelper.SKIP
        product_price =\
            Money.from_dictionary(
                dictionary.get("product_price"))\
                if "product_price" in dictionary.keys()\
                else APIHelper.SKIP
        subtotal =\
            Money.from_dictionary(
                dictionary.get("subtotal"))\
                if "subtotal" in dictionary.keys()\
                else APIHelper.SKIP

        # Return an object of this model
        return cls(total_amount,
                   setup_fee,
                   shipping_amount,
                   taxes,
                   product_price,
                   subtotal)

    def __repr__(self):
        """Return a unambiguous string representation."""
        _setup_fee=(
            self.setup_fee
            if hasattr(self, "setup_fee")
            else None
        )
        _shipping_amount=(
            self.shipping_amount
            if hasattr(self, "shipping_amount")
            else None
        )
        _taxes=(
            self.taxes
            if hasattr(self, "taxes")
            else None
        )
        _product_price=(
            self.product_price
            if hasattr(self, "product_price")
            else None
        )
        _subtotal=(
            self.subtotal
            if hasattr(self, "subtotal")
            else None
        )
        _total_amount=self.total_amount
        return (
            f"{self.__class__.__name__}("
            f"setup_fee={_setup_fee!r}, "
            f"shipping_amount={_shipping_amount!r}, "
            f"taxes={_taxes!r}, "
            f"product_price={_product_price!r}, "
            f"subtotal={_subtotal!r}, "
            f"total_amount={_total_amount!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _setup_fee=(
            self.setup_fee
            if hasattr(self, "setup_fee")
            else None
        )
        _shipping_amount=(
            self.shipping_amount
            if hasattr(self, "shipping_amount")
            else None
        )
        _taxes=(
            self.taxes
            if hasattr(self, "taxes")
            else None
        )
        _product_price=(
            self.product_price
            if hasattr(self, "product_price")
            else None
        )
        _subtotal=(
            self.subtotal
            if hasattr(self, "subtotal")
            else None
        )
        _total_amount=self.total_amount
        return (
            f"{self.__class__.__name__}("
            f"setup_fee={_setup_fee!s}, "
            f"shipping_amount={_shipping_amount!s}, "
            f"taxes={_taxes!s}, "
            f"product_price={_product_price!s}, "
            f"subtotal={_subtotal!s}, "
            f"total_amount={_total_amount!s}, "
            f")"
        )
