# -*- 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.balance_information import BalanceInformation


class BalancesResponse(object):

    """Implementation of the 'Balances Response' model.

    The balances response information.

    Attributes:
        balances (List[BalanceInformation]): An array of balance detail
            objects.
        account_id (str): The PayPal payer ID, which is a masked version of
            the PayPal account number intended for use with third parties. The
            account number is reversibly encrypted and a proprietary variant
            of Base32 is used to encode the result.
        as_of_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.
        last_refresh_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 = {
        "balances": 'balances',
        "account_id": 'account_id',
        "as_of_time": 'as_of_time',
        "last_refresh_time": 'last_refresh_time'
    }

    _optionals = [
        'balances',
        'account_id',
        'as_of_time',
        'last_refresh_time',
    ]

    def __init__(self,
                 balances=APIHelper.SKIP,
                 account_id=APIHelper.SKIP,
                 as_of_time=APIHelper.SKIP,
                 last_refresh_time=APIHelper.SKIP):
        """Constructor for the BalancesResponse class"""

        # Initialize members of the class
        if balances is not APIHelper.SKIP:
            self.balances = balances 
        if account_id is not APIHelper.SKIP:
            self.account_id = account_id 
        if as_of_time is not APIHelper.SKIP:
            self.as_of_time = as_of_time 
        if last_refresh_time is not APIHelper.SKIP:
            self.last_refresh_time = last_refresh_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
        balances = None
        if dictionary.get('balances') is not None:
            balances = [BalanceInformation.from_dictionary(x) for x in dictionary.get('balances')]
        else:
            balances = APIHelper.SKIP
        account_id = dictionary.get("account_id") if dictionary.get("account_id") else APIHelper.SKIP
        as_of_time = dictionary.get("as_of_time") if dictionary.get("as_of_time") else APIHelper.SKIP
        last_refresh_time = dictionary.get("last_refresh_time") if dictionary.get("last_refresh_time") else APIHelper.SKIP
        # Return an object of this model
        return cls(balances,
                   account_id,
                   as_of_time,
                   last_refresh_time)

    def __repr__(self):
        return (f'{self.__class__.__name__}('
                f'balances={(self.balances if hasattr(self, "balances") else None)!r}, '
                f'account_id={(self.account_id if hasattr(self, "account_id") else None)!r}, '
                f'as_of_time={(self.as_of_time if hasattr(self, "as_of_time") else None)!r}, '
                f'last_refresh_time={(self.last_refresh_time if hasattr(self, "last_refresh_time") else None)!r})')

    def __str__(self):
        return (f'{self.__class__.__name__}('
                f'balances={(self.balances if hasattr(self, "balances") else None)!s}, '
                f'account_id={(self.account_id if hasattr(self, "account_id") else None)!s}, '
                f'as_of_time={(self.as_of_time if hasattr(self, "as_of_time") else None)!s}, '
                f'last_refresh_time={(self.last_refresh_time if hasattr(self, "last_refresh_time") else None)!s})')
