"""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 LastPaymentDetails(object):
    """Implementation of the 'Last Payment Details' model.

    Attributes:
        amount (Money): The currency and amount for a financial transaction, such as
            a balance or payment due.
        time (str): The date and time, in [Internet date and time
            format](https://tools.ietf.org/html/rfc3339#section-5.6). Seconds are
            required while fractional seconds are optional. Note: The regular
            expression provides guidance but does not reject all invalid dates.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "amount": "amount",
        "time": "time",
    }

    _optionals = [
        "amount",
        "time",
    ]

    def __init__(
        self,
        amount=APIHelper.SKIP,
        time=APIHelper.SKIP):
        """Initialize a LastPaymentDetails instance."""
        # Initialize members of the class
        if amount is not APIHelper.SKIP:
            self.amount = amount
        if time is not APIHelper.SKIP:
            self.time = time

    @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
        amount =\
            Money.from_dictionary(
                dictionary.get("amount"))\
                if "amount" in dictionary.keys()\
                else APIHelper.SKIP
        time =\
            dictionary.get("time")\
            if dictionary.get("time")\
                else APIHelper.SKIP

        # Return an object of this model
        return cls(amount,
                   time)

    def __repr__(self):
        """Return a unambiguous string representation."""
        _amount=(
            self.amount
            if hasattr(self, "amount")
            else None
        )
        _time=(
            self.time
            if hasattr(self, "time")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"amount={_amount!r}, "
            f"time={_time!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _amount=(
            self.amount
            if hasattr(self, "amount")
            else None
        )
        _time=(
            self.time
            if hasattr(self, "time")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"amount={_amount!s}, "
            f"time={_time!s}, "
            f")"
        )
