# -*- 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 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):
        """Constructor for the LastPaymentDetails class"""

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

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