me.alllex.tbot.api.client.TelegramResponse.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of tbot-api-jvm Show documentation
Show all versions of tbot-api-jvm Show documentation
Fluent Kotlin bindings for Telegram Bot API
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)
}