"""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.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):
        """Initialize a BalancesResponse instance."""
        # 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):
        """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
        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 a unambiguous string representation."""
        _balances=(
            self.balances
            if hasattr(self, "balances")
            else None
        )
        _account_id=(
            self.account_id
            if hasattr(self, "account_id")
            else None
        )
        _as_of_time=(
            self.as_of_time
            if hasattr(self, "as_of_time")
            else None
        )
        _last_refresh_time=(
            self.last_refresh_time
            if hasattr(self, "last_refresh_time")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"balances={_balances!r}, "
            f"account_id={_account_id!r}, "
            f"as_of_time={_as_of_time!r}, "
            f"last_refresh_time={_last_refresh_time!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _balances=(
            self.balances
            if hasattr(self, "balances")
            else None
        )
        _account_id=(
            self.account_id
            if hasattr(self, "account_id")
            else None
        )
        _as_of_time=(
            self.as_of_time
            if hasattr(self, "as_of_time")
            else None
        )
        _last_refresh_time=(
            self.last_refresh_time
            if hasattr(self, "last_refresh_time")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"balances={_balances!s}, "
            f"account_id={_account_id!s}, "
            f"as_of_time={_as_of_time!s}, "
            f"last_refresh_time={_last_refresh_time!s}, "
            f")"
        )
