commonMain.com.github.insanusmokrassar.TelegramBotAPI.requests.answers.payments.AnswerShippingQuery.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of TelegramBotAPI-jvm Show documentation
Show all versions of TelegramBotAPI-jvm Show documentation
Library for Object-Oriented and type-safe work with Telegram Bot API
package com.github.insanusmokrassar.TelegramBotAPI.requests.answers.payments
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
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
) : AnswerShippingQuery {
@SerialName(okField)
override val isOk: Boolean = true
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
}
internal object ShippingOptionsSerializer : KSerializer> 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
): AnswerShippingQueryOk = AnswerShippingQueryOk(
id,
shippingOptions
)
fun ShippingQuery.createAnswerError(
error: String
): AnswerShippingQueryError = AnswerShippingQueryError(
id,
error
)
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.answerShippingQueryOk(
id: ShippingQueryIdentifier,
shippingOptions: List
) = execute(AnswerShippingQueryOk(id, shippingOptions))
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.answerShippingQueryOk(
shippingQuery: ShippingQuery,
shippingOptions: List
) = answerShippingQueryOk(shippingQuery.id, shippingOptions)
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.answerShippingQueryError(
id: ShippingQueryIdentifier,
error: String
) = execute(AnswerShippingQueryError(id, error))
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.answerShippingQueryError(
shippingQuery: ShippingQuery,
error: String
) = answerShippingQueryError(shippingQuery.id, error)