"""paypalserversdk.

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

# ruff: noqa: E501

class PaypalWalletContactPreference(object):
    """Implementation of the 'PayPal Wallet Contact Preference' enum.

    The preference to display the contact information (buyer’s shipping email & phone
    number) on PayPal's checkout for easy merchant-buyer communication.

    Attributes:
        NO_CONTACT_INFO: The merchant can opt out of showing buyer's contact
            information on PayPal checkout.
        UPDATE_CONTACT_INFO: The merchant allows buyer to add or update shipping
            contact information on the PayPal checkout. Please ensure to use this
            updated information returned in shipping.email_address and
            shipping.phone_number to contact your buyers.
        RETAIN_CONTACT_INFO: The buyer can only see but can not override merchant
            passed contact information (shipping.email_address and
            shipping.phone_number) on PayPal checkout. NOTE: If you don't pass the
            contact information, the behavior is the same as NO_CONTACT_INFO
            preference.

    """

    NO_CONTACT_INFO = "NO_CONTACT_INFO"

    UPDATE_CONTACT_INFO = "UPDATE_CONTACT_INFO"

    RETAIN_CONTACT_INFO = "RETAIN_CONTACT_INFO"

    @classmethod
    def from_value(cls, value, default=None):
        """Return the matching enum value for the given input."""
        if value is None:
            return default

        # If numeric and matches directly
        if isinstance(value, int):
            for name, val in cls.__dict__.items():
                if not name.startswith("_") and val == value:
                    return val

        # If string, perform case-insensitive match
        if isinstance(value, str):
            value_lower = value.lower()
            for name, val in cls.__dict__.items():
                if not name.startswith("_") and (
                    name.lower() == value_lower or str(val).lower() == value_lower
                ):
                    return val

        # Fallback to default
        return default
