mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-25 03:28:44 +00:00
add SimpleRequestSerializer
This commit is contained in:
parent
313068543f
commit
b39232ae47
@ -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,
|
||||||
|
@ -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)
|
||||||
|
Loading…
Reference in New Issue
Block a user