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`:
|
* `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
|
||||||
|
|
||||||
## 0.33.4
|
## 0.33.4
|
||||||
|
|
||||||
|
@ -35,6 +35,10 @@ data class SendInvoice(
|
|||||||
@Serializable(LabeledPricesSerializer::class)
|
@Serializable(LabeledPricesSerializer::class)
|
||||||
@SerialName(pricesField)
|
@SerialName(pricesField)
|
||||||
override val prices: List<LabeledPrice>,
|
override val prices: List<LabeledPrice>,
|
||||||
|
@SerialName(maxTipAmountField)
|
||||||
|
val maxTipAmount: Int? = null,
|
||||||
|
@SerialName(suggestedTipAmountsField)
|
||||||
|
val suggestedTipAmounts: List<Int>? = null,
|
||||||
@SerialName(startParameterField)
|
@SerialName(startParameterField)
|
||||||
val startParameter: StartParameter? = null,
|
val startParameter: StartParameter? = null,
|
||||||
@SerialName(providerDataField)
|
@SerialName(providerDataField)
|
||||||
@ -88,6 +92,17 @@ data class SendInvoice(
|
|||||||
var photoHeight: Int? = null
|
var photoHeight: Int? = null
|
||||||
private set
|
private set
|
||||||
|
|
||||||
|
init {
|
||||||
|
suggestedTipAmounts ?.let { _ ->
|
||||||
|
require(suggestedTipAmounts.size in suggestedTipAmountsLimit)
|
||||||
|
maxTipAmount ?.let { _ ->
|
||||||
|
require(
|
||||||
|
suggestedTipAmounts.none { it > maxTipAmount }
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun setPhoto(
|
fun setPhoto(
|
||||||
photoUrl: String,
|
photoUrl: String,
|
||||||
photoSize: Long? = null,
|
photoSize: Long? = null,
|
||||||
|
@ -16,6 +16,8 @@ suspend fun TelegramBot.sendInvoice(
|
|||||||
providerToken: String,
|
providerToken: String,
|
||||||
currency: Currency,
|
currency: Currency,
|
||||||
prices: List<LabeledPrice>,
|
prices: List<LabeledPrice>,
|
||||||
|
maxTipAmount: Int? = null,
|
||||||
|
suggestedTipAmounts: List<Int>? = null,
|
||||||
startParameter: StartParameter? = null,
|
startParameter: StartParameter? = null,
|
||||||
providerData: String? = null,
|
providerData: String? = null,
|
||||||
requireName: Boolean = false,
|
requireName: Boolean = false,
|
||||||
@ -30,7 +32,7 @@ suspend fun TelegramBot.sendInvoice(
|
|||||||
allowSendingWithoutReply: Boolean? = null,
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
replyMarkup: InlineKeyboardMarkup? = null
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
) = execute(
|
) = 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(
|
suspend fun TelegramBot.sendInvoice(
|
||||||
@ -41,6 +43,8 @@ suspend fun TelegramBot.sendInvoice(
|
|||||||
providerToken: String,
|
providerToken: String,
|
||||||
currency: Currency,
|
currency: Currency,
|
||||||
prices: List<LabeledPrice>,
|
prices: List<LabeledPrice>,
|
||||||
|
maxTipAmount: Int? = null,
|
||||||
|
suggestedTipAmounts: List<Int>? = null,
|
||||||
startParameter: StartParameter? = null,
|
startParameter: StartParameter? = null,
|
||||||
providerData: String? = null,
|
providerData: String? = null,
|
||||||
requireName: Boolean = false,
|
requireName: Boolean = false,
|
||||||
@ -54,7 +58,7 @@ suspend fun TelegramBot.sendInvoice(
|
|||||||
replyToMessageId: MessageIdentifier? = null,
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
replyMarkup: InlineKeyboardMarkup? = 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(
|
suspend inline fun TelegramBot.replyWithInvoice(
|
||||||
to: Message,
|
to: Message,
|
||||||
@ -64,6 +68,8 @@ suspend inline fun TelegramBot.replyWithInvoice(
|
|||||||
providerToken: String,
|
providerToken: String,
|
||||||
currency: Currency,
|
currency: Currency,
|
||||||
prices: List<LabeledPrice>,
|
prices: List<LabeledPrice>,
|
||||||
|
maxTipAmount: Int? = null,
|
||||||
|
suggestedTipAmounts: List<Int>? = null,
|
||||||
startParameter: StartParameter? = null,
|
startParameter: StartParameter? = null,
|
||||||
providerData: String? = null,
|
providerData: String? = null,
|
||||||
requireName: Boolean = false,
|
requireName: Boolean = false,
|
||||||
@ -76,4 +82,4 @@ suspend inline fun TelegramBot.replyWithInvoice(
|
|||||||
disableNotification: Boolean = false,
|
disableNotification: Boolean = false,
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
replyMarkup: InlineKeyboardMarkup? = 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