1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-11-24 11:08:43 +00:00

add support of TransactionPartnerTelegramApi

This commit is contained in:
InsanusMokrassar 2024-11-01 14:23:54 +06:00
parent dc463b5626
commit 45bbcb5ec1
2 changed files with 23 additions and 1 deletions

View File

@ -503,6 +503,7 @@ const val currencyField = "currency"
const val startParameterField = "start_parameter"
const val totalAmountField = "total_amount"
const val invoicePayloadField = "invoice_payload"
const val requestCountField = "request_count"
const val paidMediaPayloadField = "paid_media_payload"
const val shippingOptionIdField = "shipping_option_id"
const val shippingQueryIdField = "shipping_query_id"

View File

@ -55,6 +55,22 @@ sealed interface TransactionPartner {
}
}
/**
* Represents [TransactionPartnerTelegramApi](https://core.telegram.org/bots/api#transactionpartnertelegramapi)
*/
@Serializable(TransactionPartner.Companion::class)
data class TelegramAPI(
@SerialName(requestCountField)
val requestCount: Int
) : TransactionPartner {
@EncodeDefault
override val type: String = Companion.type
companion object {
const val type: String = "telegram_api"
}
}
@Serializable(TransactionPartner.Companion::class)
data object Ads : TransactionPartner {
@EncodeDefault
@ -79,7 +95,8 @@ sealed interface TransactionPartner {
val type: String,
val withdrawal_state: RevenueWithdrawalState? = null,
val user: PreviewUser? = null,
val invoice_payload: InvoicePayload? = null
val invoice_payload: InvoicePayload? = null,
val request_count: Int? = null
)
override val descriptor: SerialDescriptor
@ -96,6 +113,9 @@ sealed interface TransactionPartner {
User.type -> User(
data.user ?: return unknown,
)
TelegramAPI.type -> TelegramAPI(
data.request_count ?: return unknown,
)
Ads.type -> Ads
Fragment.type -> Fragment(
data.withdrawal_state ?: return unknown,
@ -109,6 +129,7 @@ sealed interface TransactionPartner {
Other -> Surrogate(value.type)
Ads -> Surrogate(value.type)
is User -> Surrogate(value.type, user = value.user)
is TelegramAPI -> Surrogate(value.type, request_count = value.requestCount)
is Fragment -> Surrogate(
value.type,
value.withdrawalState