2018-12-26 08:07:24 +00:00
|
|
|
package com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts
|
|
|
|
|
2019-01-17 02:43:51 +00:00
|
|
|
import com.github.insanusmokrassar.TelegramBotAPI.utils.toJsonWithoutNulls
|
2018-12-26 08:07:24 +00:00
|
|
|
import kotlinx.serialization.*
|
|
|
|
import kotlinx.serialization.json.JsonObject
|
|
|
|
|
2019-02-27 00:52:22 +00:00
|
|
|
@Serializable(RequestSerializer::class)
|
2018-12-26 08:07:24 +00:00
|
|
|
interface Request<T: Any> {
|
|
|
|
fun method(): String
|
2019-08-17 05:50:46 +00:00
|
|
|
fun resultDeserializer(): DeserializationStrategy<T>
|
2019-02-27 00:52:22 +00:00
|
|
|
fun json(): JsonObject = toJsonWithoutNulls(RequestSerializer)
|
2018-12-26 08:07:24 +00:00
|
|
|
}
|
2019-02-27 00:52:22 +00:00
|
|
|
object RequestSerializer : KSerializer<Request<*>> by ContextSerializer(Request::class)
|