"""visaacceptancemergedspec.

This file was automatically generated by APIMATIC v3.0 ( https://www.apimatic.io ).
"""

# ruff: noqa: E501
from visaacceptancemergedspec.api_helper import (
    APIHelper,
)


class TokenizedPaymentMethod2(object):
    """Implementation of the 'TokenizedPaymentMethod2' model.

    Attributes:
        description (str): Description of the vaulted payment method shown to the
            buyer during checkout and in their PayPal account.
        usage_pattern (str): Indicates how the merchant will primarily use the
            vaulted payment method. Valid values: - “IMMEDIATE”: For on-demand,
            instant payments. These payments are variable in both amount and
            frequency and will be used to pay for goods or services before they are
            rendered to the buyer - “DEFERRED”: For post-pay payments; that is,
            payments for goods or services that have already been rendered to the
            buyer - “RECURRING_PREPAID”: For recurring payments before services are
            rendered. - “RECURRING_POSTPAID”: For recurring payments after services
            are rendered. - “THRESHOLD_PREPAID”: For payments when a pre-defined
            threshold is reached before services are rendered. -
            “THRESHOLD_POSTPAID”: For payments when a pre-defined threshold is
            reached after services are rendered.
        usage_type (str): Indicates the type of vaulting relationship. Valid values:
            - “MERCHANT”: Single merchant relationship. - “PLATFORM”: Platform
            hosting multiple merchants.
        allow_multiple_tokens (bool): Create multiple payment tokens for the same
            payer, merchant/platform combination. This helps to identify customers
            distinctly even though they may share the same PayPal account.
        additional_properties (Dict[str, Any]): The additional properties for the
            model.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "description": "description",
        "usage_pattern": "usagePattern",
        "usage_type": "usageType",
        "allow_multiple_tokens": "allowMultipleTokens",
    }

    _optionals = [
        "description",
        "usage_pattern",
        "usage_type",
        "allow_multiple_tokens",
    ]

    def __init__(
        self,
        description=APIHelper.SKIP,
        usage_pattern=APIHelper.SKIP,
        usage_type=APIHelper.SKIP,
        allow_multiple_tokens=APIHelper.SKIP,
        additional_properties=None):
        """Initialize a TokenizedPaymentMethod2 instance."""
        # Initialize members of the class
        if description is not APIHelper.SKIP:
            self.description = description
        if usage_pattern is not APIHelper.SKIP:
            self.usage_pattern = usage_pattern
        if usage_type is not APIHelper.SKIP:
            self.usage_type = usage_type
        if allow_multiple_tokens is not APIHelper.SKIP:
            self.allow_multiple_tokens = allow_multiple_tokens

        # Add additional model properties to the instance
        if additional_properties is None:
            additional_properties = {}
        self.additional_properties = additional_properties

    @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
        description =\
            dictionary.get("description")\
            if dictionary.get("description")\
                else APIHelper.SKIP
        usage_pattern =\
            dictionary.get("usagePattern")\
            if dictionary.get("usagePattern")\
                else APIHelper.SKIP
        usage_type =\
            dictionary.get("usageType")\
            if dictionary.get("usageType")\
                else APIHelper.SKIP
        allow_multiple_tokens =\
            dictionary.get("allowMultipleTokens")\
            if "allowMultipleTokens" in dictionary.keys()\
                else APIHelper.SKIP

        additional_properties = APIHelper.get_additional_properties(
            dictionary={k: v for k, v in dictionary.items()
                        if k not in cls._names.values()},
            unboxing_function=lambda value: value)

        # Return an object of this model
        return cls(description,
                   usage_pattern,
                   usage_type,
                   allow_multiple_tokens,
                   additional_properties)

    def __repr__(self):
        """Return a unambiguous string representation."""
        _description=(
            self.description
            if hasattr(self, "description")
            else None
        )
        _usage_pattern=(
            self.usage_pattern
            if hasattr(self, "usage_pattern")
            else None
        )
        _usage_type=(
            self.usage_type
            if hasattr(self, "usage_type")
            else None
        )
        _allow_multiple_tokens=(
            self.allow_multiple_tokens
            if hasattr(self, "allow_multiple_tokens")
            else None
        )
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"description={_description!r}, "
            f"usage_pattern={_usage_pattern!r}, "
            f"usage_type={_usage_type!r}, "
            f"allow_multiple_tokens={_allow_multiple_tokens!r}, "
            f"additional_properties={_additional_properties!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _description=(
            self.description
            if hasattr(self, "description")
            else None
        )
        _usage_pattern=(
            self.usage_pattern
            if hasattr(self, "usage_pattern")
            else None
        )
        _usage_type=(
            self.usage_type
            if hasattr(self, "usage_type")
            else None
        )
        _allow_multiple_tokens=(
            self.allow_multiple_tokens
            if hasattr(self, "allow_multiple_tokens")
            else None
        )
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"description={_description!s}, "
            f"usage_pattern={_usage_pattern!s}, "
            f"usage_type={_usage_type!s}, "
            f"allow_multiple_tokens={_allow_multiple_tokens!s}, "
            f"additional_properties={_additional_properties!s}, "
            f")"
        )
