1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-11-26 03:58:44 +00:00

InputInvoiceMessageContent

This commit is contained in:
InsanusMokrassar 2021-04-26 20:23:26 +06:00
parent a26568aa29
commit 6a3588bb8d
6 changed files with 147 additions and 25 deletions

View File

@ -5,6 +5,7 @@
* `Core`: * `Core`:
* `SendInvoice#startParameter` becomes optional and replaced in `SendInvoice` constructor * `SendInvoice#startParameter` becomes optional and replaced in `SendInvoice` constructor
* Fields `SendInvoice#maxTipAmount` and `SendInvoice#suggestedTipAmounts` have been added * Fields `SendInvoice#maxTipAmount` and `SendInvoice#suggestedTipAmounts` have been added
* New type `InputInvoiceMessageContent` has been added
## 0.33.4 ## 0.33.4

View File

@ -0,0 +1,35 @@
package dev.inmo.tgbotapi.CommonAbstracts
import dev.inmo.tgbotapi.types.payments.abstracts.*
interface CommonSendInvoiceData : Titled, Currencied, Priced {
val description: String
val payload: String
val providerToken: String
val maxTipAmount: Int?
val suggestedTipAmounts: List<Int>?
val providerData: String?
val requireName: Boolean
val requirePhoneNumber: Boolean
val requireEmail: Boolean
val requireShippingAddress: Boolean
val shouldSendPhoneNumberToProvider: Boolean
val shouldSendEmailToProvider: Boolean
val priceDependOnShipAddress: Boolean
val photoUrl: String?
val photoSize: Long?
val photoWidth: Int?
val photoHeight: Int?
fun setPhoto(
photoUrl: String,
photoSize: Long? = null,
photoWidth: Int? = null,
photoHeight: Int? = null
)
fun unsetPhoto()
}

View File

