# -*- coding: utf-8 -*-

"""
paypalserversdk

This file was automatically generated by APIMATIC v3.0 (
 https://www.apimatic.io ).
"""
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):
        """Constructor for the FailedPaymentDetails class"""

        # 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):
        """Creates 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 (f'{self.__class__.__name__}('
                f'amount={self.amount!r}, '
                f'time={self.time!r}, '
                f'reason_code={(self.reason_code if hasattr(self, "reason_code") else None)!r}, '
                f'next_payment_retry_time={(self.next_payment_retry_time if hasattr(self, "next_payment_retry_time") else None)!r})')

    def __str__(self):
        return (f'{self.__class__.__name__}('
                f'amount={self.amount!s}, '
                f'time={self.time!s}, '
                f'reason_code={(self.reason_code if hasattr(self, "reason_code") else None)!s}, '
                f'next_payment_retry_time={(self.next_payment_retry_time if hasattr(self, "next_payment_retry_time") else None)!s})')
