1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-11-25 11:38:45 +00:00

add SimpleRequestSerializer

This commit is contained in:
InsanusMokrassar 2019-02-21 15:48:49 +08:00
parent 313068543f
commit b39232ae47
2 changed files with 9 additions and 3 deletions

View File

@ -1,8 +1,7 @@
package com.github.insanusmokrassar.TelegramBotAPI.bot.Ktor.base package com.github.insanusmokrassar.TelegramBotAPI.bot.Ktor.base
import com.github.insanusmokrassar.TelegramBotAPI.bot.Ktor.KtorCallFactory import com.github.insanusmokrassar.TelegramBotAPI.bot.Ktor.KtorCallFactory
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.Request import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.*
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
import com.github.insanusmokrassar.TelegramBotAPI.utils.toJsonWithoutNulls import com.github.insanusmokrassar.TelegramBotAPI.utils.toJsonWithoutNulls
import io.ktor.client.HttpClient import io.ktor.client.HttpClient
import io.ktor.client.call.HttpClientCall import io.ktor.client.call.HttpClientCall
@ -27,7 +26,7 @@ class SimpleRequestCallFactory : KtorCallFactory {
method = HttpMethod.Post method = HttpMethod.Post
accept(ContentType.Application.Json) accept(ContentType.Application.Json)
val content = request.toJsonWithoutNulls().toString() val content = request.toJsonWithoutNulls(SimpleRequestSerializer).toString()
body = TextContent( body = TextContent(
content, content,

View File

@ -1,3 +1,10 @@
package com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts package com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts
import kotlinx.serialization.ContextSerializer
import kotlinx.serialization.KSerializer
import kotlinx.serialization.Serializable
@Serializable(SimpleRequestSerializer::class)
interface SimpleRequest<T: Any> : Request<T> interface SimpleRequest<T: Any> : Request<T>
object SimpleRequestSerializer : KSerializer<SimpleRequest<*>> by ContextSerializer(SimpleRequest::class)