mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2025-11-15 03:20:18 +00:00
migration
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.answers
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.CallbackQuery.CallbackQuery
|
||||
import kotlinx.serialization.*
|
||||
import kotlinx.serialization.internal.BooleanSerializer
|
||||
|
||||
@Serializable
|
||||
data class AnswerCallbackQuery(
|
||||
@SerialName(callbackQueryIdField)
|
||||
val callbackQueryId: CallbackQueryIdentifier,
|
||||
@SerialName(textField)
|
||||
val text: String? = null,
|
||||
@SerialName(showAlertField)
|
||||
val showAlert: Boolean? = null,
|
||||
@SerialName(urlField)
|
||||
val url: String? = null,
|
||||
@SerialName(cachedTimeField)
|
||||
val cachedTimeSeconds: Int? = null
|
||||
) : SimpleRequest<Boolean> {
|
||||
override fun method(): String = "answerCallbackQuery"
|
||||
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||
get() = BooleanSerializer
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
|
||||
fun CallbackQuery.createAnswer(
|
||||
text: String? = null,
|
||||
showAlert: Boolean? = null,
|
||||
url: String? = null,
|
||||
cachedTimeSeconds: Int? = null
|
||||
): AnswerCallbackQuery = AnswerCallbackQuery(id, text, showAlert, url, cachedTimeSeconds)
|
||||
@@ -0,0 +1,56 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.answers
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts.InlineQueryResult
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.serializers.InlineQueryResultSerializer
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.abstracts.InlineQuery
|
||||
import kotlinx.serialization.*
|
||||
import kotlinx.serialization.internal.ArrayListSerializer
|
||||
import kotlinx.serialization.internal.BooleanSerializer
|
||||
|
||||
@Serializable
|
||||
data class AnswerInlineQuery(
|
||||
@SerialName(inlineQueryIdField)
|
||||
val inlineQueryID: InlineQueryIdentifier,
|
||||
@Serializable(InlineQueryAnswersResultsSerializer::class)
|
||||
@SerialName(resultsField)
|
||||
val results: List<InlineQueryResult> = emptyList(),
|
||||
@SerialName(cachedTimeField)
|
||||
val cachedTime: Int? = null,
|
||||
@SerialName(isPersonalField)
|
||||
val isPersonal: Boolean? = null,
|
||||
@SerialName(nextOffsetField)
|
||||
val nextOffset: String? = null,
|
||||
@SerialName(switchPmTextField)
|
||||
val switchPmText: String? = null,
|
||||
@SerialName(switchPmParameterField)
|
||||
val switchPmParameter: String? = null
|
||||
): SimpleRequest<Boolean> {
|
||||
override fun method(): String = "answerInlineQuery"
|
||||
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||
get() = BooleanSerializer
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
|
||||
fun InlineQuery.createAnswer(
|
||||
results: List<InlineQueryResult> = emptyList(),
|
||||
cachedTime: Int? = null,
|
||||
isPersonal: Boolean? = null,
|
||||
nextOffset: String? = null,
|
||||
switchPmText: String? = null,
|
||||
switchPmParameter: String? = null
|
||||
) = AnswerInlineQuery(
|
||||
id,
|
||||
results,
|
||||
cachedTime,
|
||||
isPersonal,
|
||||
nextOffset,
|
||||
switchPmText,
|
||||
switchPmParameter
|
||||
)
|
||||
|
||||
object InlineQueryAnswersResultsSerializer: KSerializer<List<InlineQueryResult>> by ArrayListSerializer(
|
||||
InlineQueryResultSerializer
|
||||
)
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.answers.payments
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.answers.payments.abstracts.AnswerPreCheckoutQuery
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.payments.PreCheckoutQuery
|
||||
import kotlinx.serialization.*
|
||||
|
||||
@Serializable
|
||||
data class AnswerPreCheckoutQueryOk(
|
||||
@SerialName(preCheckoutQueryIdField)
|
||||
override val preCheckoutQueryId: PreCheckoutQueryId
|
||||
) : AnswerPreCheckoutQuery {
|
||||
@SerialName(okField)
|
||||
override val isOk: Boolean = true
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
|
||||
|
||||
@Serializable
|
||||
data class AnswerPreCheckoutQueryError(
|
||||
@SerialName(preCheckoutQueryIdField)
|
||||
override val preCheckoutQueryId: PreCheckoutQueryId,
|
||||
@SerialName(errorMessageField)
|
||||
val errorMessage: String
|
||||
) : AnswerPreCheckoutQuery {
|
||||
@SerialName(okField)
|
||||
override val isOk: Boolean = false
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
|
||||
fun PreCheckoutQuery.createAnswerOk(): AnswerPreCheckoutQueryOk = AnswerPreCheckoutQueryOk(
|
||||
id
|
||||
)
|
||||
|
||||
fun PreCheckoutQuery.createAnswerError(
|
||||
error: String
|
||||
): AnswerPreCheckoutQueryError = AnswerPreCheckoutQueryError(
|
||||
id,
|
||||
error
|
||||
)
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.answers.payments
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.answers.payments.abstracts.AnswerShippingQuery
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.payments.ShippingOption
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.payments.ShippingQuery
|
||||
import kotlinx.serialization.*
|
||||
import kotlinx.serialization.internal.ArrayListSerializer
|
||||
|
||||
@Serializable
|
||||
data class AnswerShippingQueryOk(
|
||||
@SerialName(shippingQueryIdField)
|
||||
override val shippingQueryId: ShippingQueryIdentifier,
|
||||
@Serializable(ShippingOptionsSerializer::class)
|
||||
@SerialName(shippingOptionsField)
|
||||
val shippingOptions: List<ShippingOption>
|
||||
) : AnswerShippingQuery {
|
||||
@SerialName(okField)
|
||||
override val isOk: Boolean = true
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
|
||||
object ShippingOptionsSerializer : KSerializer<List<ShippingOption>> by ArrayListSerializer(
|
||||
ShippingOption.serializer()
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class AnswerShippingQueryError(
|
||||
@SerialName(shippingQueryIdField)
|
||||
override val shippingQueryId: ShippingQueryIdentifier,
|
||||
@SerialName(errorMessageField)
|
||||
val error: String
|
||||
) : AnswerShippingQuery {
|
||||
@SerialName(okField)
|
||||
override val isOk: Boolean = false
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
|
||||
fun ShippingQuery.createAnswerOk(
|
||||
shippingOptions: List<ShippingOption>
|
||||
): AnswerShippingQueryOk = AnswerShippingQueryOk(
|
||||
id,
|
||||
shippingOptions
|
||||
)
|
||||
|
||||
fun ShippingQuery.createAnswerError(
|
||||
error: String
|
||||
): AnswerShippingQueryError = AnswerShippingQueryError(
|
||||
id,
|
||||
error
|
||||
)
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.answers.payments.abstracts
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.PreCheckoutQueryId
|
||||
import kotlinx.serialization.KSerializer
|
||||
import kotlinx.serialization.internal.BooleanSerializer
|
||||
import kotlinx.serialization.serializer
|
||||
|
||||
interface AnswerPreCheckoutQuery : SimpleRequest<Boolean> {
|
||||
override fun method(): String = "answerPreCheckoutQuery"
|
||||
override val resultDeserializer: KSerializer<Boolean>
|
||||
get() = BooleanSerializer
|
||||
|
||||
val preCheckoutQueryId: PreCheckoutQueryId
|
||||
val isOk: Boolean
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.answers.payments.abstracts
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ShippingQueryIdentifier
|
||||
import kotlinx.serialization.*
|
||||
import kotlinx.serialization.internal.BooleanSerializer
|
||||
|
||||
interface AnswerShippingQuery : SimpleRequest<Boolean> {
|
||||
override fun method(): String = "answerShippingQuery"
|
||||
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||
get() = BooleanSerializer
|
||||
|
||||
val shippingQueryId: ShippingQueryIdentifier
|
||||
val isOk: Boolean
|
||||
}
|
||||
Reference in New Issue
Block a user