diff --git a/CHANGELOG.md b/CHANGELOG.md index 6a0e26ee31..7ca5dcc7a9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -43,6 +43,9 @@ * Now it is possible to get updates by polling with custom executor engine * `CommonMultipartFileRequest` now is internal * Added `LiveLocation` class for more useful tracking live locations +* `InvoiceOfPayment` now is `MessageContent` instead of `PaymentInfo` +* `SendInvoice` now return `ContentMessage` +* `paymentInfo` inside of `CommonMessageImpl` now can be set only to `SuccessfulPaymentInfo` ## 0.22.0 diff --git a/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/payments/SendInvoice.kt b/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/payments/SendInvoice.kt index 6367daf221..8a54257331 100644 --- a/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/payments/SendInvoice.kt +++ b/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/payments/SendInvoice.kt @@ -5,13 +5,18 @@ import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.SendMessageRequest import com.github.insanusmokrassar.TelegramBotAPI.types.* import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup -import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message +import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.* import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy +import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.media.PhotoContent +import com.github.insanusmokrassar.TelegramBotAPI.types.message.payments.InvoiceOfPayment import com.github.insanusmokrassar.TelegramBotAPI.types.payments.LabeledPrice import com.github.insanusmokrassar.TelegramBotAPI.types.payments.LabeledPricesSerializer import com.github.insanusmokrassar.TelegramBotAPI.types.payments.abstracts.* import kotlinx.serialization.* +private val invoiceMessageSerializer: DeserializationStrategy> + = TelegramBotAPIMessageDeserializationStrategyClass() + /** * @param providerData - JSON-ENCODED FIELD */ @@ -62,10 +67,10 @@ data class SendInvoice( DisableNotification, ReplyMessageId, ReplyMarkup, - SendMessageRequest { + SendMessageRequest> { override fun method(): String = "sendInvoice" - override val resultDeserializer: DeserializationStrategy - get() = TelegramBotAPIMessageDeserializationStrategy + override val resultDeserializer: DeserializationStrategy> + get() = invoiceMessageSerializer override val requestSerializer: SerializationStrategy<*> get() = serializer() diff --git a/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/CommonMessageImpl.kt b/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/CommonMessageImpl.kt index d54fcec119..3dd4192b14 100644 --- a/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/CommonMessageImpl.kt +++ b/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/CommonMessageImpl.kt @@ -6,6 +6,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMa import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.* import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MessageContent +import com.github.insanusmokrassar.TelegramBotAPI.types.message.payments.SuccessfulPaymentInfo import com.github.insanusmokrassar.TelegramBotAPI.types.message.payments.abstracts.PaymentInfo import com.soywiz.klock.DateTime @@ -19,5 +20,5 @@ data class CommonMessageImpl( override val forwardInfo: ForwardInfo?, override val replyTo: Message?, override val replyMarkup: InlineKeyboardMarkup?, - val paymentInfo: PaymentInfo? + val paymentInfo: SuccessfulPaymentInfo? ) : Message, CommonMessage, FromUserMessage \ No newline at end of file diff --git a/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/RawMessage.kt b/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/RawMessage.kt index a900382e94..05877079c7 100644 --- a/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/RawMessage.kt +++ b/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/RawMessage.kt @@ -130,6 +130,7 @@ internal data class RawMessage( location != null -> LocationContent(location) venue != null -> VenueContent(venue) poll != null -> PollContent(poll) + invoice != null -> InvoiceOfPayment(invoice) else -> null } } @@ -175,9 +176,8 @@ internal data class RawMessage( } } - private val paymentInfo: PaymentInfo? by lazy { + private val paymentInfo: SuccessfulPaymentInfo? by lazy { when { - invoice != null -> InvoiceOfPayment(invoice) successful_payment != null -> SuccessfulPaymentInfo(successful_payment) else -> null } diff --git a/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/payments/InvoiceOfPayment.kt b/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/payments/InvoiceOfPayment.kt index 7f90a9f438..3c177554af 100644 --- a/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/payments/InvoiceOfPayment.kt +++ b/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/payments/InvoiceOfPayment.kt @@ -1,8 +1,26 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.message.payments +import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.Request +import com.github.insanusmokrassar.TelegramBotAPI.requests.send.payments.SendInvoice +import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier +import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier +import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup +import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage +import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message +import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MessageContent import com.github.insanusmokrassar.TelegramBotAPI.types.message.payments.abstracts.PaymentInfo import com.github.insanusmokrassar.TelegramBotAPI.types.payments.Invoice data class InvoiceOfPayment( val invoice: Invoice -) : PaymentInfo +) : MessageContent { + override fun createResend( + chatId: ChatIdentifier, + disableNotification: Boolean, + replyToMessageId: MessageIdentifier?, + replyMarkup: KeyboardMarkup? + ): Request> { + error("Unfortunately, currently InvoiceOfPayment can not be resend due to requirement of additional parameters," + + " which can't be provided during the call of this method") + } +}