1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-06-30 13:27:47 +00:00
tgbotapi/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/Response.kt

37 lines
878 B
Kotlin
Raw Normal View History

2018-12-26 08:07:24 +00:00
package com.github.insanusmokrassar.TelegramBotAPI.types
import kotlinx.serialization.*
import org.joda.time.DateTime
import java.util.concurrent.TimeUnit
@Deprecated(
"Deprecated because incorrect name",
ReplaceWith("Response")
)
typealias ResponseParameters<T> = Response<T>
2018-12-26 08:07:24 +00:00
@Serializable
data class Response<T : Any>(
2018-12-26 08:07:24 +00:00
val ok: Boolean = false,
@Optional
val description: String? = null,
@SerialName("migrate_to_chat_id")
@Optional
val migrateToChatId: Identifier? = null,
@SerialName("retry_after")
@Optional
val retryAfter: Int? = null,
@SerialName("error_code")
@Optional
val errorCode: Int? = null,
@Optional
val result: T? = null
) {
@Transient
val waitUntil: DateTime? by lazy {
retryAfter ?.let {
DateTime.now().plus(TimeUnit.SECONDS.toMillis(it.toLong()))
}
}
}