Update methods to TBA 5.2

This commit is contained in:
Waffle 2021-05-04 16:47:16 +03:00
parent 653c804037
commit 39c497ca1e
5 changed files with 20 additions and 56 deletions

View file

@ -411,45 +411,7 @@ where
send_message, forward_message, copy_message, send_photo, send_audio,
send_document, send_video, send_animation, send_voice, send_video_note,
send_media_group, send_location, send_venue, send_contact, send_poll,
send_dice, send_sticker, => f, fty
}
type SendInvoice = ThrottlingRequest<B::SendInvoice>;
fn send_invoice<T, D, Pa, P, S, C, Pri>(
&self,
chat_id: i32,
title: T,
description: D,
payload: Pa,
provider_token: P,
start_parameter: S,
currency: C,
prices: Pri,
) -> Self::SendInvoice
where
T: Into<String>,
D: Into<String>,
Pa: Into<String>,
P: Into<String>,
S: Into<String>,
C: Into<String>,
Pri: IntoIterator<Item = LabeledPrice>,
{
ThrottlingRequest {
request: self.inner().send_invoice(
chat_id,
title,
description,
payload,
provider_token,
start_parameter,
currency,
prices,
),
chat_id: |p| ChatIdHash::Id(p.payload_ref().chat_id as _),
worker: self.queue.clone(),
}
send_dice, send_sticker, send_invoice => f, fty
}
requester_forward! {

View file

@ -875,23 +875,22 @@ impl Requester for Bot {
type SendInvoice = JsonRequest<payloads::SendInvoice>;
fn send_invoice<T, D, Pa, P, S, C, Pri>(
fn send_invoice<Ch, T, D, Pa, P, C, Pri>(
&self,
chat_id: i32,
chat_id: Ch,
title: T,
description: D,
payload: Pa,
provider_token: P,
start_parameter: S,
currency: C,
prices: Pri,
) -> Self::SendInvoice
where
Ch: Into<ChatId>,
T: Into<String>,
D: Into<String>,
Pa: Into<String>,
P: Into<String>,
S: Into<String>,
C: Into<String>,
Pri: IntoIterator<Item = LabeledPrice>,
{
@ -903,7 +902,6 @@ impl Requester for Bot {
description,
payload,
provider_token,
start_parameter,
currency,
prices,
),

View file

@ -1040,15 +1040,15 @@ macro_rules! requester_forward {
(@method send_invoice $body:ident $ty:ident) => {
type SendInvoice = $ty![SendInvoice];
fn send_invoice<T, D, Pa, P, S, C, Pri>(&self, chat_id: i32, title: T, description: D, payload: Pa, provider_token: P, start_parameter: S, currency: C, prices: Pri) -> Self::SendInvoice where T: Into<String>,
fn send_invoice<Ch, T, D, Pa, P, C, Pri>(&self, chat_id: Ch, title: T, description: D, payload: Pa, provider_token: P, currency: C, prices: Pri) -> Self::SendInvoice where Ch: Into<ChatId>,
T: Into<String>,
D: Into<String>,
Pa: Into<String>,
P: Into<String>,
S: Into<String>,
C: Into<String>,
Pri: IntoIterator<Item = LabeledPrice> {
let this = self;
$body!(send_invoice this (chat_id: i32, title: T, description: D, payload: Pa, provider_token: P, start_parameter: S, currency: C, prices: Pri))
$body!(send_invoice this (chat_id: Ch, title: T, description: D, payload: Pa, provider_token: P, currency: C, prices: Pri))
}
};
(@method answer_shipping_query $body:ident $ty:ident) => {

View file

@ -8,7 +8,7 @@
// [`schema`]: https://github.com/WaffleLapkin/tg-methods-schema
use serde::Serialize;
use crate::types::{InlineKeyboardMarkup, LabeledPrice, Message};
use crate::types::{ChatId, InlineKeyboardMarkup, LabeledPrice, Message};
impl_payload! {
/// Use this method to send invoices. On success, the sent [`Message`] is returned.
@ -18,7 +18,7 @@ impl_payload! {
pub SendInvoice (SendInvoiceSetters) => Message {
required {
/// Unique identifier for the target private chat
pub chat_id: i32,
pub chat_id: ChatId [into],
/// Product name, 1-32 characters
pub title: String [into],
/// Product description, 1-255 characters
@ -29,14 +29,20 @@ impl_payload! {
///
/// [Botfather]: https://t.me/botfather
pub provider_token: String [into],
/// Unique deep-linking parameter that can be used to generate this invoice when used as a start parameter
pub start_parameter: String [into],
/// Three-letter ISO 4217 currency code, see more on currencies
pub currency: String [into],
/// Price breakdown, a JSON-serialized list of components (e.g. product price, tax, discount, delivery cost, delivery tax, bonus, etc.)
pub prices: Vec<LabeledPrice> [collect],
}
optional {
/// The maximum accepted amount for tips in the smallest units of the currency (integer, **not** float/double). For example, for a maximum tip of `US$ 1.45` pass `max_tip_amount = 145`. See the exp parameter in [`currencies.json`], it shows the number of digits past the decimal point for each currency (2 for the majority of currencies). Defaults to 0
///
/// [`currencies.json`]: https://core.telegram.org/bots/payments/currencies.json
pub max_tip_amount: u32,
/// A JSON-serialized array of suggested amounts of tips in the smallest units of the currency (integer, **not** float/double). At most 4 suggested tip amounts can be specified. The suggested tip amounts must be positive, passed in a strictly increased order and must not exceed _max_tip_amount_.
pub suggested_tip_amounts: Vec<u32> [collect],
/// Unique deep-linking parameter. If left empty, **forwarded copies** of the sent message will have a Pay button, allowing multiple users to pay directly from the forwarded message, using the same invoice. If non-empty, forwarded copies of the sent message will have a URL button with a deep link to the bot (instead of a Pay button), with the value used as the start parameter
pub start_parameter: String [into],
/// A JSON-serialized data about the invoice, which will be shared with the payment provider. A detailed description of required fields should be provided by the payment provider.
pub provider_data: String [into],
/// URL of the product photo for the invoice. Can be a photo of the goods or a marketing image for a service. People like it better when they see what they are paying for.

View file

@ -60,7 +60,6 @@ pub trait Requester {
//
// [cg]: https://github.com/teloxide/cg
// [`schema`]: https://github.com/WaffleLapkin/tg-methods-schema
type GetUpdates: Request<Payload = GetUpdates, Err = Self::Err>;
/// For Telegram documentation see [`GetUpdates`].
@ -723,23 +722,22 @@ pub trait Requester {
type SendInvoice: Request<Payload = SendInvoice, Err = Self::Err>;
/// For Telegram documentation see [`SendInvoice`].
fn send_invoice<T, D, Pa, P, S, C, Pri>(
fn send_invoice<Ch, T, D, Pa, P, C, Pri>(
&self,
chat_id: i32,
chat_id: Ch,
title: T,
description: D,
payload: Pa,
provider_token: P,
start_parameter: S,
currency: C,
prices: Pri,
) -> Self::SendInvoice
where
Ch: Into<ChatId>,
T: Into<String>,
D: Into<String>,
Pa: Into<String>,
P: Into<String>,
S: Into<String>,
C: Into<String>,
Pri: IntoIterator<Item = LabeledPrice>;