mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-22 16:23:48 +00:00
Request extracting result method removed
This commit is contained in:
parent
84eb2fac7c
commit
f86ae2b592
@ -8,6 +8,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.bot.settings.limiters.EmptyLim
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.settings.limiters.RequestLimiter
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.Request
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.extractResult
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.Response
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.RetryAfterError
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.TelegramAPIUrlsKeeper
|
||||
import io.ktor.client.HttpClient
|
||||
@ -74,7 +75,7 @@ class KtorRequestsExecutor(
|
||||
val content = call.response.use {
|
||||
it.content.toByteArray().toString(Charsets.UTF_8)
|
||||
}
|
||||
val responseObject = jsonFormatter.extractResult(content)
|
||||
val responseObject = jsonFormatter.parse(Response.serializer(), content)
|
||||
|
||||
(responseObject.result ?.let {
|
||||
jsonFormatter.fromJson(request.resultDeserializer(), it)
|
||||
|
@ -1,6 +1,5 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.Response
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.toJsonWithoutNulls
|
||||
import kotlinx.serialization.*
|
||||
import kotlinx.serialization.json.JsonObject
|
||||
@ -12,9 +11,3 @@ interface Request<T: Any> {
|
||||
fun json(): JsonObject = toJsonWithoutNulls(RequestSerializer)
|
||||
}
|
||||
object RequestSerializer : KSerializer<Request<*>> by ContextSerializer(Request::class)
|
||||
|
||||
fun StringFormat.extractResult(
|
||||
from: String
|
||||
): Response {
|
||||
return parse(Response.serializer(), from)
|
||||
}
|
Loading…
Reference in New Issue
Block a user