diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt index bd47811cc6..324ac6a3a3 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt @@ -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" diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/payments/stars/TransactionPartner.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/payments/stars/TransactionPartner.kt index 5a042b6dde..90cf454d9a 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/payments/stars/TransactionPartner.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/payments/stars/TransactionPartner.kt @@ -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