"""cellpointapi.

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

# ruff: noqa: E501

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

    Category of transaction failure.
    <table>
      <thead>
        <tr>
          <th>Category</th>
          <th>Description</th>
        </tr>
      </thead>
      <tbody>
        <tr>
          <td>USER_ERROR</td>
          <td>The buyer has entered invalid details during the payment session.</td>
        </tr>
        <tr>
          <td>INTEGRATION_ERROR</td>
          <td>There is an error with the integration between us and an external
    system for this request. Example - provider does not support decimal. Or MID does
    not exist.</td>
        </tr>
        <tr>
          <td>SECURITY_ERROR</td>
          <td>
            Payment failed to pass additional security screening verification.
            EXAMPLES:
              - CARD_BLOCKED
              - AVS_FAILED
              - FRAUD_SUSPICION
              - 3DS_FAILED
          </td>
        </tr>
        <tr>
          <td>TECHNICAL_ERROR</td>
          <td>Transient errors that are happening due to unavailable of some system
    (possibly downstream).</td>
        </tr>
        <tr>
          <td>TRANSACTION_ERROR</td>
          <td>Transaction related errors.</td>
        </tr>
      </tbody>
    </table>

    Attributes:
        USER_ERROR: The enum member of type str.
        INTEGRATION_ERROR: The enum member of type str.
        SECURITY_ERROR: The enum member of type str.
        TECHNICAL_ERROR: The enum member of type str.
        TRANSACTION_ERROR: The enum member of type str.

    """

    _all_values = ["USER_ERROR", "INTEGRATION_ERROR", "SECURITY_ERROR",
        "TECHNICAL_ERROR", "TRANSACTION_ERROR"]
    USER_ERROR = "USER_ERROR"

    INTEGRATION_ERROR = "INTEGRATION_ERROR"

    SECURITY_ERROR = "SECURITY_ERROR"

    TECHNICAL_ERROR = "TECHNICAL_ERROR"

    TRANSACTION_ERROR = "TRANSACTION_ERROR"

    @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
