1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
use crate::client::Bot;
use serde::Serialize;
/// Use this method to create a subscription invite link for a channel chat. The bot must have the `can_invite_users` administrator rights. The link can be edited using the method editChatSubscriptionInviteLink or revoked using the method revokeChatInviteLink. Returns the new invite link as a [`crate::types::ChatInviteLink`] object.
/// # Documentation
/// <https://core.telegram.org/bots/api#createchatsubscriptioninvitelink>
/// # Returns
/// - `crate::types::ChatInviteLink`
#[derive(Clone, Debug, Serialize)]
pub struct CreateChatSubscriptionInviteLink {
/// Unique identifier for the target channel chat or username of the target channel (in the format @channelusername)
pub chat_id: crate::types::ChatIdKind,
/// Invite link name; 0-32 characters
#[serde(skip_serializing_if = "Option::is_none")]
pub name: Option<Box<str>>,
/// The number of seconds the subscription will be active for before the next payment. Currently, it must always be 2592000 (30 days).
pub subscription_period: i64,
/// The amount of Telegram Stars a user must pay initially and after each subsequent subscription period to be a member of the chat; 1-10000
pub subscription_price: u16,
}
impl CreateChatSubscriptionInviteLink {
/// Creates a new `CreateChatSubscriptionInviteLink`.
///
/// # Arguments
/// * `chat_id` - Unique identifier for the target channel chat or username of the target channel (in the format @channelusername)
/// * `subscription_period` - The number of seconds the subscription will be active for before the next payment. Currently, it must always be 2592000 (30 days).
/// * `subscription_price` - The amount of Telegram Stars a user must pay initially and after each subsequent subscription period to be a member of the chat; 1-10000
///
/// # Notes
/// Use builder methods to set optional fields.
#[must_use]
pub fn new<T0: Into<crate::types::ChatIdKind>, T1: Into<i64>, T2: Into<u16>>(
chat_id: T0,
subscription_period: T1,
subscription_price: T2,
) -> Self {
Self {
chat_id: chat_id.into(),
name: None,
subscription_period: subscription_period.into(),
subscription_price: subscription_price.into(),
}
}
/// Unique identifier for the target channel chat or username of the target channel (in the format @channelusername)
#[must_use]
pub fn chat_id<T: Into<crate::types::ChatIdKind>>(self, val: T) -> Self {
let mut this = self;
this.chat_id = val.into();
this
}
/// Invite link name; 0-32 characters
#[must_use]
pub fn name<T: Into<Box<str>>>(self, val: T) -> Self {
let mut this = self;
this.name = Some(val.into());
this
}
/// Invite link name; 0-32 characters
#[must_use]
pub fn name_option<T: Into<Box<str>>>(self, val: Option<T>) -> Self {
let mut this = self;
this.name = val.map(Into::into);
this
}
/// The number of seconds the subscription will be active for before the next payment. Currently, it must always be 2592000 (30 days).
#[must_use]
pub fn subscription_period<T: Into<i64>>(self, val: T) -> Self {
let mut this = self;
this.subscription_period = val.into();
this
}
/// The amount of Telegram Stars a user must pay initially and after each subsequent subscription period to be a member of the chat; 1-10000
#[must_use]
pub fn subscription_price<T: Into<u16>>(self, val: T) -> Self {
let mut this = self;
this.subscription_price = val.into();
this
}
}
impl super::TelegramMethod for CreateChatSubscriptionInviteLink {
type Method = Self;
type Return = crate::types::ChatInviteLink;
fn build_request<Client>(self, _bot: &Bot<Client>) -> super::Request<Self::Method> {
super::Request::new("createChatSubscriptionInviteLink", self, None)
}
}