"""paypalserversdk.

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

# ruff: noqa: E501

class AvsCode(object):
    """Implementation of the 'AVS Code' enum.

    The address verification code for Visa, Discover, Mastercard, or American Express
    transactions.

    Attributes:
        AVS_A: For Visa, Mastercard, or Discover transactions, the address matches
            but the zip code does not match. For American Express transactions, the
            card holder address is correct.
        AVS_B: For Visa, Mastercard, or Discover transactions, the address matches.
            International A.
        AVS_C: For Visa, Mastercard, or Discover transactions, no values match.
            International N.
        AVS_D: For Visa, Mastercard, or Discover transactions, the address and postal
            code match. International X.
        AVS_E: For Visa, Mastercard, or Discover transactions, not allowed for
            Internet or phone transactions. For American Express card holder, the
            name is incorrect but the address and postal code match.
        AVS_F: For Visa, Mastercard, or Discover transactions, the address and postal
            code match. UK-specific X. For American Express card holder, the name is
            incorrect but the address matches.
        AVS_G: For Visa, Mastercard, or Discover transactions, global is unavailable.
            Nothing matches.
        AVS_I: For Visa, Mastercard, or Discover transactions, international is
            unavailable. Not applicable.
        AVS_M: For Visa, Mastercard, or Discover transactions, the address and postal
            code match. For American Express card holder, the name, address, and
            postal code match.
        AVS_N: For Visa, Mastercard, or Discover transactions, nothing matches. For
            American Express card holder, the address and postal code are both
            incorrect.
        AVS_P: For Visa, Mastercard, or Discover transactions, postal international
            Z. Postal code only.
        AVS_R: For Visa, Mastercard, or Discover transactions, re-try the request.
            For American Express, the system is unavailable.
        AVS_S: For Visa, Mastercard, Discover, or American Express, the service is
            not supported.
        AVS_U: For Visa, Mastercard, or Discover transactions, the service is
            unavailable. For American Express, information is not available. For
            Maestro, the address is not checked or the acquirer had no response. The
            service is not available.
        AVS_W: For Visa, Mastercard, or Discover transactions, whole ZIP code. For
            American Express, the card holder name, address, and postal code are all
            incorrect.
        AVS_X: For Visa, Mastercard, or Discover transactions, exact match of the
            address and the nine-digit ZIP code. For American Express, the card
            holder name, address, and postal code are all incorrect.
        AVS_Y: For Visa, Mastercard, or Discover transactions, the address and
            five-digit ZIP code match. For American Express, the card holder address
            and postal code are both correct.
        AVS_Z: For Visa, Mastercard, or Discover transactions, the five-digit ZIP
            code matches but no address. For American Express, only the card holder
            postal code is correct.
        AVS_NULL: For Maestro, no AVS response was obtained.
        AVS_0: For Maestro, all address information matches.
        AVS_1: For Maestro, none of the address information matches.
        AVS_2: For Maestro, part of the address information matches.
        AVS_3: For Maestro, the merchant did not provide AVS information. It was not
            processed.
        AVS_4: For Maestro, the address was not checked or the acquirer had no
            response. The service is not available.

    """

    AVS_A = "A"

    AVS_B = "B"

    AVS_C = "C"

    AVS_D = "D"

    AVS_E = "E"

    AVS_F = "F"

    AVS_G = "G"

    AVS_I = "I"

    AVS_M = "M"

    AVS_N = "N"

    AVS_P = "P"

    AVS_R = "R"

    AVS_S = "S"

    AVS_U = "U"

    AVS_W = "W"

    AVS_X = "X"

    AVS_Y = "Y"

    AVS_Z = "Z"

    AVS_NULL = "Null"

    AVS_0 = "0"

    AVS_1 = "1"

    AVS_2 = "2"

    AVS_3 = "3"

    AVS_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
