"""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.card_supplementary_data import (
    CardSupplementaryData,
)
from paypalserversdk.models.risk_supplementary_data import (
    RiskSupplementaryData,
)


class SupplementaryData(object):
    """Implementation of the 'Supplementary Data' model.

    Supplementary data about a payment. This object passes information that can be
    used to improve risk assessments and processing costs, for example, by providing
    Level 2 and Level 3 payment data.

    Attributes:
        card (CardSupplementaryData): Merchants and partners can add Level 2 and 3
            data to payments to reduce risk and payment processing costs. For more
            information about processing payments, see checkout or multiparty
            checkout.
        risk (RiskSupplementaryData): Additional information necessary to evaluate
            the risk profile of a transaction.

    """

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

    _optionals = [
        "card",
        "risk",
    ]

    def __init__(
        self,
        card=APIHelper.SKIP,
        risk=APIHelper.SKIP):
        """Initialize a SupplementaryData instance."""
        # Initialize members of the class
        if card is not APIHelper.SKIP:
            self.card = card
        if risk is not APIHelper.SKIP:
            self.risk = risk

    @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
        card =\
            CardSupplementaryData.from_dictionary(
                dictionary.get("card"))\
                if "card" in dictionary.keys()\
                else APIHelper.SKIP
        risk =\
            RiskSupplementaryData.from_dictionary(
                dictionary.get("risk"))\
                if "risk" in dictionary.keys()\
                else APIHelper.SKIP

        # Return an object of this model
        return cls(card,
                   risk)

    def __repr__(self):
        """Return a unambiguous string representation."""
        _card=(
            self.card
            if hasattr(self, "card")
            else None
        )
        _risk=(
            self.risk
            if hasattr(self, "risk")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"card={_card!r}, "
            f"risk={_risk!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _card=(
            self.card
            if hasattr(self, "card")
            else None
        )
        _risk=(
            self.risk
            if hasattr(self, "risk")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"card={_card!s}, "
            f"risk={_risk!s}, "
            f")"
        )
