Skip to content

Commit

Permalink
feat: add method sendPaidMedia
Browse files Browse the repository at this point in the history
  • Loading branch information
pxp9 committed Jul 5, 2024
1 parent afd7d02 commit c94c448
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 4 deletions.
47 changes: 43 additions & 4 deletions src/api_params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ use crate::objects::{
InlineQueryResultCachedVoice, InlineQueryResultContact, InlineQueryResultDocument,
InlineQueryResultGame, InlineQueryResultGif, InlineQueryResultLocation,
InlineQueryResultMpeg4Gif, InlineQueryResultPhoto, InlineQueryResultVenue,
InlineQueryResultVideo, InlineQueryResultVoice, InputPollOption, InputSticker, LabeledPrice,
LinkPreviewOptions, MaskPosition, MenuButton, MessageEntity, PassportElementErrorDataField,
PassportElementErrorFile, PassportElementErrorFiles, PassportElementErrorFrontSide,
PassportElementErrorReverseSide, PassportElementErrorSelfie,
InlineQueryResultVideo, InlineQueryResultVoice, InputPaidMedia, InputPollOption, InputSticker,
LabeledPrice, LinkPreviewOptions, MaskPosition, MenuButton, MessageEntity,
PassportElementErrorDataField, PassportElementErrorFile, PassportElementErrorFiles,
PassportElementErrorFrontSide, PassportElementErrorReverseSide, PassportElementErrorSelfie,
PassportElementErrorTranslationFile, PassportElementErrorTranslationFiles,
PassportElementErrorUnspecified, PollType, ReactionType, ReplyKeyboardMarkup,
ReplyKeyboardRemove, ShippingOption, StickerFormat, StickerType, WebAppInfo,
Expand Down Expand Up @@ -2796,6 +2796,45 @@ pub struct UnpinAllGeneralForumTopicMessagesParams {
pub chat_id: ChatId,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Builder)]
pub struct SendPaidMediaParams {
pub chat_id: ChatId,
pub star_count: i32,
pub media: Vec<InputPaidMedia>,

#[serde(skip_serializing_if = "Option::is_none")]
#[builder(setter(into, strip_option), default)]
pub caption: Option<String>,

#[serde(skip_serializing_if = "Option::is_none")]
#[builder(setter(into, strip_option), default)]
pub parse_mode: Option<String>,

#[serde(skip_serializing_if = "Option::is_none")]
#[builder(setter(into, strip_option), default)]
pub caption_entities: Option<Vec<MessageEntity>>,

#[serde(skip_serializing_if = "Option::is_none")]
#[builder(setter(into, strip_option), default)]
pub show_caption_above_media: Option<bool>,

#[serde(skip_serializing_if = "Option::is_none")]
#[builder(setter(into, strip_option), default)]
pub disable_notification: Option<bool>,

#[serde(skip_serializing_if = "Option::is_none")]
#[builder(setter(into, strip_option), default)]
pub protect_content: Option<bool>,

#[serde(skip_serializing_if = "Option::is_none")]
#[builder(setter(into, strip_option), default)]
pub reply_parameters: Option<ReplyParameters>,

#[serde(skip_serializing_if = "Option::is_none")]
#[builder(setter(into, strip_option), default)]
pub reply_markup: Option<ReplyMarkup>,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Builder)]
pub struct ReplyParameters {
pub message_id: i32,
Expand Down
8 changes: 8 additions & 0 deletions src/api_traits/async_telegram_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ use crate::api_params::SendInvoiceParams;
use crate::api_params::SendLocationParams;
use crate::api_params::SendMediaGroupParams;
use crate::api_params::SendMessageParams;
use crate::api_params::SendPaidMediaParams;
use crate::api_params::SendPhotoParams;
use crate::api_params::SendPollParams;
use crate::api_params::SendStickerParams;
Expand Down Expand Up @@ -1361,6 +1362,13 @@ pub trait AsyncTelegramApi {
.await
}

async fn send_paid_media(
&self,
params: SendPaidMediaParams,
) -> Result<MethodResponse<Message>, Self::Error> {
self.request("sendPaidMedia", Some(params)).await
}

async fn request_without_body<T: serde::de::DeserializeOwned>(
&self,
method: &str,
Expand Down
8 changes: 8 additions & 0 deletions src/api_traits/telegram_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ use crate::api_params::SendInvoiceParams;
use crate::api_params::SendLocationParams;
use crate::api_params::SendMediaGroupParams;
use crate::api_params::SendMessageParams;
use crate::api_params::SendPaidMediaParams;
use crate::api_params::SendPhotoParams;
use crate::api_params::SendPollParams;
use crate::api_params::SendStickerParams;
Expand Down Expand Up @@ -1298,6 +1299,13 @@ pub trait TelegramApi {
self.request("unpinAllGeneralForumTopicMessages", Some(params))
}

fn send_paid_media(
&self,
params: SendPaidMediaParams,
) -> Result<MethodResponse<Message>, Self::Error> {
self.request("sendPaidMedia", Some(params))
}

fn request_without_body<T: serde::de::DeserializeOwned>(
&self,
method: &str,
Expand Down

0 comments on commit c94c448

Please sign in to comment.