"""visaacceptancemergedspec.

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

# ruff: noqa: E501

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

    Attributes:
        INVALID_APIKEY: The enum member of type str.
        INVALID_SHIPPING_INPUT_PARAMS: The enum member of type str.
        CAPTURE_CONTEXT_INVALID: The enum member of type str.
        CAPTURE_CONTEXT_EXPIRED: The enum member of type str.
        SDK_XHR_ERROR: The enum member of type str.
        UNIFIEDPAYMENTS_VALIDATION_PARAMS: The enum member of type str.
        UNIFIEDPAYMENTS_VALIDATION_FIELDS: The enum member of type str.
        UNIFIEDPAYMENT_PAYMENT_PARAMITERS: The enum member of type str.
        CREATE_TOKEN_TIMEOUT: The enum member of type str.
        CREATE_TOKEN_XHR_ERROR: The enum member of type str.
        SHOW_LOAD_CONTAINER_SELECTOR: The enum member of type str.
        SHOW_LOAD_INVALID_CONTAINER: The enum member of type str.
        SHOW_TOKEN_TIMEOUT: The enum member of type str.
        SHOW_TOKEN_XHR_ERROR: The enum member of type str.
        SHOW_PAYMENT_TIMEOUT: The enum member of type str.
        additional_properties (Dict[str, Any]): The additional properties for the
            model.

    """

    INVALID_APIKEY = "INVALID_APIKEY"

    INVALID_SHIPPING_INPUT_PARAMS = "INVALID_SHIPPING_INPUT_PARAMS"

    CAPTURE_CONTEXT_INVALID = "CAPTURE_CONTEXT_INVALID"

    CAPTURE_CONTEXT_EXPIRED = "CAPTURE_CONTEXT_EXPIRED"

    SDK_XHR_ERROR = "SDK_XHR_ERROR"

    UNIFIEDPAYMENTS_VALIDATION_PARAMS = "UNIFIEDPAYMENTS_VALIDATION_PARAMS"

    UNIFIEDPAYMENTS_VALIDATION_FIELDS = "UNIFIEDPAYMENTS_VALIDATION_FIELDS"

    UNIFIEDPAYMENT_PAYMENT_PARAMITERS = "UNIFIEDPAYMENT_PAYMENT_PARAMITERS"

    CREATE_TOKEN_TIMEOUT = "CREATE_TOKEN_TIMEOUT"

    CREATE_TOKEN_XHR_ERROR = "CREATE_TOKEN_XHR_ERROR"

    SHOW_LOAD_CONTAINER_SELECTOR = "SHOW_LOAD_CONTAINER_SELECTOR"

    SHOW_LOAD_INVALID_CONTAINER = "SHOW_LOAD_INVALID_CONTAINER"

    SHOW_TOKEN_TIMEOUT = "SHOW_TOKEN_TIMEOUT"

    SHOW_TOKEN_XHR_ERROR = "SHOW_TOKEN_XHR_ERROR"

    SHOW_PAYMENT_TIMEOUT = "SHOW_PAYMENT_TIMEOUT"

    @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
