"""paypalserversdk.

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

# ruff: noqa: E501

class CvvCode(object):
    """Implementation of the 'CVV Code' enum.

    The card verification value code for for Visa, Discover, Mastercard, or American
    Express.

    Attributes:
        CVV_E: For Visa, Mastercard, Discover, or American Express, error -
            unrecognized or unknown response.
        CVV_I: For Visa, Mastercard, Discover, or American Express, invalid or null.
        CVV_M: For Visa, Mastercard, Discover, or American Express, the CVV2/CSC
            matches.
        CVV_N: For Visa, Mastercard, Discover, or American Express, the CVV2/CSC does
            not match.
        CVV_P: For Visa, Mastercard, Discover, or American Express, it was not
            processed.
        CVV_S: For Visa, Mastercard, Discover, or American Express, the service is
            not supported.
        CVV_U: For Visa, Mastercard, Discover, or American Express, unknown - the
            issuer is not certified.
        CVV_X: For Visa, Mastercard, Discover, or American Express, no response. For
            Maestro, the service is not available.
        ENUM_ALL OTHERS: For Visa, Mastercard, Discover, or American Express, error.
        CVV_0: For Maestro, the CVV2 matched.
        CVV_1: For Maestro, the CVV2 did not match.
        CVV_2: For Maestro, the merchant has not implemented CVV2 code handling.
        CVV_3: For Maestro, the merchant has indicated that CVV2 is not present on
            card.
        CVV_4: For Maestro, the service is not available.

    """

    CVV_E = "E"

    CVV_I = "I"

    CVV_M = "M"

    CVV_N = "N"

    CVV_P = "P"

    CVV_S = "S"

    CVV_U = "U"

    CVV_X = "X"

    ENUM_ALL_OTHERS = "All others"

    CVV_0 = "0"

    CVV_1 = "1"

    CVV_2 = "2"

    CVV_3 = "3"

    CVV_4 = "4"

    @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
