"""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.sepa_debit_request import (
    SepaDebitRequest,
)


class BankRequest(object):
    """Implementation of the 'Bank Request' model.

    A Resource representing a request to vault a Bank used for ACH Debit.

    Attributes:
        ach_debit (Any): A Resource representing a request to vault a ACH Debit.
        sepa_debit (SepaDebitRequest): An API resource denoting a request to securely
            store a SEPA Debit.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "ach_debit": "ach_debit",
        "sepa_debit": "sepa_debit",
    }

    _optionals = [
        "ach_debit",
        "sepa_debit",
    ]

    def __init__(
        self,
        ach_debit=APIHelper.SKIP,
        sepa_debit=APIHelper.SKIP):
        """Initialize a BankRequest instance."""
        # Initialize members of the class
        if ach_debit is not APIHelper.SKIP:
            self.ach_debit = ach_debit
        if sepa_debit is not APIHelper.SKIP:
            self.sepa_debit = sepa_debit

    @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
        ach_debit =\
            dictionary.get("ach_debit")\
            if dictionary.get("ach_debit")\
                else APIHelper.SKIP
        sepa_debit =\
            SepaDebitRequest.from_dictionary(
                dictionary.get("sepa_debit"))\
                if "sepa_debit" in dictionary.keys()\
                else APIHelper.SKIP

        # Return an object of this model
        return cls(ach_debit,
                   sepa_debit)

    def __repr__(self):
        """Return a unambiguous string representation."""
        _ach_debit=(
            self.ach_debit
            if hasattr(self, "ach_debit")
            else None
        )
        _sepa_debit=(
            self.sepa_debit
            if hasattr(self, "sepa_debit")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"ach_debit={_ach_debit!r}, "
            f"sepa_debit={_sepa_debit!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _ach_debit=(
            self.ach_debit
            if hasattr(self, "ach_debit")
            else None
        )
        _sepa_debit=(
            self.sepa_debit
            if hasattr(self, "sepa_debit")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"ach_debit={_ach_debit!s}, "
            f"sepa_debit={_sepa_debit!s}, "
            f")"
        )
