"""cellpointapi.

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

# ruff: noqa: E501

class CardScheme(object):
    """Implementation of the 'CardScheme' enum.

    Card Scheme networks connects acquiring banks to issuing banks so that a customer
    transaction can be verified.
    Is a middle man that also provide additional services, such as data processing,
    international transactions, etc.

    Attributes:
        AMERICAN_EXPRESS: The enum member of type str.
        DINERS: The enum member of type str.
        DISCOVER: The enum member of type str.
        JCB: The enum member of type str.
        MASTERCARD: The enum member of type str.
        UATP: The enum member of type str.
        UNION_PAY: The enum member of type str.
        VISA: The enum member of type str.

    """

    _all_values = ["AMERICAN_EXPRESS", "DINERS", "DISCOVER", "JCB",
        "MASTERCARD", "UATP", "UNION_PAY", "VISA"]
    AMERICAN_EXPRESS = "AMERICAN_EXPRESS"

    DINERS = "DINERS"

    DISCOVER = "DISCOVER"

    JCB = "JCB"

    MASTERCARD = "MASTERCARD"

    UATP = "UATP"

    UNION_PAY = "UNION_PAY"

    VISA = "VISA"

    @classmethod
    def validate(cls, value):
        """Validate value contains in enum

        Args:
            value: the value to be validated

        Returns:
            boolean : if value is valid enum values.

        """
        return value in cls._all_values

    @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
