mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-25 19:48:43 +00:00
maxTipAmounts and suggestedTipAmounts support in SendInvoice
This commit is contained in:
parent
cd30660256
commit
a26568aa29
@ -4,6 +4,7 @@
|
||||
|
||||
* `Core`:
|
||||
* `SendInvoice#startParameter` becomes optional and replaced in `SendInvoice` constructor
|
||||
* Fields `SendInvoice#maxTipAmount` and `SendInvoice#suggestedTipAmounts` have been added
|
||||
|
||||
## 0.33.4
|
||||
|
||||
|
@ -35,6 +35,10 @@ data class SendInvoice(
|
||||
@Serializable(LabeledPricesSerializer::class)
|
||||
@SerialName(pricesField)
|
||||
override val prices: List<LabeledPrice>,
|
||||
@SerialName(maxTipAmountField)
|
||||
val maxTipAmount: Int? = null,
|
||||
@SerialName(suggestedTipAmountsField)
|
||||
val suggestedTipAmounts: List<Int>? = null,
|
||||
@SerialName(startParameterField)
|
||||
val startParameter: StartParameter? = null,
|
||||
@SerialName(providerDataField)
|
||||
@ -88,6 +92,17 @@ data class SendInvoice(
|
||||
var photoHeight: Int? = null
|
||||
private set
|
||||
|
||||
init {
|
||||
suggestedTipAmounts ?.let { _ ->
|
||||
require(suggestedTipAmounts.size in suggestedTipAmountsLimit)
|
||||
maxTipAmount ?.let { _ ->
|
||||
require(
|
||||
suggestedTipAmounts.none { it > maxTipAmount }
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun setPhoto(
|
||||
photoUrl: String,
|
||||
photoSize: Long? = null,
|
||||
|
@ -16,6 +16,8 @@ suspend fun TelegramBot.sendInvoice(
|
||||
providerToken: String,
|
||||
currency: Currency,
|
||||
prices: List<LabeledPrice>,
|
||||
maxTipAmount: Int? = null,
|
||||
suggestedTipAmounts: List<Int>? = null,
|
||||
startParameter: StartParameter? = null,
|
||||
providerData: String? = null,
|
||||
requireName: Boolean = false,
|
||||
@ -30,7 +32,7 @@ suspend fun TelegramBot.sendInvoice(
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = execute(
|
||||
SendInvoice(chatId, title, description, payload, providerToken, currency, prices, startParameter, providerData, requireName, requirePhoneNumber, requireEmail, requireShippingAddress, shouldSendPhoneNumberToProvider, shouldSendEmailToProvider, priceDependOnShipAddress, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
SendInvoice(chatId, title, description, payload, providerToken, currency, prices, maxTipAmount, suggestedTipAmounts ?.sorted(), startParameter, providerData, requireName, requirePhoneNumber, requireEmail, requireShippingAddress, shouldSendPhoneNumberToProvider, shouldSendEmailToProvider, priceDependOnShipAddress, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.sendInvoice(
|
||||
@ -41,6 +43,8 @@ suspend fun TelegramBot.sendInvoice(
|
||||
providerToken: String,
|
||||
currency: Currency,
|
||||
prices: List<LabeledPrice>,
|
||||
maxTipAmount: Int? = null,
|
||||
suggestedTipAmounts: List<Int>? = null,
|
||||
startParameter: StartParameter? = null,
|
||||
providerData: String? = null,
|
||||
requireName: Boolean = false,
|
||||
@ -54,7 +58,7 @@ suspend fun TelegramBot.sendInvoice(
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = sendInvoice(user.id, title, description, payload, providerToken, currency, prices, startParameter, providerData, requireName, requirePhoneNumber, requireEmail, requireShippingAddress, shouldSendPhoneNumberToProvider, shouldSendEmailToProvider, priceDependOnShipAddress, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
) = sendInvoice(user.id, title, description, payload, providerToken, currency, prices, maxTipAmount, suggestedTipAmounts, startParameter, providerData, requireName, requirePhoneNumber, requireEmail, requireShippingAddress, shouldSendPhoneNumberToProvider, shouldSendEmailToProvider, priceDependOnShipAddress, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
suspend inline fun TelegramBot.replyWithInvoice(
|
||||
to: Message,
|
||||
@ -64,6 +68,8 @@ suspend inline fun TelegramBot.replyWithInvoice(
|
||||
providerToken: String,
|
||||
currency: Currency,
|
||||
prices: List<LabeledPrice>,
|
||||
maxTipAmount: Int? = null,
|
||||
suggestedTipAmounts: List<Int>? = null,
|
||||
startParameter: StartParameter? = null,
|
||||
providerData: String? = null,
|
||||
requireName: Boolean = false,
|
||||
@ -76,4 +82,4 @@ suspend inline fun TelegramBot.replyWithInvoice(
|
||||
disableNotification: Boolean = false,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = sendInvoice(to.chat.id, title, description, payload, providerToken, currency, prices, startParameter, providerData, requireName, requirePhoneNumber, requireEmail, requireShippingAddress, shouldSendPhoneNumberToProvider, shouldSendEmailToProvider, priceDependOnShipAddress, disableNotification, to.messageId, allowSendingWithoutReply, replyMarkup)
|
||||
) = sendInvoice(to.chat.id, title, description, payload, providerToken, currency, prices, maxTipAmount, suggestedTipAmounts, startParameter, providerData, requireName, requirePhoneNumber, requireEmail, requireShippingAddress, shouldSendPhoneNumberToProvider, shouldSendEmailToProvider, priceDependOnShipAddress, disableNotification, to.messageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
Loading…
Reference in New Issue
Block a user