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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
use serde::{Deserialize, Serialize};
/// This object represents a premium giveaway.
/// # Notes
/// This object represents a giveaway from original giveaway type `premium`.
/// # Documentation
/// <https://core.telegram.org/bots/api#giveaway>
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct GiveawayPremium {
/// The list of chats which the user must join to participate in the giveaway
pub chats: Box<[crate::types::Chat]>,
/// Point in time (Unix timestamp) when winners of the giveaway will be selected
pub winners_selection_date: i64,
/// The number of users which are supposed to be selected as winners of the giveaway
pub winner_count: i64,
/// `true`, if only users who join the chats after the giveaway started should be eligible to win
#[serde(skip_serializing_if = "Option::is_none")]
pub only_new_members: Option<bool>,
/// `true`, if the list of giveaway winners will be visible to everyone
#[serde(skip_serializing_if = "Option::is_none")]
pub has_public_winners: Option<bool>,
/// Description of additional giveaway prize
#[serde(skip_serializing_if = "Option::is_none")]
pub prize_description: Option<Box<str>>,
/// A list of two-letter ISO 3166-1 alpha-2 country codes indicating the countries from which eligible users for the giveaway must come. If empty, then all users can participate in the giveaway. Users with a phone number that was bought on Fragment can always participate in giveaways.
#[serde(skip_serializing_if = "Option::is_none")]
pub country_codes: Option<Box<[Box<str>]>>,
/// The number of months the Telegram Premium subscription won from the giveaway will be active for; for Telegram Premium giveaways only
pub premium_subscription_month_count: i64,
}
impl GiveawayPremium {
/// Creates a new `GiveawayPremium`.
///
/// # Arguments
/// * `chats` - The list of chats which the user must join to participate in the giveaway
/// * `winners_selection_date` - Point in time (Unix timestamp) when winners of the giveaway will be selected
/// * `winner_count` - The number of users which are supposed to be selected as winners of the giveaway
/// * `premium_subscription_month_count` - The number of months the Telegram Premium subscription won from the giveaway will be active for; for Telegram Premium giveaways only
///
/// # Notes
/// Use builder methods to set optional fields.
#[must_use]
pub fn new<
T0Item: Into<crate::types::Chat>,
T0: IntoIterator<Item = T0Item>,
T1: Into<i64>,
T2: Into<i64>,
T3: Into<i64>,
>(
chats: T0,
winners_selection_date: T1,
winner_count: T2,
premium_subscription_month_count: T3,
) -> Self {
Self {
chats: chats.into_iter().map(Into::into).collect(),
winners_selection_date: winners_selection_date.into(),
winner_count: winner_count.into(),
only_new_members: None,
has_public_winners: None,
prize_description: None,
country_codes: None,
premium_subscription_month_count: premium_subscription_month_count.into(),
}
}
/// The list of chats which the user must join to participate in the giveaway
///
/// # Notes
/// Adds multiple elements.
#[must_use]
pub fn chats<T: Into<Box<[crate::types::Chat]>>>(self, val: T) -> Self {
let mut this = self;
this.chats = this
.chats
.into_vec()
.into_iter()
.chain(val.into())
.collect();
this
}
/// The list of chats which the user must join to participate in the giveaway
///
/// # Notes
/// Adds a single element.
#[must_use]
pub fn chat<T: Into<crate::types::Chat>>(self, val: T) -> Self {
let mut this = self;
this.chats = this
.chats
.into_vec()
.into_iter()
.chain(Some(val.into()))
.collect();
this
}
/// Point in time (Unix timestamp) when winners of the giveaway will be selected
#[must_use]
pub fn winners_selection_date<T: Into<i64>>(self, val: T) -> Self {
let mut this = self;
this.winners_selection_date = val.into();
this
}
/// The number of users which are supposed to be selected as winners of the giveaway
#[must_use]
pub fn winner_count<T: Into<i64>>(self, val: T) -> Self {
let mut this = self;
this.winner_count = val.into();
this
}
/// `true`, if only users who join the chats after the giveaway started should be eligible to win
#[must_use]
pub fn only_new_members<T: Into<bool>>(self, val: T) -> Self {
let mut this = self;
this.only_new_members = Some(val.into());
this
}
/// `true`, if only users who join the chats after the giveaway started should be eligible to win
#[must_use]
pub fn only_new_members_option<T: Into<bool>>(self, val: Option<T>) -> Self {
let mut this = self;
this.only_new_members = val.map(Into::into);
this
}
/// `true`, if the list of giveaway winners will be visible to everyone
#[must_use]
pub fn has_public_winners<T: Into<bool>>(self, val: T) -> Self {
let mut this = self;
this.has_public_winners = Some(val.into());
this
}
/// `true`, if the list of giveaway winners will be visible to everyone
#[must_use]
pub fn has_public_winners_option<T: Into<bool>>(self, val: Option<T>) -> Self {
let mut this = self;
this.has_public_winners = val.map(Into::into);
this
}
/// Description of additional giveaway prize
#[must_use]
pub fn prize_description<T: Into<Box<str>>>(self, val: T) -> Self {
let mut this = self;
this.prize_description = Some(val.into());
this
}
/// Description of additional giveaway prize
#[must_use]
pub fn prize_description_option<T: Into<Box<str>>>(self, val: Option<T>) -> Self {
let mut this = self;
this.prize_description = val.map(Into::into);
this
}
/// A list of two-letter ISO 3166-1 alpha-2 country codes indicating the countries from which eligible users for the giveaway must come. If empty, then all users can participate in the giveaway. Users with a phone number that was bought on Fragment can always participate in giveaways.
///
/// # Notes
/// Adds multiple elements.
#[must_use]
pub fn country_codes<T: Into<Box<[Box<str>]>>>(self, val: T) -> Self {
let mut this = self;
this.country_codes = Some(
this.country_codes
.unwrap_or_default()
.into_vec()
.into_iter()
.chain(val.into())
.collect(),
);
this
}
/// A list of two-letter ISO 3166-1 alpha-2 country codes indicating the countries from which eligible users for the giveaway must come. If empty, then all users can participate in the giveaway. Users with a phone number that was bought on Fragment can always participate in giveaways.
///
/// # Notes
/// Adds a single element.
#[must_use]
pub fn country_code<T: Into<Box<str>>>(self, val: T) -> Self {
let mut this = self;
this.country_codes = Some(
this.country_codes
.unwrap_or_default()
.into_vec()
.into_iter()
.chain(Some(val.into()))
.collect(),
);
this
}
/// A list of two-letter ISO 3166-1 alpha-2 country codes indicating the countries from which eligible users for the giveaway must come. If empty, then all users can participate in the giveaway. Users with a phone number that was bought on Fragment can always participate in giveaways.
///
/// # Notes
/// Adds a single element.
#[must_use]
pub fn country_codes_option<T: Into<Box<[Box<str>]>>>(self, val: Option<T>) -> Self {
let mut this = self;
this.country_codes = val.map(Into::into);
this
}
/// The number of months the Telegram Premium subscription won from the giveaway will be active for; for Telegram Premium giveaways only
#[must_use]
pub fn premium_subscription_month_count<T: Into<i64>>(self, val: T) -> Self {
let mut this = self;
this.premium_subscription_month_count = val.into();
this
}
}