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

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

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