mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-12-25 18:17:13 +00:00
ResponseParameters renaming to Response
This commit is contained in:
parent
6f04baea4e
commit
206b3fd3e4
@ -30,6 +30,7 @@ must be regular text
|
||||
### 0.9.3
|
||||
|
||||
* `KtorRequestsExecutor` now can use custom `JSON` string formatter (by default - non strict)
|
||||
* `ResponseParameters` renamed to `Response`
|
||||
|
||||
### 0.8.5
|
||||
|
||||
|
@ -7,7 +7,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestException
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.settings.limiters.EmptyLimiter
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.settings.limiters.RequestLimiter
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.Request
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ResponseParameters
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.Response
|
||||
import io.ktor.client.HttpClient
|
||||
import io.ktor.client.call.HttpClientCall
|
||||
import io.ktor.client.engine.HttpClientEngine
|
||||
@ -61,7 +61,7 @@ class KtorRequestsExecutor(
|
||||
}
|
||||
val content = call.response.content.toByteArray().toString(Charset.defaultCharset())
|
||||
val responseObject = jsonFormatter.parse(
|
||||
ResponseParameters.serializer(request.resultSerializer()),
|
||||
Response.serializer(request.resultSerializer()),
|
||||
content
|
||||
)
|
||||
responseObject.result ?: call.let {
|
||||
|
@ -1,10 +1,10 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.bot
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ResponseParameters
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.Response
|
||||
import java.io.IOException
|
||||
|
||||
class RequestException(
|
||||
val response: ResponseParameters<*>,
|
||||
val response: Response<*>,
|
||||
message: String? = null,
|
||||
cause: Throwable? = null
|
||||
) : IOException(
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ResponseParameters
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.Response
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.toJsonWithoutNulls
|
||||
import kotlinx.serialization.*
|
||||
import kotlinx.serialization.json.JsonObject
|
||||
@ -15,6 +15,6 @@ interface Request<T: Any> {
|
||||
fun <T : Any> StringFormat.extractResult(
|
||||
from: String,
|
||||
dataSerializer: KSerializer<T>
|
||||
): ResponseParameters<T> {
|
||||
return parse(ResponseParameters.serializer(dataSerializer), from)
|
||||
): Response<T> {
|
||||
return parse(Response.serializer(dataSerializer), from)
|
||||
}
|
@ -4,8 +4,14 @@ import kotlinx.serialization.*
|
||||
import org.joda.time.DateTime
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
@Deprecated(
|
||||
"Deprecated because incorrect name",
|
||||
ReplaceWith("Response")
|
||||
)
|
||||
typealias ResponseParameters<T> = Response<T>
|
||||
|
||||
@Serializable
|
||||
data class ResponseParameters<T : Any>(
|
||||
data class Response<T : Any>(
|
||||
val ok: Boolean = false,
|
||||
@Optional
|
||||
val description: String? = null,
|
@ -4,7 +4,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestException
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.Request
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ResponseParameters
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.Response
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.UpdateIdentifier
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.MediaGroupMessage
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.update.*
|
||||
@ -147,7 +147,7 @@ fun RequestsExecutor.startGettingOfUpdates(
|
||||
|
||||
fun <T: Any> RequestsExecutor.executeAsync(
|
||||
request: Request<T>,
|
||||
onFail: (suspend (ResponseParameters<*>) -> Unit)? = null,
|
||||
onFail: (suspend (Response<*>) -> Unit)? = null,
|
||||
scope: CoroutineScope = GlobalScope,
|
||||
onSuccess: (suspend (T) -> Unit)? = null
|
||||
): Job {
|
||||
|
Loading…
Reference in New Issue
Block a user