@ -1,5 +1,6 @@
package dev.inmo.tgbotapi.requests.send.payments package dev.inmo.tgbotapi.requests.send.payments
import dev.inmo.tgbotapi.CommonAbstracts.CommonSendInvoiceData
import dev.inmo.tgbotapi.CommonAbstracts.types.* import dev.inmo.tgbotapi.CommonAbstracts.types.*
import dev.inmo.tgbotapi.requests.send.abstracts.SendMessageRequest import dev.inmo.tgbotapi.requests.send.abstracts.SendMessageRequest
import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.*
@ -23,40 +24,40 @@ data class SendInvoice(
@SerialName(chatIdField) @SerialName(chatIdField)
override val chatId: ChatId, override val chatId: ChatId,
@SerialName(titleField) @SerialName(titleField)
val title: String, override val title: String,
@SerialName(descriptionField) @SerialName(descriptionField)
val description: String, override val description: String,
@SerialName(payloadField) @SerialName(payloadField)
val payload: String, override val payload: String,
@SerialName(providerTokenField) @SerialName(providerTokenField)
val providerToken: String, override val providerToken: String,
@SerialName(currencyField) @SerialName(currencyField)
override val currency: Currency, override val currency: Currency,
@Serializable(LabeledPricesSerializer::class) @Serializable(LabeledPricesSerializer::class)
@SerialName(pricesField) @SerialName(pricesField)
override val prices: List<LabeledPrice>, override val prices: List<LabeledPrice>,
@SerialName(maxTipAmountField) @SerialName(maxTipAmountField)
val maxTipAmount: Int? = null, override val maxTipAmount: Int? = null,
@SerialName(suggestedTipAmountsField) @SerialName(suggestedTipAmountsField)
val suggestedTipAmounts: List<Int>? = null, override val suggestedTipAmounts: List<Int>? = null,
@SerialName(startParameterField) @SerialName(startParameterField)
val startParameter: StartParameter? = null, val startParameter: StartParameter? = null,
@SerialName(providerDataField) @SerialName(providerDataField)
val providerData: String? = null, override val providerData: String? = null,
@SerialName(requireNameField) @SerialName(requireNameField)
val requireName: Boolean = false, override val requireName: Boolean = false,
@SerialName(requirePhoneNumberField) @SerialName(requirePhoneNumberField)
val requirePhoneNumber: Boolean = false, override val requirePhoneNumber: Boolean = false,
@SerialName(requireEmailField) @SerialName(requireEmailField)
val requireEmail: Boolean = false, override val requireEmail: Boolean = false,
@SerialName(requireShippingAddressField) @SerialName(requireShippingAddressField)
val requireShippingAddress: Boolean = false, override val requireShippingAddress: Boolean = false,
@SerialName(shouldSendPhoneNumberToProviderField) @SerialName(shouldSendPhoneNumberToProviderField)
val shouldSendPhoneNumberToProvider: Boolean = false, override val shouldSendPhoneNumberToProvider: Boolean = false,
@SerialName(shouldSendEmailToProviderField) @SerialName(shouldSendEmailToProviderField)
val shouldSendEmailToProvider: Boolean = false, override val shouldSendEmailToProvider: Boolean = false,
@SerialName(priceDependOnShipAddressField) @SerialName(priceDependOnShipAddressField)
val priceDependOnShipAddress: Boolean = false, override val priceDependOnShipAddress: Boolean = false,
@SerialName(disableNotificationField) @SerialName(disableNotificationField)
override val disableNotification: Boolean = false, override val disableNotification: Boolean = false,
@SerialName(replyToMessageIdField) @SerialName(replyToMessageIdField)
@ -65,8 +66,7 @@ data class SendInvoice(
override val allowSendingWithoutReply: Boolean? = null, override val allowSendingWithoutReply: Boolean? = null,
@SerialName(replyMarkupField) @SerialName(replyMarkupField)
override val replyMarkup: InlineKeyboardMarkup? = null override val replyMarkup: InlineKeyboardMarkup? = null
) : Currencied, ) : CommonSendInvoiceData,
Priced,
ChatRequest, ChatRequest,
DisableNotification, DisableNotification,
ReplyMessageId, ReplyMessageId,
@ -79,17 +79,17 @@ data class SendInvoice(
get() = serializer() get() = serializer()
@SerialName(photoUrlField) @SerialName(photoUrlField)
var photoUrl: String? = null override var photoUrl: String? = null
private set private set
@SerialName(photoSizeField) @SerialName(photoSizeField)
var photoSize: Long? = null override var photoSize: Long? = null
private set private set
@SerialName(photoWidthField) @SerialName(photoWidthField)
var photoWidth: Int? = null override var photoWidth: Int? = null
private set private set
@SerialName(photoHeightField) @SerialName(photoHeightField)
var photoHeight: Int? = null override var photoHeight: Int? = null
private set private set
init { init {
@ -103,11 +103,11 @@ data class SendInvoice(
} }
} }
fun setPhoto( override fun setPhoto(
photoUrl: String, photoUrl: String,
photoSize: Long? = null, photoSize: Long?,
photoWidth: Int? = null, photoWidth: Int?,
photoHeight: Int? = null photoHeight: Int?
) { ) {
this.photoUrl = photoUrl this.photoUrl = photoUrl
this.photoSize = photoSize this.photoSize = photoSize
@ -115,7 +115,7 @@ data class SendInvoice(
this.photoHeight = photoHeight this.photoHeight = photoHeight
} }
fun unsetPhoto() { override fun unsetPhoto() {
photoUrl = null photoUrl = null
photoSize = null photoSize = null
photoWidth = null photoWidth = null

View File

@ -80,6 +80,8 @@ val openPeriodPollSecondsLimit = 5 .. 600
val membersLimit = 1 .. 99999 val membersLimit = 1 .. 99999
val suggestedTipAmountsLimit = 1 .. 4
const val botActionActualityTime: Seconds = 5 const val botActionActualityTime: Seconds = 5
// Made as lazy for correct work in K/JS // Made as lazy for correct work in K/JS
@ -315,6 +317,9 @@ const val xShiftField = "x_shift"
const val yShiftField = "y_shift" const val yShiftField = "y_shift"
const val scaleField = "scale" const val scaleField = "scale"
const val maxTipAmountField = "max_tip_amount"
const val suggestedTipAmountsField = "suggested_tip_amounts"
const val explanationEntitiesField = "explanation_entities" const val explanationEntitiesField = "explanation_entities"
const val explanationParseModeField = "explanation_parse_mode" const val explanationParseModeField = "explanation_parse_mode"
const val openPeriodField = "open_period" const val openPeriodField = "open_period"

View File

@ -0,0 +1,80 @@
package dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent
import dev.inmo.tgbotapi.CommonAbstracts.CommonSendInvoiceData
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.InlineQueries.abstracts.InputMessageContent
import dev.inmo.tgbotapi.types.payments.LabeledPrice
import dev.inmo.tgbotapi.types.payments.LabeledPricesSerializer
import dev.inmo.tgbotapi.types.payments.abstracts.Currency
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
@Serializable
class InputInvoiceMessageContent(
@SerialName(titleField)
override val title: String,
@SerialName(descriptionField)
override val description: String,
@SerialName(payloadField)
override val payload: String,
@SerialName(providerTokenField)
override val providerToken: String,
@SerialName(currencyField)
override val currency: Currency,
@Serializable(LabeledPricesSerializer::class)
@SerialName(pricesField)
override val prices: List<LabeledPrice>,
@SerialName(maxTipAmountField)
override val maxTipAmount: Int? = null,
@SerialName(suggestedTipAmountsField)
override val suggestedTipAmounts: List<Int>? = null,
@SerialName(providerDataField)
override val providerData: String? = null,
@SerialName(requireNameField)
override val requireName: Boolean = false,
@SerialName(requirePhoneNumberField)
override val requirePhoneNumber: Boolean = false,
@SerialName(requireEmailField)
override val requireEmail: Boolean = false,
@SerialName(requireShippingAddressField)
override val requireShippingAddress: Boolean = false,
@SerialName(shouldSendPhoneNumberToProviderField)
override val shouldSendPhoneNumberToProvider: Boolean = false,
@SerialName(shouldSendEmailToProviderField)
override val shouldSendEmailToProvider: Boolean = false,
@SerialName(priceDependOnShipAddressField)
override val priceDependOnShipAddress: Boolean = false
) : InputMessageContent, CommonSendInvoiceData {
@SerialName(photoUrlField)
override var photoUrl: String? = null
private set
@SerialName(photoSizeField)
override var photoSize: Long? = null
private set
@SerialName(photoWidthField)
override var photoWidth: Int? = null
private set
@SerialName(photoHeightField)
override var photoHeight: Int? = null
private set
override fun setPhoto(
photoUrl: String,
photoSize: Long?,
photoWidth: Int?,
photoHeight: Int?
) {
this.photoUrl = photoUrl
this.photoSize = photoSize
this.photoWidth = photoWidth
this.photoHeight = photoHeight
}
override fun unsetPhoto() {
photoUrl = null
photoSize = null
photoWidth = null
photoHeight = null
}
}

View File

@ -17,6 +17,7 @@ internal object InputMessageContentSerializer : KSerializer<InputMessageContent>
is InputLocationMessageContent -> InputLocationMessageContent.serializer().serialize(encoder, value) is InputLocationMessageContent -> InputLocationMessageContent.serializer().serialize(encoder, value)
is InputTextMessageContent -> InputTextMessageContent.serializer().serialize(encoder, value) is InputTextMessageContent -> InputTextMessageContent.serializer().serialize(encoder, value)
is InputVenueMessageContent -> InputVenueMessageContent.serializer().serialize(encoder, value) is InputVenueMessageContent -> InputVenueMessageContent.serializer().serialize(encoder, value)
is InputInvoiceMessageContent -> InputInvoiceMessageContent.serializer().serialize(encoder, value)
else -> throw IllegalArgumentException("Unknown for serializing InputContactMessageContent") else -> throw IllegalArgumentException("Unknown for serializing InputContactMessageContent")
} }
} }