All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ru.tinkoff.acquiring.sdk.utils.RequestResult.kt Maven / Gradle / Ivy

There is a newer version: 4.2.0
Show newest version
package ru.tinkoff.acquiring.sdk.utils

import ru.tinkoff.acquiring.sdk.responses.AcquiringResponse

sealed class RequestResult {

    object NotYet:  RequestResult()

    class Success(val result: R) : RequestResult()

    class Failure(val exception: Exception) : RequestResult()

    fun process(onSuccess: (R) -> Unit, onFailure: (Exception) -> Unit) {
        when (this) {
            is Success -> onSuccess(result)
            is Failure -> onFailure(exception)
            else -> Unit
        }
    }

    val isFinished get() = this !is NotYet
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy