"""cellpointapi.

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

# ruff: noqa: E501

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

    Reason that the order was canceled.
    Will only be sent if order state is `CANCELED`.
    <table>
      <thead>
        <tr>
          <th>Type</th>
          <th>Description</th>
        </tr>
      </thead>
      <tbody>
        <tr>
          <td>ABANDONED</td>
          <td>Order has been abandoned. Time is out to complete payment. Please
    create a new order.</td>
        </tr>
        <tr>
          <td>FULFILLMENT_FAILURE</td>
          <td>Order was unable to be fulfilled by the merchant. All transactions have
    been canceled.</td>
        </tr>
        <tr>
          <td>FRAUD_REJECT</td>
          <td>Order was canceled due to the detection of fraud.</td>
        </tr>
        <tr>
          <td>MAXIMUM_NUMBER_OF_PAYMENT_ATTEMPTS_EXCEEDED</td>
          <td>Order was canceled because the maximum number of payment attempts has
    been exceeded on every possible payment method</td>
        </tr>
      </tbody>
    </table>

    Attributes:
        ABANDONED: The enum member of type str.
        FULFILLMENT_FAILURE: The enum member of type str.
        FRAUD_REJECT: The enum member of type str.
        MAXIMUM_NUMBER_OF_PAYMENT_ATTEMPTS_EXCEEDED: The enum member of type str.

    """

    _all_values = ["ABANDONED", "FULFILLMENT_FAILURE", "FRAUD_REJECT",
        "MAXIMUM_NUMBER_OF_PAYMENT_ATTEMPTS_EXCEEDED"]
    ABANDONED = "ABANDONED"

    FULFILLMENT_FAILURE = "FULFILLMENT_FAILURE"

    FRAUD_REJECT = "FRAUD_REJECT"

    MAXIMUM_NUMBER_OF_PAYMENT_ATTEMPTS_EXCEEDED = "MAXIMUM_NUMBER_OF_PAYMENT_ATTEMPTS_EXCEEDED" # noqa: E501

    @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
