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
use crate::client::Bot;
use serde::Serialize;
/// Returns the gifts owned and hosted by a user. Returns [`crate::types::OwnedGifts`] on success.
/// # Documentation
/// <https://core.telegram.org/bots/api#getusergifts>
/// # Returns
/// - `crate::types::OwnedGifts`
#[derive(Clone, Debug, Serialize)]
pub struct GetUserGifts {
/// Unique identifier of the user
pub user_id: i64,
/// Pass `true` to exclude gifts that can be purchased an unlimited number of times
#[serde(skip_serializing_if = "Option::is_none")]
pub exclude_unlimited: Option<bool>,
/// Pass `true` to exclude gifts that can be purchased a limited number of times and can be upgraded to unique
#[serde(skip_serializing_if = "Option::is_none")]
pub exclude_limited_upgradable: Option<bool>,
/// Pass `true` to exclude gifts that can be purchased a limited number of times and can't be upgraded to unique
#[serde(skip_serializing_if = "Option::is_none")]
pub exclude_limited_non_upgradable: Option<bool>,
/// Pass `true` to exclude gifts that were assigned from the TON blockchain and can't be resold or transferred in Telegram
#[serde(skip_serializing_if = "Option::is_none")]
pub exclude_from_blockchain: Option<bool>,
/// Pass `true` to exclude unique gifts
#[serde(skip_serializing_if = "Option::is_none")]
pub exclude_unique: Option<bool>,
/// Pass `true` to sort results by gift price instead of send date. Sorting is applied before pagination.
#[serde(skip_serializing_if = "Option::is_none")]
pub sort_by_price: Option<bool>,
/// Offset of the first entry to return as received from the previous request; use an empty string to get the first chunk of results
#[serde(skip_serializing_if = "Option::is_none")]
pub offset: Option<Box<str>>,
/// The maximum number of gifts to be returned; 1-100. Defaults to 100
#[serde(skip_serializing_if = "Option::is_none")]
pub limit: Option<u8>,
}
impl GetUserGifts {
/// Creates a new `GetUserGifts`.
///
/// # Arguments
/// * `user_id` - Unique identifier of the user
///
/// # Notes
/// Use builder methods to set optional fields.
#[must_use]
pub fn new<T0: Into<i64>>(user_id: T0) -> Self {
Self {
user_id: user_id.into(),
exclude_unlimited: None,
exclude_limited_upgradable: None,
exclude_limited_non_upgradable: None,
exclude_from_blockchain: None,
exclude_unique: None,
sort_by_price: None,
offset: None,
limit: None,
}
}
/// Unique identifier of the user
#[must_use]
pub fn user_id<T: Into<i64>>(mut self, val: T) -> Self {
self.user_id = val.into();
self
}
/// Pass `true` to exclude gifts that can be purchased an unlimited number of times
#[must_use]
pub fn exclude_unlimited<T: Into<bool>>(mut self, val: T) -> Self {
self.exclude_unlimited = Some(val.into());
self
}
/// Pass `true` to exclude gifts that can be purchased an unlimited number of times
#[must_use]
pub fn exclude_unlimited_option<T: Into<bool>>(mut self, val: Option<T>) -> Self {
self.exclude_unlimited = val.map(Into::into);
self
}
/// Pass `true` to exclude gifts that can be purchased a limited number of times and can be upgraded to unique
#[must_use]
pub fn exclude_limited_upgradable<T: Into<bool>>(mut self, val: T) -> Self {
self.exclude_limited_upgradable = Some(val.into());
self
}
/// Pass `true` to exclude gifts that can be purchased a limited number of times and can be upgraded to unique
#[must_use]
pub fn exclude_limited_upgradable_option<T: Into<bool>>(mut self, val: Option<T>) -> Self {
self.exclude_limited_upgradable = val.map(Into::into);
self
}
/// Pass `true` to exclude gifts that can be purchased a limited number of times and can't be upgraded to unique
#[must_use]
pub fn exclude_limited_non_upgradable<T: Into<bool>>(mut self, val: T) -> Self {
self.exclude_limited_non_upgradable = Some(val.into());
self
}
/// Pass `true` to exclude gifts that can be purchased a limited number of times and can't be upgraded to unique
#[must_use]
pub fn exclude_limited_non_upgradable_option<T: Into<bool>>(mut self, val: Option<T>) -> Self {
self.exclude_limited_non_upgradable = val.map(Into::into);
self
}
/// Pass `true` to exclude gifts that were assigned from the TON blockchain and can't be resold or transferred in Telegram
#[must_use]
pub fn exclude_from_blockchain<T: Into<bool>>(mut self, val: T) -> Self {
self.exclude_from_blockchain = Some(val.into());
self
}
/// Pass `true` to exclude gifts that were assigned from the TON blockchain and can't be resold or transferred in Telegram
#[must_use]
pub fn exclude_from_blockchain_option<T: Into<bool>>(mut self, val: Option<T>) -> Self {
self.exclude_from_blockchain = val.map(Into::into);
self
}
/// Pass `true` to exclude unique gifts
#[must_use]
pub fn exclude_unique<T: Into<bool>>(mut self, val: T) -> Self {
self.exclude_unique = Some(val.into());
self
}
/// Pass `true` to exclude unique gifts
#[must_use]
pub fn exclude_unique_option<T: Into<bool>>(mut self, val: Option<T>) -> Self {
self.exclude_unique = val.map(Into::into);
self
}
/// Pass `true` to sort results by gift price instead of send date. Sorting is applied before pagination.
#[must_use]
pub fn sort_by_price<T: Into<bool>>(mut self, val: T) -> Self {
self.sort_by_price = Some(val.into());
self
}
/// Pass `true` to sort results by gift price instead of send date. Sorting is applied before pagination.
#[must_use]
pub fn sort_by_price_option<T: Into<bool>>(mut self, val: Option<T>) -> Self {
self.sort_by_price = val.map(Into::into);
self
}
/// Offset of the first entry to return as received from the previous request; use an empty string to get the first chunk of results
#[must_use]
pub fn offset<T: Into<Box<str>>>(mut self, val: T) -> Self {
self.offset = Some(val.into());
self
}
/// Offset of the first entry to return as received from the previous request; use an empty string to get the first chunk of results
#[must_use]
pub fn offset_option<T: Into<Box<str>>>(mut self, val: Option<T>) -> Self {
self.offset = val.map(Into::into);
self
}
/// The maximum number of gifts to be returned; 1-100. Defaults to 100
#[must_use]
pub fn limit<T: Into<u8>>(mut self, val: T) -> Self {
self.limit = Some(val.into());
self
}
/// The maximum number of gifts to be returned; 1-100. Defaults to 100
#[must_use]
pub fn limit_option<T: Into<u8>>(mut self, val: Option<T>) -> Self {
self.limit = val.map(Into::into);
self
}
}
impl super::TelegramMethod for GetUserGifts {
type Method = Self;
type Return = crate::types::OwnedGifts;
fn build_request<Client>(self, _bot: &Bot<Client>) -> super::Request<Self::Method> {
super::Request::new("getUserGifts", self, None)
}
}