diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/bot/Ktor/KtorRequestsExecutor.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/bot/Ktor/KtorRequestsExecutor.kt index b753c78c02..d30c8479df 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/bot/Ktor/KtorRequestsExecutor.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/bot/Ktor/KtorRequestsExecutor.kt @@ -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) diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/abstracts/Request.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/abstracts/Request.kt index 617eb399ef..d93d77ba0d 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/abstracts/Request.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/abstracts/Request.kt @@ -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 { fun json(): JsonObject = toJsonWithoutNulls(RequestSerializer) } object RequestSerializer : KSerializer> by ContextSerializer(Request::class) - -fun StringFormat.extractResult( - from: String -): Response { - return parse(Response.serializer(), from) -} \ No newline at end of file