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

me.alllex.tbot.api.client.TelegramResponse.kt Maven / Gradle / Ivy

The newest version!
package me.alllex.tbot.api.client

import kotlinx.serialization.Serializable
import me.alllex.tbot.api.model.ResponseParameters

@Serializable
data class TelegramResponse(
    val result: T? = null,
    val ok: Boolean,
    val description: String? = null,
    val errorCode: Int? = null,
    val parameters: ResponseParameters? = null
)

@Throws(TelegramBotApiException::class)
fun  TelegramResponse.getResultOrThrow(): T {
    if (ok && result != null) {
        return result
    }

    throw TelegramBotApiException(this)
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy