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

    The details for the failed payment of the subscription.

    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.
        reason_code (ReasonCode): The reason code for the payment failure.
        next_payment_retry_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",
        "reason_code": "reason_code",
        "next_payment_retry_time": "next_payment_retry_time",
    }

    _optionals = [
        "reason_code",
        "next_payment_retry_time",
    ]

    def __init__(
        self,
        amount=None,
        time=None,
        reason_code=APIHelper.SKIP,
        next_payment_retry_time=APIHelper.SKIP):
        """Initialize a FailedPaymentDetails instance."""
        # Initialize members of the class
        self.amount = amount
        self.time = time
        if reason_code is not APIHelper.SKIP:
            self.reason_code = reason_code
        if next_payment_retry_time is not APIHelper.SKIP:
            self.next_payment_retry_time = next_payment_retry_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 dictionary.get("amount") else None
        time =\
            dictionary.get("time")\
            if dictionary.get("time")\
                else None
        reason_code =\
            dictionary.get("reason_code")\
            if dictionary.get("reason_code")\
                else APIHelper.SKIP
        next_payment_retry_time =\
            dictionary.get("next_payment_retry_time")\
            if dictionary.get("next_payment_retry_time")\
                else APIHelper.SKIP

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

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

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