# This file was auto-generated by Fern from our API Definition.

import enum
import typing

T_Result = typing.TypeVar("T_Result")


class InvoiceFailureType(str, enum.Enum):
    SOURCE_PAYMENT_ERROR = "SOURCE_PAYMENT_ERROR"
    DESTINATION_PAYMENT_ERROR = "DESTINATION_PAYMENT_ERROR"
    REJECTED_HIGH_RISK = "REJECTED_HIGH_RISK"
    INSUFFICIENT_FUNDS = "INSUFFICIENT_FUNDS"
    PROCESSING_ERROR = "PROCESSING_ERROR"

    def visit(
        self,
        source_payment_error: typing.Callable[[], T_Result],
        destination_payment_error: typing.Callable[[], T_Result],
        rejected_high_risk: typing.Callable[[], T_Result],
        insufficient_funds: typing.Callable[[], T_Result],
        processing_error: typing.Callable[[], T_Result],
    ) -> T_Result:
        if self is InvoiceFailureType.SOURCE_PAYMENT_ERROR:
            return source_payment_error()
        if self is InvoiceFailureType.DESTINATION_PAYMENT_ERROR:
            return destination_payment_error()
        if self is InvoiceFailureType.REJECTED_HIGH_RISK:
            return rejected_high_risk()
        if self is InvoiceFailureType.INSUFFICIENT_FUNDS:
            return insufficient_funds()
        if self is InvoiceFailureType.PROCESSING_ERROR:
            return processing_error()
