"""paypalserversdk.

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

# ruff: noqa: E501

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

    The reason code for the payment failure.

    Attributes:
        PAYMENT_DENIED: PayPal declined the payment due to one or more customer
            issues.
        INTERNAL_SERVER_ERROR: An internal server error has occurred.
        PAYEE_ACCOUNT_RESTRICTED: The payee account is not in good standing and
            cannot receive payments.
        PAYER_ACCOUNT_RESTRICTED: The payer account is not in good standing and
            cannot make payments.
        PAYER_CANNOT_PAY: Payer cannot pay for this transaction.
        SENDING_LIMIT_EXCEEDED: The transaction exceeds the payer's sending limit.
        TRANSACTION_RECEIVING_LIMIT_EXCEEDED: The transaction exceeds the receiver's
            receiving limit.
        CURRENCY_MISMATCH: The transaction is declined due to a currency mismatch.

    """

    PAYMENT_DENIED = "PAYMENT_DENIED"

    INTERNAL_SERVER_ERROR = "INTERNAL_SERVER_ERROR"

    PAYEE_ACCOUNT_RESTRICTED = "PAYEE_ACCOUNT_RESTRICTED"

    PAYER_ACCOUNT_RESTRICTED = "PAYER_ACCOUNT_RESTRICTED"

    PAYER_CANNOT_PAY = "PAYER_CANNOT_PAY"

    SENDING_LIMIT_EXCEEDED = "SENDING_LIMIT_EXCEEDED"

    TRANSACTION_RECEIVING_LIMIT_EXCEEDED = "TRANSACTION_RECEIVING_LIMIT_EXCEEDED"

    CURRENCY_MISMATCH = "CURRENCY_MISMATCH"

    @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
