"""cellpointapi.

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

# ruff: noqa: E501

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

    Which business module the failure happened in.
    <table>
      <thead>
        <tr>
          <th>Module</th>
          <th>Description</th>
        </tr>
      </thead>
      <tbody>
        <tr>
          <td>PRE_AUTHORIZATION</td>
          <td>Failure happened during pre-authorization checks.</td>
        </tr>
        <tr>
          <td>PAYMENT_PROCESSOR</td>
          <td>Failure happened when processing the payment.</td>
        </tr>
        <tr>
          <td>FOREIGN_EXCHANGE</td>
          <td>Failure happened in foreign exchange (FX).</td>
        </tr>
        <tr>
          <td>THREE_D_SECURE</td>
          <td>Failure happened during 3DSecure flow.</td>
        </tr>
        <tr>
          <td>FRAUD</td>
          <td>Failure happened in fraud checks.</td>
        </tr>
      </tbody>
    </table>

    Attributes:
        PRE_AUTHORIZATION: The enum member of type str.
        PAYMENT_PROCESSOR: The enum member of type str.
        FOREIGN_EXCHANGE: The enum member of type str.
        THREE_D_SECURE: The enum member of type str.
        FRAUD: The enum member of type str.

    """

    _all_values = ["PRE_AUTHORIZATION", "PAYMENT_PROCESSOR",
        "FOREIGN_EXCHANGE", "THREE_D_SECURE", "FRAUD"]
    PRE_AUTHORIZATION = "PRE_AUTHORIZATION"

    PAYMENT_PROCESSOR = "PAYMENT_PROCESSOR"

    FOREIGN_EXCHANGE = "FOREIGN_EXCHANGE"

    THREE_D_SECURE = "THREE_D_SECURE"

    FRAUD = "FRAUD"

    @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
