telegram_bot_api/
methods.rs

1use serde::{Deserialize, Serialize};
2use std::collections::HashMap;
3use std::fmt::Debug;
4
5use crate::types;
6
7/// request param interface
8pub trait Params {
9    fn params(&self) -> Result<types::Params, Box<dyn std::error::Error>>;
10}
11
12/// available methods interface
13pub trait Methods: Params {
14    fn endpoint(&self) -> String;
15    fn files(&self) -> HashMap<String, types::InputFile> {
16        HashMap::new()
17    }
18}
19
20/// impl params for any method
21impl<T> Params for T
22where
23    T: Serialize,
24{
25    fn params(&self) -> Result<types::Params, Box<dyn std::error::Error>> {
26        Ok(serde_json::from_str(serde_json::to_string(self)?.as_str()).unwrap())
27    }
28}
29
30/// A simple method for testing your bot's authentication token. Requires no parameters. Returns basic information about the bot in form of a User object.
31#[derive(Deserialize, Serialize, Debug, Clone)]
32pub struct GetMe {}
33impl GetMe {
34    pub fn new() -> Self {
35        Self {}
36    }
37}
38
39impl Methods for GetMe {
40    fn endpoint(&self) -> String {
41        "getMe".to_string()
42    }
43}
44
45/// Use this method to log out from the cloud Bot API server before launching the bot locally. You must log out the bot before running it locally, otherwise there is no guarantee that the bot will receive updates. After a successful call, you can immediately log in on a local server, but will not be able to log in back to the cloud Bot API server for 10 minutes. Returns True on success. Requires no parameters.
46#[derive(Deserialize, Serialize, Debug, Clone)]
47pub struct LogOut {}
48impl LogOut {
49    pub fn new() -> Self {
50        Self {}
51    }
52}
53
54impl Methods for LogOut {
55    fn endpoint(&self) -> String {
56        "logOut".to_string()
57    }
58}
59
60/// Use this method to close the bot instance before moving it from one local server to another. You need to delete the webhook before calling this method to ensure that the bot isn't launched again after server restart. The method will error 429 in the first 10 minutes after the bot is launched. Returns True on success. Requires no parameters.
61#[derive(Deserialize, Serialize, Debug, Clone)]
62pub struct Close {}
63impl Close {
64    pub fn new() -> Self {
65        Self {}
66    }
67}
68
69impl Methods for Close {
70    fn endpoint(&self) -> String {
71        "close".to_string()
72    }
73}
74
75/// Use this method to send text messages. On success, the sent Message is returned.
76#[derive(Deserialize, Serialize, Debug, Clone)]
77pub struct SendMessage {
78    /// Unique identifier for the target chat or username of the target channel (in the format @channelusername)
79    pub chat_id: types::ChatId,
80    /// Text of the message to be sent, 1-4096 characters after entities parsing
81    pub text: String,
82    /// Mode for parsing entities in the message text. See formatting options for more details.
83    #[serde(skip_serializing_if = "Option::is_none")]
84    pub parse_mode: Option<String>,
85    /// A JSON-serialized list of special entities that appear in message text, which can be specified instead of parse_mode
86    #[serde(skip_serializing_if = "Option::is_none")]
87    pub entities: Option<Vec<types::MessageEntity>>,
88    /// Disables link previews for links in this message
89    #[serde(skip_serializing_if = "Option::is_none")]
90    pub disable_web_page_preview: Option<bool>,
91    /// Sends the message silently. Users will receive a notification with no sound.
92    #[serde(skip_serializing_if = "Option::is_none")]
93    pub disable_notification: Option<bool>,
94    /// Protects the contents of the sent message from forwarding and saving
95    #[serde(skip_serializing_if = "Option::is_none")]
96    pub protect_content: Option<bool>,
97    /// If the message is a reply, ID of the original message
98    #[serde(skip_serializing_if = "Option::is_none")]
99    pub reply_to_message_id: Option<i64>,
100    /// Pass True if the message should be sent even if the specified replied-to message is not found
101    #[serde(skip_serializing_if = "Option::is_none")]
102    pub allow_sending_without_reply: Option<bool>,
103    /// Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.
104    #[serde(skip_serializing_if = "Option::is_none")]
105    pub reply_markup: Option<types::ReplyMarkup>,
106}
107impl SendMessage {
108    pub fn new(chat_id: types::ChatId, text: String) -> Self {
109        Self {
110            chat_id,
111            text,
112            parse_mode: None,
113            entities: None,
114            disable_web_page_preview: None,
115            disable_notification: None,
116            protect_content: None,
117            reply_to_message_id: None,
118            allow_sending_without_reply: None,
119            reply_markup: None,
120        }
121    }
122}
123
124impl Methods for SendMessage {
125    fn endpoint(&self) -> String {
126        "sendMessage".to_string()
127    }
128}
129
130/// Use this method to forward messages of any kind. Service messages can't be forwarded. On success, the sent Message is returned.
131#[derive(Deserialize, Serialize, Debug, Clone)]
132pub struct ForwardMessage {
133    /// Unique identifier for the target chat or username of the target channel (in the format @channelusername)
134    pub chat_id: types::ChatId,
135    /// Unique identifier for the chat where the original message was sent (or channel username in the format @channelusername)
136    pub from_chat_id: types::ChatId,
137    /// Sends the message silently. Users will receive a notification with no sound.
138    #[serde(skip_serializing_if = "Option::is_none")]
139    pub disable_notification: Option<bool>,
140    /// Protects the contents of the forwarded message from forwarding and saving
141    #[serde(skip_serializing_if = "Option::is_none")]
142    pub protect_content: Option<bool>,
143    /// Message identifier in the chat specified in from_chat_id
144    pub message_id: i64,
145}
146impl ForwardMessage {
147    pub fn new(chat_id: types::ChatId, from_chat_id: types::ChatId, message_id: i64) -> Self {
148        Self {
149            chat_id,
150            from_chat_id,
151            disable_notification: None,
152            protect_content: None,
153            message_id,
154        }
155    }
156}
157
158impl Methods for ForwardMessage {
159    fn endpoint(&self) -> String {
160        "forwardMessage".to_string()
161    }
162}
163
164/// Use this method to copy messages of any kind. Service messages and invoice messages can't be copied. A quiz poll can be copied only if the value of the field correct_option_id is known to the bot. The method is analogous to the method forwardMessage, but the copied message doesn't have a link to the original message. Returns the MessageId of the sent message on success.
165#[derive(Deserialize, Serialize, Debug, Clone)]
166pub struct CopyMessage {
167    /// Unique identifier for the target chat or username of the target channel (in the format @channelusername)
168    pub chat_id: types::ChatId,
169    /// Unique identifier for the chat where the original message was sent (or channel username in the format @channelusername)
170    pub from_chat_id: types::ChatId,
171    /// Message identifier in the chat specified in from_chat_id
172    pub message_id: i64,
173    /// New caption for media, 0-1024 characters after entities parsing. If not specified, the original caption is kept
174    #[serde(skip_serializing_if = "Option::is_none")]
175    pub caption: Option<String>,
176    /// Mode for parsing entities in the new caption. See formatting options for more details.
177    #[serde(skip_serializing_if = "Option::is_none")]
178    pub parse_mode: Option<String>,
179    /// A JSON-serialized list of special entities that appear in the new caption, which can be specified instead of parse_mode
180    #[serde(skip_serializing_if = "Option::is_none")]
181    pub caption_entities: Option<Vec<types::MessageEntity>>,
182    /// Sends the message silently. Users will receive a notification with no sound.
183    #[serde(skip_serializing_if = "Option::is_none")]
184    pub disable_notification: Option<bool>,
185    /// Protects the contents of the sent message from forwarding and saving
186    #[serde(skip_serializing_if = "Option::is_none")]
187    pub protect_content: Option<bool>,
188    /// If the message is a reply, ID of the original message
189    #[serde(skip_serializing_if = "Option::is_none")]
190    pub reply_to_message_id: Option<i64>,
191    /// Pass True if the message should be sent even if the specified replied-to message is not found
192    #[serde(skip_serializing_if = "Option::is_none")]
193    pub allow_sending_without_reply: Option<bool>,
194    /// Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.
195    #[serde(skip_serializing_if = "Option::is_none")]
196    pub reply_markup: Option<types::ReplyMarkup>,
197}
198impl CopyMessage {
199    pub fn new(chat_id: types::ChatId, from_chat_id: types::ChatId, message_id: i64) -> Self {
200        Self {
201            chat_id,
202            from_chat_id,
203            message_id,
204            caption: None,
205            parse_mode: None,
206            caption_entities: None,
207            disable_notification: None,
208            protect_content: None,
209            reply_to_message_id: None,
210            allow_sending_without_reply: None,
211            reply_markup: None,
212        }
213    }
214}
215
216impl Methods for CopyMessage {
217    fn endpoint(&self) -> String {
218        "copyMessage".to_string()
219    }
220}
221
222/// Use this method to send photos. On success, the sent Message is returned.
223#[derive(Deserialize, Serialize, Debug, Clone)]
224pub struct SendPhoto {
225    /// Unique identifier for the target chat or username of the target channel (in the format @channelusername)
226    pub chat_id: types::ChatId,
227    /// Photo to send. Pass a file_id as String to send a photo that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a photo from the Internet, or upload a new photo using multipart/form-data. The photo must be at most 10 MB in size. The photo's width and height must not exceed 10000 in total. Width and height ratio must be at most 20. More information on Sending Files »
228    #[serde(skip_serializing)]
229    pub photo: types::InputFile,
230    /// Photo caption (may also be used when resending photos by file_id), 0-1024 characters after entities parsing
231    #[serde(skip_serializing_if = "Option::is_none")]
232    pub caption: Option<String>,
233    /// Mode for parsing entities in the photo caption. See formatting options for more details.
234    #[serde(skip_serializing_if = "Option::is_none")]
235    pub parse_mode: Option<String>,
236    /// A JSON-serialized list of special entities that appear in the caption, which can be specified instead of parse_mode
237    #[serde(skip_serializing_if = "Option::is_none")]
238    pub caption_entities: Option<Vec<types::MessageEntity>>,
239    /// Sends the message silently. Users will receive a notification with no sound.
240    #[serde(skip_serializing_if = "Option::is_none")]
241    pub disable_notification: Option<bool>,
242    /// Protects the contents of the sent message from forwarding and saving
243    #[serde(skip_serializing_if = "Option::is_none")]
244    pub protect_content: Option<bool>,
245    /// If the message is a reply, ID of the original message
246    #[serde(skip_serializing_if = "Option::is_none")]
247    pub reply_to_message_id: Option<i64>,
248    /// Pass True if the message should be sent even if the specified replied-to message is not found
249    #[serde(skip_serializing_if = "Option::is_none")]
250    pub allow_sending_without_reply: Option<bool>,
251    /// Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.
252    #[serde(skip_serializing_if = "Option::is_none")]
253    pub reply_markup: Option<types::ReplyMarkup>,
254}
255impl SendPhoto {
256    pub fn new(chat_id: types::ChatId, photo: types::InputFile) -> Self {
257        Self {
258            chat_id,
259            photo,
260            caption: None,
261            parse_mode: None,
262            caption_entities: None,
263            disable_notification: None,
264            protect_content: None,
265            reply_to_message_id: None,
266            allow_sending_without_reply: None,
267            reply_markup: None,
268        }
269    }
270}
271
272impl Methods for SendPhoto {
273    fn endpoint(&self) -> String {
274        "sendPhoto".to_string()
275    }
276    fn files(&self) -> HashMap<String, types::InputFile> {
277        let mut result = HashMap::new();
278        result.insert("photo".to_string(), self.photo.clone());
279        result
280    }
281}
282
283/// Use this method to send audio files, if you want Telegram clients to display them in the music player. Your audio must be in the .MP3 or .M4A format. On success, the sent Message is returned. Bots can currently send audio files of up to 50 MB in size, this limit may be changed in the future.
284#[derive(Deserialize, Serialize, Debug, Clone)]
285pub struct SendAudio {
286    /// Unique identifier for the target chat or username of the target channel (in the format @channelusername)
287    pub chat_id: types::ChatId,
288    /// Audio file to send. Pass a file_id as String to send an audio file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get an audio file from the Internet, or upload a new one using multipart/form-data. More information on Sending Files »
289    #[serde(skip_serializing)]
290    pub audio: types::InputFile,
291    /// Audio caption, 0-1024 characters after entities parsing
292    #[serde(skip_serializing_if = "Option::is_none")]
293    pub caption: Option<String>,
294    /// Mode for parsing entities in the audio caption. See formatting options for more details.
295    #[serde(skip_serializing_if = "Option::is_none")]
296    pub parse_mode: Option<String>,
297    /// A JSON-serialized list of special entities that appear in the caption, which can be specified instead of parse_mode
298    #[serde(skip_serializing_if = "Option::is_none")]
299    pub caption_entities: Option<Vec<types::MessageEntity>>,
300    /// Duration of the audio in seconds
301    #[serde(skip_serializing_if = "Option::is_none")]
302    pub duration: Option<i64>,
303    /// Performer
304    #[serde(skip_serializing_if = "Option::is_none")]
305    pub performer: Option<String>,
306    /// Track name
307    #[serde(skip_serializing_if = "Option::is_none")]
308    pub title: Option<String>,
309    /// Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail's width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can't be reused and can be only uploaded as a new file, so you can pass “attach://<file_attach_name>” if the thumbnail was uploaded using multipart/form-data under <file_attach_name>. More information on Sending Files »
310    #[serde(skip_serializing_if = "Option::is_none")]
311    pub thumb: Option<types::InputFile>,
312    /// Sends the message silently. Users will receive a notification with no sound.
313    #[serde(skip_serializing_if = "Option::is_none")]
314    pub disable_notification: Option<bool>,
315    /// Protects the contents of the sent message from forwarding and saving
316    #[serde(skip_serializing_if = "Option::is_none")]
317    pub protect_content: Option<bool>,
318    /// If the message is a reply, ID of the original message
319    #[serde(skip_serializing_if = "Option::is_none")]
320    pub reply_to_message_id: Option<i64>,
321    /// Pass True if the message should be sent even if the specified replied-to message is not found
322    #[serde(skip_serializing_if = "Option::is_none")]
323    pub allow_sending_without_reply: Option<bool>,
324    /// Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.
325    #[serde(skip_serializing_if = "Option::is_none")]
326    pub reply_markup: Option<types::ReplyMarkup>,
327}
328impl SendAudio {
329    pub fn new(chat_id: types::ChatId, audio: types::InputFile) -> Self {
330        Self {
331            chat_id,
332            audio,
333            caption: None,
334            parse_mode: None,
335            caption_entities: None,
336            duration: None,
337            performer: None,
338            title: None,
339            thumb: None,
340            disable_notification: None,
341            protect_content: None,
342            reply_to_message_id: None,
343            allow_sending_without_reply: None,
344            reply_markup: None,
345        }
346    }
347}
348
349impl Methods for SendAudio {
350    fn endpoint(&self) -> String {
351        "sendAudio".to_string()
352    }
353    fn files(&self) -> HashMap<String, types::InputFile> {
354        let mut result = HashMap::new();
355        result.insert("audio".to_string(), self.audio.clone());
356        if let Some(thumb) = &self.thumb {
357            result.insert("thumb".to_string(), thumb.clone());
358        }
359        result
360    }
361}
362
363/// Use this method to send general files. On success, the sent Message is returned. Bots can currently send files of any type of up to 50 MB in size, this limit may be changed in the future.
364#[derive(Deserialize, Serialize, Debug, Clone)]
365pub struct SendDocument {
366    /// Unique identifier for the target chat or username of the target channel (in the format @channelusername)
367    pub chat_id: types::ChatId,
368    /// File to send. Pass a file_id as String to send a file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data. More information on Sending Files »
369    #[serde(skip_serializing)]
370    pub document: types::InputFile,
371    /// Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail's width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can't be reused and can be only uploaded as a new file, so you can pass “attach://<file_attach_name>” if the thumbnail was uploaded using multipart/form-data under <file_attach_name>. More information on Sending Files »
372    #[serde(skip_serializing_if = "Option::is_none")]
373    pub thumb: Option<types::InputFile>,
374    /// Document caption (may also be used when resending documents by file_id), 0-1024 characters after entities parsing
375    #[serde(skip_serializing_if = "Option::is_none")]
376    pub caption: Option<String>,
377    /// Mode for parsing entities in the document caption. See formatting options for more details.
378    #[serde(skip_serializing_if = "Option::is_none")]
379    pub parse_mode: Option<String>,
380    /// A JSON-serialized list of special entities that appear in the caption, which can be specified instead of parse_mode
381    #[serde(skip_serializing_if = "Option::is_none")]
382    pub caption_entities: Option<Vec<types::MessageEntity>>,
383    /// Disables automatic server-side content type detection for files uploaded using multipart/form-data
384    #[serde(skip_serializing_if = "Option::is_none")]
385    pub disable_content_type_detection: Option<bool>,
386    /// Sends the message silently. Users will receive a notification with no sound.
387    #[serde(skip_serializing_if = "Option::is_none")]
388    pub disable_notification: Option<bool>,
389    /// Protects the contents of the sent message from forwarding and saving
390    #[serde(skip_serializing_if = "Option::is_none")]
391    pub protect_content: Option<bool>,
392    /// If the message is a reply, ID of the original message
393    #[serde(skip_serializing_if = "Option::is_none")]
394    pub reply_to_message_id: Option<i64>,
395    /// Pass True if the message should be sent even if the specified replied-to message is not found
396    #[serde(skip_serializing_if = "Option::is_none")]
397    pub allow_sending_without_reply: Option<bool>,
398    /// Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.
399    #[serde(skip_serializing_if = "Option::is_none")]
400    pub reply_markup: Option<types::ReplyMarkup>,
401}
402impl SendDocument {
403    pub fn new(chat_id: types::ChatId, document: types::InputFile) -> Self {
404        Self {
405            chat_id,
406            document,
407            thumb: None,
408            caption: None,
409            parse_mode: None,
410            caption_entities: None,
411            disable_content_type_detection: None,
412            disable_notification: None,
413            protect_content: None,
414            reply_to_message_id: None,
415            allow_sending_without_reply: None,
416            reply_markup: None,
417        }
418    }
419}
420
421impl Methods for SendDocument {
422    fn endpoint(&self) -> String {
423        "sendDocument".to_string()
424    }
425
426    fn files(&self) -> HashMap<String, types::InputFile> {
427        let mut result = HashMap::new();
428        result.insert("document".to_string(), self.document.clone());
429        if let Some(thumb) = &self.thumb {
430            result.insert("thumb".to_string(), thumb.clone());
431        }
432        result
433    }
434}
435
436/// Use this method to send video files, Telegram clients support MPEG4 videos (other formats may be sent as Document). On success, the sent Message is returned. Bots can currently send video files of up to 50 MB in size, this limit may be changed in the future.
437#[derive(Deserialize, Serialize, Debug, Clone)]
438pub struct SendVideo {
439    /// Unique identifier for the target chat or username of the target channel (in the format @channelusername)
440    pub chat_id: types::ChatId,
441    /// Video to send. Pass a file_id as String to send a video that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a video from the Internet, or upload a new video using multipart/form-data. More information on Sending Files »
442    #[serde(skip_serializing)]
443    pub video: types::InputFile,
444    /// Duration of sent video in seconds
445    #[serde(skip_serializing_if = "Option::is_none")]
446    pub duration: Option<i64>,
447    /// Video width
448    #[serde(skip_serializing_if = "Option::is_none")]
449    pub width: Option<i64>,
450    /// Video height
451    #[serde(skip_serializing_if = "Option::is_none")]
452    pub height: Option<i64>,
453    /// Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail's width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can't be reused and can be only uploaded as a new file, so you can pass “attach://<file_attach_name>” if the thumbnail was uploaded using multipart/form-data under <file_attach_name>. More information on Sending Files »
454    #[serde(skip_serializing_if = "Option::is_none")]
455    pub thumb: Option<types::InputFile>,
456    /// Video caption (may also be used when resending videos by file_id), 0-1024 characters after entities parsing
457    #[serde(skip_serializing_if = "Option::is_none")]
458    pub caption: Option<String>,
459    /// Mode for parsing entities in the video caption. See formatting options for more details.
460    #[serde(skip_serializing_if = "Option::is_none")]
461    pub parse_mode: Option<String>,
462    /// A JSON-serialized list of special entities that appear in the caption, which can be specified instead of parse_mode
463    #[serde(skip_serializing_if = "Option::is_none")]
464    pub caption_entities: Option<Vec<types::MessageEntity>>,
465    /// Pass True if the uploaded video is suitable for streaming
466    #[serde(skip_serializing_if = "Option::is_none")]
467    pub supports_streaming: Option<bool>,
468    /// Sends the message silently. Users will receive a notification with no sound.
469    #[serde(skip_serializing_if = "Option::is_none")]
470    pub disable_notification: Option<bool>,
471    /// Protects the contents of the sent message from forwarding and saving
472    #[serde(skip_serializing_if = "Option::is_none")]
473    pub protect_content: Option<bool>,
474    /// If the message is a reply, ID of the original message
475    #[serde(skip_serializing_if = "Option::is_none")]
476    pub reply_to_message_id: Option<i64>,
477    /// Pass True if the message should be sent even if the specified replied-to message is not found
478    #[serde(skip_serializing_if = "Option::is_none")]
479    pub allow_sending_without_reply: Option<bool>,
480    /// Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.
481    #[serde(skip_serializing_if = "Option::is_none")]
482    pub reply_markup: Option<types::ReplyMarkup>,
483}
484impl SendVideo {
485    pub fn new(chat_id: types::ChatId, video: types::InputFile) -> Self {
486        Self {
487            chat_id,
488            video,
489            duration: None,
490            width: None,
491            height: None,
492            thumb: None,
493            caption: None,
494            parse_mode: None,
495            caption_entities: None,
496            supports_streaming: None,
497            disable_notification: None,
498            protect_content: None,
499            reply_to_message_id: None,
500            allow_sending_without_reply: None,
501            reply_markup: None,
502        }
503    }
504}
505
506impl Methods for SendVideo {
507    fn endpoint(&self) -> String {
508        "sendVideo".to_string()
509    }
510
511    fn files(&self) -> HashMap<String, types::InputFile> {
512        let mut result = HashMap::new();
513        result.insert("video".to_string(), self.video.clone());
514        if let Some(thumb) = &self.thumb {
515            result.insert("thumb".to_string(), thumb.clone());
516        }
517        result
518    }
519}
520
521/// Use this method to send animation files (GIF or H.264/MPEG-4 AVC video without sound). On success, the sent Message is returned. Bots can currently send animation files of up to 50 MB in size, this limit may be changed in the future.
522#[derive(Deserialize, Serialize, Debug, Clone)]
523pub struct SendAnimation {
524    /// Unique identifier for the target chat or username of the target channel (in the format @channelusername)
525    pub chat_id: types::ChatId,
526    /// Animation to send. Pass a file_id as String to send an animation that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get an animation from the Internet, or upload a new animation using multipart/form-data. More information on Sending Files »
527    #[serde(skip_serializing)]
528    pub animation: types::InputFile,
529    /// Duration of sent animation in seconds
530    #[serde(skip_serializing_if = "Option::is_none")]
531    pub duration: Option<i64>,
532    /// Animation width
533    #[serde(skip_serializing_if = "Option::is_none")]
534    pub width: Option<i64>,
535    /// Animation height
536    #[serde(skip_serializing_if = "Option::is_none")]
537    pub height: Option<i64>,
538    /// Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail's width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can't be reused and can be only uploaded as a new file, so you can pass “attach://<file_attach_name>” if the thumbnail was uploaded using multipart/form-data under <file_attach_name>. More information on Sending Files »
539    #[serde(skip_serializing_if = "Option::is_none")]
540    pub thumb: Option<types::InputFile>,
541    /// Animation caption (may also be used when resending animation by file_id), 0-1024 characters after entities parsing
542    #[serde(skip_serializing_if = "Option::is_none")]
543    pub caption: Option<String>,
544    /// Mode for parsing entities in the animation caption. See formatting options for more details.
545    #[serde(skip_serializing_if = "Option::is_none")]
546    pub parse_mode: Option<String>,
547    /// A JSON-serialized list of special entities that appear in the caption, which can be specified instead of parse_mode
548    #[serde(skip_serializing_if = "Option::is_none")]
549    pub caption_entities: Option<Vec<types::MessageEntity>>,
550    /// Sends the message silently. Users will receive a notification with no sound.
551    #[serde(skip_serializing_if = "Option::is_none")]
552    pub disable_notification: Option<bool>,
553    /// Protects the contents of the sent message from forwarding and saving
554    #[serde(skip_serializing_if = "Option::is_none")]
555    pub protect_content: Option<bool>,
556    /// If the message is a reply, ID of the original message
557    #[serde(skip_serializing_if = "Option::is_none")]
558    pub reply_to_message_id: Option<i64>,
559    /// Pass True if the message should be sent even if the specified replied-to message is not found
560    #[serde(skip_serializing_if = "Option::is_none")]
561    pub allow_sending_without_reply: Option<bool>,
562    /// Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.
563    #[serde(skip_serializing_if = "Option::is_none")]
564    pub reply_markup: Option<types::ReplyMarkup>,
565}
566impl SendAnimation {
567    pub fn new(chat_id: types::ChatId, animation: types::InputFile) -> Self {
568        Self {
569            chat_id,
570            animation,
571            duration: None,
572            width: None,
573            height: None,
574            thumb: None,
575            caption: None,
576            parse_mode: None,
577            caption_entities: None,
578            disable_notification: None,
579            protect_content: None,
580            reply_to_message_id: None,
581            allow_sending_without_reply: None,
582            reply_markup: None,
583        }
584    }
585}
586
587impl Methods for SendAnimation {
588    fn endpoint(&self) -> String {
589        "sendAnimation".to_string()
590    }
591
592    fn files(&self) -> HashMap<String, types::InputFile> {
593        let mut result = HashMap::new();
594        result.insert("animation".to_string(), self.animation.clone());
595        if let Some(thumb) = &self.thumb {
596            result.insert("thumb".to_string(), thumb.clone());
597        }
598        result
599    }
600}
601
602/// Use this method to send audio files, if you want Telegram clients to display the file as a playable voice message. For this to work, your audio must be in an .OGG file encoded with OPUS (other formats may be sent as Audio or Document). On success, the sent Message is returned. Bots can currently send voice messages of up to 50 MB in size, this limit may be changed in the future.
603#[derive(Deserialize, Serialize, Debug, Clone)]
604pub struct SendVoice {
605    /// Unique identifier for the target chat or username of the target channel (in the format @channelusername)
606    pub chat_id: types::ChatId,
607    /// Audio file to send. Pass a file_id as String to send a file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data. More information on Sending Files »
608    #[serde(skip_serializing)]
609    pub voice: types::InputFile,
610    /// Voice message caption, 0-1024 characters after entities parsing
611    #[serde(skip_serializing_if = "Option::is_none")]
612    pub caption: Option<String>,
613    /// Mode for parsing entities in the voice message caption. See formatting options for more details.
614    #[serde(skip_serializing_if = "Option::is_none")]
615    pub parse_mode: Option<String>,
616    /// A JSON-serialized list of special entities that appear in the caption, which can be specified instead of parse_mode
617    #[serde(skip_serializing_if = "Option::is_none")]
618    pub caption_entities: Option<Vec<types::MessageEntity>>,
619    /// Duration of the voice message in seconds
620    #[serde(skip_serializing_if = "Option::is_none")]
621    pub duration: Option<i64>,
622    /// Sends the message silently. Users will receive a notification with no sound.
623    #[serde(skip_serializing_if = "Option::is_none")]
624    pub disable_notification: Option<bool>,
625    /// Protects the contents of the sent message from forwarding and saving
626    #[serde(skip_serializing_if = "Option::is_none")]
627    pub protect_content: Option<bool>,
628    /// If the message is a reply, ID of the original message
629    #[serde(skip_serializing_if = "Option::is_none")]
630    pub reply_to_message_id: Option<i64>,
631    /// Pass True if the message should be sent even if the specified replied-to message is not found
632    #[serde(skip_serializing_if = "Option::is_none")]
633    pub allow_sending_without_reply: Option<bool>,
634    /// Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.
635    #[serde(skip_serializing_if = "Option::is_none")]
636    pub reply_markup: Option<types::ReplyMarkup>,
637}
638impl SendVoice {
639    pub fn new(chat_id: types::ChatId, voice: types::InputFile) -> Self {
640        Self {
641            chat_id,
642            voice,
643            caption: None,
644            parse_mode: None,
645            caption_entities: None,
646            duration: None,
647            disable_notification: None,
648            protect_content: None,
649            reply_to_message_id: None,
650            allow_sending_without_reply: None,
651            reply_markup: None,
652        }
653    }
654}
655
656impl Methods for SendVoice {
657    fn endpoint(&self) -> String {
658        "sendVoice".to_string()
659    }
660
661    fn files(&self) -> HashMap<String, types::InputFile> {
662        let mut result = HashMap::new();
663        result.insert("voice".to_string(), self.voice.clone());
664        result
665    }
666}
667
668/// As of v.4.0, Telegram clients support rounded square MPEG4 videos of up to 1 minute long. Use this method to send video messages. On success, the sent Message is returned.
669#[derive(Deserialize, Serialize, Debug, Clone)]
670pub struct SendVideoNote {
671    /// Unique identifier for the target chat or username of the target channel (in the format @channelusername)
672    pub chat_id: types::ChatId,
673    /// Video note to send. Pass a file_id as String to send a video note that exists on the Telegram servers (recommended) or upload a new video using multipart/form-data. More information on Sending Files ». Sending video notes by a URL is currently unsupported
674    #[serde(skip_serializing)]
675    pub video_note: types::InputFile,
676    /// Duration of sent video in seconds
677    #[serde(skip_serializing_if = "Option::is_none")]
678    pub duration: Option<i64>,
679    /// Video width and height, i.e. diameter of the video message
680    #[serde(skip_serializing_if = "Option::is_none")]
681    pub length: Option<i64>,
682    /// Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail's width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can't be reused and can be only uploaded as a new file, so you can pass “attach://<file_attach_name>” if the thumbnail was uploaded using multipart/form-data under <file_attach_name>. More information on Sending Files »
683    #[serde(skip_serializing_if = "Option::is_none")]
684    pub thumb: Option<types::InputFile>,
685    /// Sends the message silently. Users will receive a notification with no sound.
686    #[serde(skip_serializing_if = "Option::is_none")]
687    pub disable_notification: Option<bool>,
688    /// Protects the contents of the sent message from forwarding and saving
689    #[serde(skip_serializing_if = "Option::is_none")]
690    pub protect_content: Option<bool>,
691    /// If the message is a reply, ID of the original message
692    #[serde(skip_serializing_if = "Option::is_none")]
693    pub reply_to_message_id: Option<i64>,
694    /// Pass True if the message should be sent even if the specified replied-to message is not found
695    #[serde(skip_serializing_if = "Option::is_none")]
696    pub allow_sending_without_reply: Option<bool>,
697    /// Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.
698    #[serde(skip_serializing_if = "Option::is_none")]
699    pub reply_markup: Option<types::ReplyMarkup>,
700}
701impl SendVideoNote {
702    pub fn new(chat_id: types::ChatId, video_note: types::InputFile) -> Self {
703        Self {
704            chat_id,
705            video_note,
706            duration: None,
707            length: None,
708            thumb: None,
709            disable_notification: None,
710            protect_content: None,
711            reply_to_message_id: None,
712            allow_sending_without_reply: None,
713            reply_markup: None,
714        }
715    }
716}
717
718impl Methods for SendVideoNote {
719    fn endpoint(&self) -> String {
720        "sendVideoNote".to_string()
721    }
722
723    fn files(&self) -> HashMap<String, types::InputFile> {
724        let mut result = HashMap::new();
725        result.insert("video_note".to_string(), self.video_note.clone());
726        if let Some(thumb) = &self.thumb {
727            result.insert("thumb".to_string(), thumb.clone());
728        }
729        result
730    }
731}
732
733/// Use this method to send a group of photos, videos, documents or audios as an album. Documents and audio files can be only grouped in an album with messages of the same type. On success, an array of Messages that were sent is returned.
734#[derive(Deserialize, Serialize, Debug, Clone)]
735pub struct SendMediaGroup {
736    /// Unique identifier for the target chat or username of the target channel (in the format @channelusername)
737    pub chat_id: types::ChatId,
738    /// A JSON-serialized array describing messages to be sent, must include 2-10 items
739    #[serde(serialize_with = "serialize_input_media")]
740    pub media: Vec<types::InputMedia>,
741    /// Sends messages silently. Users will receive a notification with no sound.
742    #[serde(skip_serializing_if = "Option::is_none")]
743    pub disable_notification: Option<bool>,
744    /// Protects the contents of the sent messages from forwarding and saving
745    #[serde(skip_serializing_if = "Option::is_none")]
746    pub protect_content: Option<bool>,
747    /// If the messages are a reply, ID of the original message
748    #[serde(skip_serializing_if = "Option::is_none")]
749    pub reply_to_message_id: Option<i64>,
750    /// Pass True if the message should be sent even if the specified replied-to message is not found
751    #[serde(skip_serializing_if = "Option::is_none")]
752    pub allow_sending_without_reply: Option<bool>,
753}
754
755/// SendMediaGroup serialize media field
756fn serialize_input_media<S>(input_media: &[types::InputMedia], s: S) -> Result<S::Ok, S::Error>
757where
758    S: serde::Serializer,
759{
760    use serde::ser::SerializeSeq;
761    let mut seq = s.serialize_seq(Some(input_media.len()))?;
762    let mut idx = 0;
763    for elem in input_media {
764        seq.serialize_element(&(elem.prepare_input_media_param(idx)))?;
765        idx += 1;
766    }
767    seq.end()
768}
769
770impl SendMediaGroup {
771    pub fn new(chat_id: types::ChatId, media: Vec<types::InputMedia>) -> Self {
772        Self {
773            chat_id,
774            media,
775            disable_notification: None,
776            protect_content: None,
777            reply_to_message_id: None,
778            allow_sending_without_reply: None,
779        }
780    }
781}
782
783impl Methods for SendMediaGroup {
784    fn endpoint(&self) -> String {
785        "sendMediaGroup".to_string()
786    }
787    fn files(&self) -> HashMap<String, types::InputFile> {
788        let mut result = HashMap::new();
789        let mut idx = 0;
790        for elem in self.media.clone() {
791            for (name, file) in elem.prepare_input_media_file(idx) {
792                result.insert(name, file);
793            }
794            idx += 1;
795        }
796        result
797    }
798}
799
800/// Use this method to send point on the map. On success, the sent Message is returned.
801#[derive(Deserialize, Serialize, Debug, Clone)]
802pub struct SendLocation {
803    /// Unique identifier for the target chat or username of the target channel (in the format @channelusername)
804    pub chat_id: types::ChatId,
805    /// Latitude of the location
806    pub latitude: f64,
807    /// Longitude of the location
808    pub longitude: f64,
809    /// The radius of uncertainty for the location, measured in meters; 0-1500
810    #[serde(skip_serializing_if = "Option::is_none")]
811    pub horizontal_accuracy: Option<f64>,
812    /// Period in seconds for which the location will be updated (see Live Locations, should be between 60 and 86400.
813    #[serde(skip_serializing_if = "Option::is_none")]
814    pub live_period: Option<i64>,
815    /// For live locations, a direction in which the user is moving, in degrees. Must be between 1 and 360 if specified.
816    #[serde(skip_serializing_if = "Option::is_none")]
817    pub heading: Option<i64>,
818    /// For live locations, a maximum distance for proximity alerts about approaching another chat member, in meters. Must be between 1 and 100000 if specified.
819    #[serde(skip_serializing_if = "Option::is_none")]
820    pub proximity_alert_radius: Option<i64>,
821    /// Sends the message silently. Users will receive a notification with no sound.
822    #[serde(skip_serializing_if = "Option::is_none")]
823    pub disable_notification: Option<bool>,
824    /// Protects the contents of the sent message from forwarding and saving
825    #[serde(skip_serializing_if = "Option::is_none")]
826    pub protect_content: Option<bool>,
827    /// If the message is a reply, ID of the original message
828    #[serde(skip_serializing_if = "Option::is_none")]
829    pub reply_to_message_id: Option<i64>,
830    /// Pass True if the message should be sent even if the specified replied-to message is not found
831    #[serde(skip_serializing_if = "Option::is_none")]
832    pub allow_sending_without_reply: Option<bool>,
833    /// Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.
834    #[serde(skip_serializing_if = "Option::is_none")]
835    pub reply_markup: Option<types::ReplyMarkup>,
836}
837impl SendLocation {
838    pub fn new(chat_id: types::ChatId, latitude: f64, longitude: f64) -> Self {
839        Self {
840            chat_id,
841            latitude,
842            longitude,
843            horizontal_accuracy: None,
844            live_period: None,
845            heading: None,
846            proximity_alert_radius: None,
847            disable_notification: None,
848            protect_content: None,
849            reply_to_message_id: None,
850            allow_sending_without_reply: None,
851            reply_markup: None,
852        }
853    }
854}
855
856impl Methods for SendLocation {
857    fn endpoint(&self) -> String {
858        "sendLocation".to_string()
859    }
860}
861
862/// Use this method to edit live location messages. A location can be edited until its live_period expires or editing is explicitly disabled by a call to stopMessageLiveLocation. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned.
863#[derive(Deserialize, Serialize, Debug, Clone)]
864pub struct EditMessageLiveLocation {
865    /// Required if inline_message_id is not specified. Unique identifier for the target chat or username of the target channel (in the format @channelusername)
866    #[serde(skip_serializing_if = "Option::is_none")]
867    pub chat_id: Option<types::ChatId>,
868    /// Required if inline_message_id is not specified. Identifier of the message to edit
869    #[serde(skip_serializing_if = "Option::is_none")]
870    pub message_id: Option<i64>,
871    /// Required if chat_id and message_id are not specified. Identifier of the inline message
872    #[serde(skip_serializing_if = "Option::is_none")]
873    pub inline_message_id: Option<String>,
874    /// Latitude of new location
875    pub latitude: f64,
876    /// Longitude of new location
877    pub longitude: f64,
878    /// The radius of uncertainty for the location, measured in meters; 0-1500
879    #[serde(skip_serializing_if = "Option::is_none")]
880    pub horizontal_accuracy: Option<f64>,
881    /// Direction in which the user is moving, in degrees. Must be between 1 and 360 if specified.
882    #[serde(skip_serializing_if = "Option::is_none")]
883    pub heading: Option<i64>,
884    /// The maximum distance for proximity alerts about approaching another chat member, in meters. Must be between 1 and 100000 if specified.
885    #[serde(skip_serializing_if = "Option::is_none")]
886    pub proximity_alert_radius: Option<i64>,
887    /// A JSON-serialized object for a new inline keyboard.
888    #[serde(skip_serializing_if = "Option::is_none")]
889    pub reply_markup: Option<types::InlineKeyboardMarkup>,
890}
891impl EditMessageLiveLocation {
892    pub fn new(latitude: f64, longitude: f64) -> Self {
893        Self {
894            chat_id: None,
895            message_id: None,
896            inline_message_id: None,
897            latitude,
898            longitude,
899            horizontal_accuracy: None,
900            heading: None,
901            proximity_alert_radius: None,
902            reply_markup: None,
903        }
904    }
905}
906
907impl Methods for EditMessageLiveLocation {
908    fn endpoint(&self) -> String {
909        "editMessageLiveLocation".to_string()
910    }
911}
912
913/// Use this method to stop updating a live location message before live_period expires. On success, if the message is not an inline message, the edited Message is returned, otherwise True is returned.
914#[derive(Deserialize, Serialize, Debug, Clone)]
915pub struct StopMessageLiveLocation {
916    /// Required if inline_message_id is not specified. Unique identifier for the target chat or username of the target channel (in the format @channelusername)
917    #[serde(skip_serializing_if = "Option::is_none")]
918    pub chat_id: Option<types::ChatId>,
919    /// Required if inline_message_id is not specified. Identifier of the message with live location to stop
920    #[serde(skip_serializing_if = "Option::is_none")]
921    pub message_id: Option<i64>,
922    /// Required if chat_id and message_id are not specified. Identifier of the inline message
923    #[serde(skip_serializing_if = "Option::is_none")]
924    pub inline_message_id: Option<String>,
925    /// A JSON-serialized object for a new inline keyboard.
926    #[serde(skip_serializing_if = "Option::is_none")]
927    pub reply_markup: Option<types::InlineKeyboardMarkup>,
928}
929impl StopMessageLiveLocation {
930    pub fn new() -> Self {
931        Self {
932            chat_id: None,
933            message_id: None,
934            inline_message_id: None,
935            reply_markup: None,
936        }
937    }
938}
939
940impl Methods for StopMessageLiveLocation {
941    fn endpoint(&self) -> String {
942        "stopMessageLiveLocation".to_string()
943    }
944}
945
946/// Use this method to send information about a venue. On success, the sent Message is returned.
947#[derive(Deserialize, Serialize, Debug, Clone)]
948pub struct SendVenue {
949    /// Unique identifier for the target chat or username of the target channel (in the format @channelusername)
950    pub chat_id: types::ChatId,
951    /// Latitude of the venue
952    pub latitude: f64,
953    /// Longitude of the venue
954    pub longitude: f64,
955    /// Name of the venue
956    pub title: String,
957    /// Address of the venue
958    pub address: String,
959    /// Foursquare identifier of the venue
960    #[serde(skip_serializing_if = "Option::is_none")]
961    pub foursquare_id: Option<String>,
962    /// Foursquare type of the venue, if known. (For example, “arts_entertainment/default”, “arts_entertainment/aquarium” or “food/icecream”.)
963    #[serde(skip_serializing_if = "Option::is_none")]
964    pub foursquare_type: Option<String>,
965    /// Google Places identifier of the venue
966    #[serde(skip_serializing_if = "Option::is_none")]
967    pub google_place_id: Option<String>,
968    /// Google Places type of the venue. (See supported types.)
969    #[serde(skip_serializing_if = "Option::is_none")]
970    pub google_place_type: Option<String>,
971    /// Sends the message silently. Users will receive a notification with no sound.
972    #[serde(skip_serializing_if = "Option::is_none")]
973    pub disable_notification: Option<bool>,
974    /// Protects the contents of the sent message from forwarding and saving
975    #[serde(skip_serializing_if = "Option::is_none")]
976    pub protect_content: Option<bool>,
977    /// If the message is a reply, ID of the original message
978    #[serde(skip_serializing_if = "Option::is_none")]
979    pub reply_to_message_id: Option<i64>,
980    /// Pass True if the message should be sent even if the specified replied-to message is not found
981    #[serde(skip_serializing_if = "Option::is_none")]
982    pub allow_sending_without_reply: Option<bool>,
983    /// Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.
984    #[serde(skip_serializing_if = "Option::is_none")]
985    pub reply_markup: Option<types::ReplyMarkup>,
986}
987impl SendVenue {
988    pub fn new(
989        chat_id: types::ChatId,
990        latitude: f64,
991        longitude: f64,
992        title: String,
993        address: String,
994    ) -> Self {
995        Self {
996            chat_id,
997            latitude,
998            longitude,
999            title,
1000            address,
1001            foursquare_id: None,
1002            foursquare_type: None,
1003            google_place_id: None,
1004            google_place_type: None,
1005            disable_notification: None,
1006            protect_content: None,
1007            reply_to_message_id: None,
1008            allow_sending_without_reply: None,
1009            reply_markup: None,
1010        }
1011    }
1012}
1013
1014impl Methods for SendVenue {
1015    fn endpoint(&self) -> String {
1016        "sendVenue".to_string()
1017    }
1018}
1019
1020/// Use this method to send phone contacts. On success, the sent Message is returned.
1021#[derive(Deserialize, Serialize, Debug, Clone)]
1022pub struct SendContact {
1023    /// Unique identifier for the target chat or username of the target channel (in the format @channelusername)
1024    pub chat_id: types::ChatId,
1025    /// Contact's phone number
1026    pub phone_number: String,
1027    /// Contact's first name
1028    pub first_name: String,
1029    /// Contact's last name
1030    #[serde(skip_serializing_if = "Option::is_none")]
1031    pub last_name: Option<String>,
1032    /// Additional data about the contact in the form of a vCard, 0-2048 bytes
1033    #[serde(skip_serializing_if = "Option::is_none")]
1034    pub vcard: Option<String>,
1035    /// Sends the message silently. Users will receive a notification with no sound.
1036    #[serde(skip_serializing_if = "Option::is_none")]
1037    pub disable_notification: Option<bool>,
1038    /// Protects the contents of the sent message from forwarding and saving
1039    #[serde(skip_serializing_if = "Option::is_none")]
1040    pub protect_content: Option<bool>,
1041    /// If the message is a reply, ID of the original message
1042    #[serde(skip_serializing_if = "Option::is_none")]
1043    pub reply_to_message_id: Option<i64>,
1044    /// Pass True if the message should be sent even if the specified replied-to message is not found
1045    #[serde(skip_serializing_if = "Option::is_none")]
1046    pub allow_sending_without_reply: Option<bool>,
1047    /// Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove keyboard or to force a reply from the user.
1048    #[serde(skip_serializing_if = "Option::is_none")]
1049    pub reply_markup: Option<types::ReplyMarkup>,
1050}
1051impl SendContact {
1052    pub fn new(chat_id: types::ChatId, phone_number: String, first_name: String) -> Self {
1053        Self {
1054            chat_id,
1055            phone_number,
1056            first_name,
1057            last_name: None,
1058            vcard: None,
1059            disable_notification: None,
1060            protect_content: None,
1061            reply_to_message_id: None,
1062            allow_sending_without_reply: None,
1063            reply_markup: None,
1064        }
1065    }
1066}
1067
1068impl Methods for SendContact {
1069    fn endpoint(&self) -> String {
1070        "sendContact".to_string()
1071    }
1072}
1073
1074/// Use this method to send a native poll. On success, the sent Message is returned.
1075#[derive(Deserialize, Serialize, Debug, Clone)]
1076pub struct SendPoll {
1077    /// unique identifier for the target chat or username of the target channel (in the format @channelusername)
1078    pub chat_id: types::ChatId,
1079    /// Poll question, 1-300 characters
1080    pub question: String,
1081    /// A JSON-serialized list of answer options, 2-10 strings 1-100 characters each
1082    pub options: Vec<String>,
1083    /// True, if the poll needs to be anonymous, defaults to True
1084    #[serde(skip_serializing_if = "Option::is_none")]
1085    pub is_anonymous: Option<bool>,
1086    /// Poll type, “quiz” or “regular”, defaults to “regular”
1087    #[serde(skip_serializing_if = "Option::is_none", rename = "type")]
1088    pub type_name: Option<String>,
1089    /// True, if the poll allows multiple answers, ignored for polls in quiz mode, defaults to False
1090    #[serde(skip_serializing_if = "Option::is_none")]
1091    pub allows_multiple_answers: Option<bool>,
1092    /// 0-based identifier of the correct answer option, required for polls in quiz mode
1093    #[serde(skip_serializing_if = "Option::is_none")]
1094    pub correct_option_id: Option<i64>,
1095    /// Text that is shown when a user chooses an incorrect answer or taps on the lamp icon in a quiz-style poll, 0-200 characters with at most 2 line feeds after entities parsing
1096    #[serde(skip_serializing_if = "Option::is_none")]
1097    pub explanation: Option<String>,
1098    /// Mode for parsing entities in the explanation. See formatting options for more details.
1099    #[serde(skip_serializing_if = "Option::is_none")]
1100    pub explanation_parse_mode: Option<String>,
1101    /// A JSON-serialized list of special entities that appear in the poll explanation, which can be specified instead of parse_mode
1102    #[serde(skip_serializing_if = "Option::is_none")]
1103    pub explanation_entities: Option<Vec<types::MessageEntity>>,
1104    /// Amount of time in seconds the poll will be active after creation, 5-600. Can't be used together with close_date.
1105    #[serde(skip_serializing_if = "Option::is_none")]
1106    pub open_period: Option<i64>,
1107    /// Point in time (Unix timestamp) when the poll will be automatically closed. Must be at least 5 and no more than 600 seconds in the future. Can't be used together with open_period.
1108    #[serde(skip_serializing_if = "Option::is_none")]
1109    pub close_date: Option<i64>,
1110    /// Pass True if the poll needs to be immediately closed. This can be useful for poll preview.
1111    #[serde(skip_serializing_if = "Option::is_none")]
1112    pub is_closed: Option<bool>,
1113    /// Sends the message silently. Users will receive a notification with no sound.
1114    #[serde(skip_serializing_if = "Option::is_none")]
1115    pub disable_notification: Option<bool>,
1116    /// Protects the contents of the sent message from forwarding and saving
1117    #[serde(skip_serializing_if = "Option::is_none")]
1118    pub protect_content: Option<bool>,
1119    /// If the message is a reply, ID of the original message
1120    #[serde(skip_serializing_if = "Option::is_none")]
1121    pub reply_to_message_id: Option<i64>,
1122    /// Pass True if the message should be sent even if the specified replied-to message is not found
1123    #[serde(skip_serializing_if = "Option::is_none")]
1124    pub allow_sending_without_reply: Option<bool>,
1125    /// Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.
1126    #[serde(skip_serializing_if = "Option::is_none")]
1127    pub reply_markup: Option<types::ReplyMarkup>,
1128}
1129impl SendPoll {
1130    pub fn new(chat_id: types::ChatId, question: String, options: Vec<String>) -> Self {
1131        Self {
1132            chat_id,
1133            question,
1134            options,
1135            is_anonymous: None,
1136            type_name: None,
1137            allows_multiple_answers: None,
1138            correct_option_id: None,
1139            explanation: None,
1140            explanation_parse_mode: None,
1141            explanation_entities: None,
1142            open_period: None,
1143            close_date: None,
1144            is_closed: None,
1145            disable_notification: None,
1146            protect_content: None,
1147            reply_to_message_id: None,
1148            allow_sending_without_reply: None,
1149            reply_markup: None,
1150        }
1151    }
1152}
1153
1154impl Methods for SendPoll {
1155    fn endpoint(&self) -> String {
1156        "sendPoll".to_string()
1157    }
1158}
1159
1160/// Use this method to send an animated emoji that will display a random value. On success, the sent Message is returned.
1161#[derive(Deserialize, Serialize, Debug, Clone)]
1162pub struct SendDice {
1163    /// Unique identifier for the target chat or username of the target channel (in the format @channelusername)
1164    pub chat_id: types::ChatId,
1165    /// Emoji on which the dice throw animation is based. Currently, must be one of “🎲”, “🎯”, “🏀”, “⚽”, “🎳”, or “🎰”. Dice can have values 1-6 for “🎲”, “🎯” and “🎳”, values 1-5 for “🏀” and “⚽”, and values 1-64 for “🎰”. Defaults to “🎲”
1166    #[serde(skip_serializing_if = "Option::is_none")]
1167    pub emoji: Option<String>,
1168    /// Sends the message silently. Users will receive a notification with no sound.
1169    #[serde(skip_serializing_if = "Option::is_none")]
1170    pub disable_notification: Option<bool>,
1171    /// Protects the contents of the sent message from forwarding
1172    #[serde(skip_serializing_if = "Option::is_none")]
1173    pub protect_content: Option<bool>,
1174    /// If the message is a reply, ID of the original message
1175    #[serde(skip_serializing_if = "Option::is_none")]
1176    pub reply_to_message_id: Option<i64>,
1177    /// Pass True if the message should be sent even if the specified replied-to message is not found
1178    #[serde(skip_serializing_if = "Option::is_none")]
1179    pub allow_sending_without_reply: Option<bool>,
1180    /// Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.
1181    #[serde(skip_serializing_if = "Option::is_none")]
1182    pub reply_markup: Option<types::ReplyMarkup>,
1183}
1184impl SendDice {
1185    pub fn new(chat_id: types::ChatId) -> Self {
1186        Self {
1187            chat_id,
1188            emoji: None,
1189            disable_notification: None,
1190            protect_content: None,
1191            reply_to_message_id: None,
1192            allow_sending_without_reply: None,
1193            reply_markup: None,
1194        }
1195    }
1196}
1197
1198impl Methods for SendDice {
1199    fn endpoint(&self) -> String {
1200        "sendDice".to_string()
1201    }
1202}
1203
1204/// Use this method when you need to tell the user that something is happening on the bot's side. The status is set for 5 seconds or less (when a message arrives from your bot, Telegram clients clear its typing status). Returns True on success.
1205#[derive(Deserialize, Serialize, Debug, Clone)]
1206pub struct SendChatAction {
1207    /// Unique identifier for the target chat or username of the target channel (in the format @channelusername)
1208    pub chat_id: types::ChatId,
1209    /// Type of action to broadcast. Choose one, depending on what the user is about to receive: typing for text messages, upload_photo for photos, record_video or upload_video for videos, record_voice or upload_voice for voice notes, upload_document for general files, choose_sticker for stickers, find_location for location data, record_video_note or upload_video_note for video notes.
1210    pub action: String,
1211}
1212impl SendChatAction {
1213    pub fn new(chat_id: types::ChatId, action: String) -> Self {
1214        Self { chat_id, action }
1215    }
1216}
1217
1218impl Methods for SendChatAction {
1219    fn endpoint(&self) -> String {
1220        "sendChatAction".to_string()
1221    }
1222}
1223
1224/// Use this method to get a list of profile pictures for a user. Returns a UserProfilePhotos object.
1225#[derive(Deserialize, Serialize, Debug, Clone)]
1226pub struct GetUserProfilePhotos {
1227    /// Unique identifier of the target user
1228    pub user_id: i64,
1229    /// Sequential number of the first photo to be returned. By default, all photos are returned.
1230    #[serde(skip_serializing_if = "Option::is_none")]
1231    pub offset: Option<i64>,
1232    /// Limits the number of photos to be retrieved. Values between 1-100 are accepted. Defaults to 100.
1233    #[serde(skip_serializing_if = "Option::is_none")]
1234    pub limit: Option<i64>,
1235}
1236impl GetUserProfilePhotos {
1237    pub fn new(user_id: i64) -> Self {
1238        Self {
1239            user_id,
1240            offset: None,
1241            limit: None,
1242        }
1243    }
1244}
1245
1246impl Methods for GetUserProfilePhotos {
1247    fn endpoint(&self) -> String {
1248        "getUserProfilePhotos".to_string()
1249    }
1250}
1251
1252/// Use this method to get basic information about a file and prepare it for downloading. For the moment, bots can download files of up to 20MB in size. On success, a File object is returned. The file can then be downloaded via the link https://api.telegram.org/file/bot<token>/<file_path>, where <file_path> is taken from the response. It is guaranteed that the link will be valid for at least 1 hour. When the link expires, a new one can be requested by calling getFile again.
1253#[derive(Deserialize, Serialize, Debug, Clone)]
1254pub struct GetFile {
1255    /// File identifier to get information about
1256    pub file_id: String,
1257}
1258impl GetFile {
1259    pub fn new(file_id: String) -> Self {
1260        Self { file_id }
1261    }
1262}
1263
1264impl Methods for GetFile {
1265    fn endpoint(&self) -> String {
1266        "getFile".to_string()
1267    }
1268}
1269
1270/// Use this method to ban a user in a group, a supergroup or a channel. In the case of supergroups and channels, the user will not be able to to the chat on their own using invite links, etc., unless unbanned first. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns True on success.
1271#[derive(Deserialize, Serialize, Debug, Clone)]
1272pub struct BanChatMember {
1273    /// Unique identifier for the target group or username of the target supergroup or channel (in the format @channelusername)
1274    pub chat_id: types::ChatId,
1275    /// Unique identifier of the target user
1276    pub user_id: i64,
1277    /// Date when the user will be unbanned, unix time. If user is banned for more than 366 days or less than 30 seconds from the current time they are considered to be banned forever. Applied for supergroups and channels only.
1278    #[serde(skip_serializing_if = "Option::is_none")]
1279    pub until_date: Option<i64>,
1280    /// Pass True to delete all messages from the chat for the user that is being removed. If False, the user will be able to see messages in the group that were sent before the user was removed. Always True for supergroups and channels.
1281    #[serde(skip_serializing_if = "Option::is_none")]
1282    pub revoke_messages: Option<bool>,
1283}
1284impl BanChatMember {
1285    pub fn new(chat_id: types::ChatId, user_id: i64) -> Self {
1286        Self {
1287            chat_id,
1288            user_id,
1289            until_date: None,
1290            revoke_messages: None,
1291        }
1292    }
1293}
1294
1295impl Methods for BanChatMember {
1296    fn endpoint(&self) -> String {
1297        "banChatMember".to_string()
1298    }
1299}
1300
1301/// Use this method to unban a previously banned user in a supergroup or channel. The user will not to the group or channel automatically, but will be able to join via link, etc. The bot must be an administrator for this to work. By default, this method guarantees that after the call the user is not a member of the chat, but will be able to join it. So if the user is a member of the chat they will also be removed from the chat. If you don't want this, use the parameter only_if_banned. Returns True on success.
1302#[derive(Deserialize, Serialize, Debug, Clone)]
1303pub struct UnbanChatMember {
1304    /// Unique identifier for the target group or username of the target supergroup or channel (in the format @channelusername)
1305    pub chat_id: types::ChatId,
1306    /// Unique identifier of the target user
1307    pub user_id: i64,
1308    /// Do nothing if the user is not banned
1309    #[serde(skip_serializing_if = "Option::is_none")]
1310    pub only_if_banned: Option<bool>,
1311}
1312impl UnbanChatMember {
1313    pub fn new(chat_id: types::ChatId, user_id: i64) -> Self {
1314        Self {
1315            chat_id,
1316            user_id,
1317            only_if_banned: None,
1318        }
1319    }
1320}
1321
1322impl Methods for UnbanChatMember {
1323    fn endpoint(&self) -> String {
1324        "unbanChatMember".to_string()
1325    }
1326}
1327
1328/// Use this method to restrict a user in a supergroup. The bot must be an administrator in the supergroup for this to work and must have the appropriate administrator rights. Pass True for all permissions to lift restrictions from a user. Returns True on success.
1329#[derive(Deserialize, Serialize, Debug, Clone)]
1330pub struct RestrictChatMember {
1331    /// Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
1332    pub chat_id: types::ChatId,
1333    /// Unique identifier of the target user
1334    pub user_id: i64,
1335    /// A JSON-serialized object for new user permissions
1336    pub permissions: types::ChatPermissions,
1337    /// Date when restrictions will be lifted for the user, unix time. If user is restricted for more than 366 days or less than 30 seconds from the current time, they are considered to be restricted forever
1338    #[serde(skip_serializing_if = "Option::is_none")]
1339    pub until_date: Option<i64>,
1340}
1341impl RestrictChatMember {
1342    pub fn new(chat_id: types::ChatId, user_id: i64, permissions: types::ChatPermissions) -> Self {
1343        Self {
1344            chat_id,
1345            user_id,
1346            permissions,
1347            until_date: None,
1348        }
1349    }
1350}
1351
1352impl Methods for RestrictChatMember {
1353    fn endpoint(&self) -> String {
1354        "restrictChatMember".to_string()
1355    }
1356}
1357
1358/// Use this method to promote or demote a user in a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Pass False for all boolean parameters to demote a user. Returns True on success.
1359#[derive(Deserialize, Serialize, Debug, Clone)]
1360pub struct PromoteChatMember {
1361    /// Unique identifier for the target chat or username of the target channel (in the format @channelusername)
1362    pub chat_id: types::ChatId,
1363    /// Unique identifier of the target user
1364    pub user_id: i64,
1365    /// Pass True if the administrator's presence in the chat is hidden
1366    #[serde(skip_serializing_if = "Option::is_none")]
1367    pub is_anonymous: Option<bool>,
1368    /// Pass True if the administrator can access the chat event log, chat statistics, message statistics in channels, see channel members, see anonymous administrators in supergroups and ignore slow mode. Implied by any other administrator privilege
1369    #[serde(skip_serializing_if = "Option::is_none")]
1370    pub can_manage_chat: Option<bool>,
1371    /// Pass True if the administrator can create channel posts, channels only
1372    #[serde(skip_serializing_if = "Option::is_none")]
1373    pub can_post_messages: Option<bool>,
1374    /// Pass True if the administrator can edit messages of other users and can pin messages, channels only
1375    #[serde(skip_serializing_if = "Option::is_none")]
1376    pub can_edit_messages: Option<bool>,
1377    /// Pass True if the administrator can delete messages of other users
1378    #[serde(skip_serializing_if = "Option::is_none")]
1379    pub can_delete_messages: Option<bool>,
1380    /// Pass True if the administrator can manage video chats
1381    #[serde(skip_serializing_if = "Option::is_none")]
1382    pub can_manage_video_chats: Option<bool>,
1383    /// Pass True if the administrator can restrict, ban or unban chat members
1384    #[serde(skip_serializing_if = "Option::is_none")]
1385    pub can_restrict_members: Option<bool>,
1386    /// Pass True if the administrator can add new administrators with a subset of their own privileges or demote administrators that he has promoted, directly or indirectly (promoted by administrators that were appointed by him)
1387    #[serde(skip_serializing_if = "Option::is_none")]
1388    pub can_promote_members: Option<bool>,
1389    /// Pass True if the administrator can change chat title, photo and other settings
1390    #[serde(skip_serializing_if = "Option::is_none")]
1391    pub can_change_info: Option<bool>,
1392    /// Pass True if the administrator can invite new users to the chat
1393    #[serde(skip_serializing_if = "Option::is_none")]
1394    pub can_invite_users: Option<bool>,
1395    /// Pass True if the administrator can pin messages, supergroups only
1396    #[serde(skip_serializing_if = "Option::is_none")]
1397    pub can_pin_messages: Option<bool>,
1398}
1399impl PromoteChatMember {
1400    pub fn new(chat_id: types::ChatId, user_id: i64) -> Self {
1401        Self {
1402            chat_id,
1403            user_id,
1404            is_anonymous: None,
1405            can_manage_chat: None,
1406            can_post_messages: None,
1407            can_edit_messages: None,
1408            can_delete_messages: None,
1409            can_manage_video_chats: None,
1410            can_restrict_members: None,
1411            can_promote_members: None,
1412            can_change_info: None,
1413            can_invite_users: None,
1414            can_pin_messages: None,
1415        }
1416    }
1417}
1418
1419impl Methods for PromoteChatMember {
1420    fn endpoint(&self) -> String {
1421        "promoteChatMember".to_string()
1422    }
1423}
1424
1425/// Use this method to set a custom title for an administrator in a supergroup promoted by the bot. Returns True on success.
1426#[derive(Deserialize, Serialize, Debug, Clone)]
1427pub struct SetChatAdministratorCustomTitle {
1428    /// Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
1429    pub chat_id: types::ChatId,
1430    /// Unique identifier of the target user
1431    pub user_id: i64,
1432    /// New custom title for the administrator; 0-16 characters, emoji are not allowed
1433    pub custom_title: String,
1434}
1435impl SetChatAdministratorCustomTitle {
1436    pub fn new(chat_id: types::ChatId, user_id: i64, custom_title: String) -> Self {
1437        Self {
1438            chat_id,
1439            user_id,
1440            custom_title,
1441        }
1442    }
1443}
1444
1445impl Methods for SetChatAdministratorCustomTitle {
1446    fn endpoint(&self) -> String {
1447        "setChatAdministratorCustomTitle".to_string()
1448    }
1449}
1450
1451/// Use this method to ban a channel chat in a supergroup or a channel. Until the chat is unbanned, the owner of the banned chat won't be able to send messages on behalf of any of their channels. The bot must be an administrator in the supergroup or channel for this to work and must have the appropriate administrator rights. Returns True on success.
1452#[derive(Deserialize, Serialize, Debug, Clone)]
1453pub struct BanChatSenderChat {
1454    /// Unique identifier for the target chat or username of the target channel (in the format @channelusername)
1455    pub chat_id: types::ChatId,
1456    /// Unique identifier of the target sender chat
1457    pub sender_chat_id: i64,
1458}
1459impl BanChatSenderChat {
1460    pub fn new(chat_id: types::ChatId, sender_chat_id: i64) -> Self {
1461        Self {
1462            chat_id,
1463            sender_chat_id,
1464        }
1465    }
1466}
1467
1468impl Methods for BanChatSenderChat {
1469    fn endpoint(&self) -> String {
1470        "banChatSenderChat".to_string()
1471    }
1472}
1473
1474/// Use this method to unban a previously banned channel chat in a supergroup or channel. The bot must be an administrator for this to work and must have the appropriate administrator rights. Returns True on success.
1475#[derive(Deserialize, Serialize, Debug, Clone)]
1476pub struct UnbanChatSenderChat {
1477    /// Unique identifier for the target chat or username of the target channel (in the format @channelusername)
1478    pub chat_id: types::ChatId,
1479    /// Unique identifier of the target sender chat
1480    pub sender_chat_id: i64,
1481}
1482impl UnbanChatSenderChat {
1483    pub fn new(chat_id: types::ChatId, sender_chat_id: i64) -> Self {
1484        Self {
1485            chat_id,
1486            sender_chat_id,
1487        }
1488    }
1489}
1490
1491impl Methods for UnbanChatSenderChat {
1492    fn endpoint(&self) -> String {
1493        "unbanChatSenderChat".to_string()
1494    }
1495}
1496
1497/// Use this method to set default chat permissions for all members. The bot must be an administrator in the group or a supergroup for this to work and must have the can_restrict_members administrator rights. Returns True on success.
1498#[derive(Deserialize, Serialize, Debug, Clone)]
1499pub struct SetChatPermissions {
1500    /// Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
1501    pub chat_id: types::ChatId,
1502    /// A JSON-serialized object for new default chat permissions
1503    pub permissions: types::ChatPermissions,
1504}
1505impl SetChatPermissions {
1506    pub fn new(chat_id: types::ChatId, permissions: types::ChatPermissions) -> Self {
1507        Self {
1508            chat_id,
1509            permissions,
1510        }
1511    }
1512}
1513
1514impl Methods for SetChatPermissions {
1515    fn endpoint(&self) -> String {
1516        "setChatPermissions".to_string()
1517    }
1518}
1519
1520/// Use this method to generate a new primary invite link for a chat; any previously generated primary link is revoked. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns the new invite link as String on success.
1521#[derive(Deserialize, Serialize, Debug, Clone)]
1522pub struct ExportChatInviteLink {
1523    /// Unique identifier for the target chat or username of the target channel (in the format @channelusername)
1524    pub chat_id: types::ChatId,
1525}
1526impl ExportChatInviteLink {
1527    pub fn new(chat_id: types::ChatId) -> Self {
1528        Self { chat_id }
1529    }
1530}
1531
1532impl Methods for ExportChatInviteLink {
1533    fn endpoint(&self) -> String {
1534        "exportChatInviteLink".to_string()
1535    }
1536}
1537
1538/// Use this method to create an additional invite link for a chat. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. The link can be revoked using the method revokeChatInviteLink. Returns the new invite link as ChatInviteLink object.
1539#[derive(Deserialize, Serialize, Debug, Clone)]
1540pub struct CreateChatInviteLink {
1541    /// Unique identifier for the target chat or username of the target channel (in the format @channelusername)
1542    pub chat_id: types::ChatId,
1543    /// Invite link name; 0-32 characters
1544    #[serde(skip_serializing_if = "Option::is_none")]
1545    pub name: Option<String>,
1546    /// Point in time (Unix timestamp) when the link will expire
1547    #[serde(skip_serializing_if = "Option::is_none")]
1548    pub expire_date: Option<i64>,
1549    /// The maximum number of users that can be members of the chat simultaneously after joining the chat via this invite link; 1-99999
1550    #[serde(skip_serializing_if = "Option::is_none")]
1551    pub member_limit: Option<i64>,
1552    /// True, if users joining the chat via the link need to be approved by chat administrators. If True, member_limit can't be specified
1553    #[serde(skip_serializing_if = "Option::is_none")]
1554    pub creates_join_request: Option<bool>,
1555}
1556impl CreateChatInviteLink {
1557    pub fn new(chat_id: types::ChatId) -> Self {
1558        Self {
1559            chat_id,
1560            name: None,
1561            expire_date: None,
1562            member_limit: None,
1563            creates_join_request: None,
1564        }
1565    }
1566}
1567
1568impl Methods for CreateChatInviteLink {
1569    fn endpoint(&self) -> String {
1570        "createChatInviteLink".to_string()
1571    }
1572}
1573
1574/// Use this method to edit a non-primary invite link created by the bot. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns the edited invite link as a ChatInviteLink object.
1575#[derive(Deserialize, Serialize, Debug, Clone)]
1576pub struct EditChatInviteLink {
1577    /// Unique identifier for the target chat or username of the target channel (in the format @channelusername)
1578    pub chat_id: types::ChatId,
1579    /// The invite link to edit
1580    pub invite_link: String,
1581    /// Invite link name; 0-32 characters
1582    #[serde(skip_serializing_if = "Option::is_none")]
1583    pub name: Option<String>,
1584    /// Point in time (Unix timestamp) when the link will expire
1585    #[serde(skip_serializing_if = "Option::is_none")]
1586    pub expire_date: Option<i64>,
1587    /// The maximum number of users that can be members of the chat simultaneously after joining the chat via this invite link; 1-99999
1588    #[serde(skip_serializing_if = "Option::is_none")]
1589    pub member_limit: Option<i64>,
1590    /// True, if users joining the chat via the link need to be approved by chat administrators. If True, member_limit can't be specified
1591    #[serde(skip_serializing_if = "Option::is_none")]
1592    pub creates_join_request: Option<bool>,
1593}
1594impl EditChatInviteLink {
1595    pub fn new(chat_id: types::ChatId, invite_link: String) -> Self {
1596        Self {
1597            chat_id,
1598            invite_link,
1599            name: None,
1600            expire_date: None,
1601            member_limit: None,
1602            creates_join_request: None,
1603        }
1604    }
1605}
1606
1607impl Methods for EditChatInviteLink {
1608    fn endpoint(&self) -> String {
1609        "editChatInviteLink".to_string()
1610    }
1611}
1612
1613/// Use this method to revoke an invite link created by the bot. If the primary link is revoked, a new link is automatically generated. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns the revoked invite link as ChatInviteLink object.
1614#[derive(Deserialize, Serialize, Debug, Clone)]
1615pub struct RevokeChatInviteLink {
1616    /// Unique identifier of the target chat or username of the target channel (in the format @channelusername)
1617    pub chat_id: types::ChatId,
1618    /// The invite link to revoke
1619    pub invite_link: String,
1620}
1621impl RevokeChatInviteLink {
1622    pub fn new(chat_id: types::ChatId, invite_link: String) -> Self {
1623        Self {
1624            chat_id,
1625            invite_link,
1626        }
1627    }
1628}
1629
1630impl Methods for RevokeChatInviteLink {
1631    fn endpoint(&self) -> String {
1632        "revokeChatInviteLink".to_string()
1633    }
1634}
1635
1636/// Use this method to approve a chat join request. The bot must be an administrator in the chat for this to work and must have the can_invite_users administrator right. Returns True on success.
1637#[derive(Deserialize, Serialize, Debug, Clone)]
1638pub struct ApproveChatJoinRequest {
1639    /// Unique identifier for the target chat or username of the target channel (in the format @channelusername)
1640    pub chat_id: types::ChatId,
1641    /// Unique identifier of the target user
1642    pub user_id: i64,
1643}
1644impl ApproveChatJoinRequest {
1645    pub fn new(chat_id: types::ChatId, user_id: i64) -> Self {
1646        Self { chat_id, user_id }
1647    }
1648}
1649
1650impl Methods for ApproveChatJoinRequest {
1651    fn endpoint(&self) -> String {
1652        "approveChatJoinRequest".to_string()
1653    }
1654}
1655
1656/// Use this method to decline a chat join request. The bot must be an administrator in the chat for this to work and must have the can_invite_users administrator right. Returns True on success.
1657#[derive(Deserialize, Serialize, Debug, Clone)]
1658pub struct DeclineChatJoinRequest {
1659    /// Unique identifier for the target chat or username of the target channel (in the format @channelusername)
1660    pub chat_id: types::ChatId,
1661    /// Unique identifier of the target user
1662    pub user_id: i64,
1663}
1664impl DeclineChatJoinRequest {
1665    pub fn new(chat_id: types::ChatId, user_id: i64) -> Self {
1666        Self { chat_id, user_id }
1667    }
1668}
1669
1670impl Methods for DeclineChatJoinRequest {
1671    fn endpoint(&self) -> String {
1672        "declineChatJoinRequest".to_string()
1673    }
1674}
1675
1676/// Use this method to set a new profile photo for the chat. Photos can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns True on success.
1677#[derive(Deserialize, Serialize, Debug, Clone)]
1678pub struct SetChatPhoto {
1679    /// Unique identifier for the target chat or username of the target channel (in the format @channelusername)
1680    pub chat_id: types::ChatId,
1681    /// New chat photo, uploaded using multipart/form-data
1682    #[serde(skip_serializing)]
1683    pub photo: types::InputFile,
1684}
1685impl SetChatPhoto {
1686    pub fn new(chat_id: types::ChatId, photo: types::InputFile) -> Self {
1687        Self { chat_id, photo }
1688    }
1689}
1690
1691impl Methods for SetChatPhoto {
1692    fn endpoint(&self) -> String {
1693        "setChatPhoto".to_string()
1694    }
1695
1696    fn files(&self) -> HashMap<String, types::InputFile> {
1697        let mut result = HashMap::new();
1698        result.insert("photo".to_string(), self.photo.clone());
1699        result
1700    }
1701}
1702
1703/// Use this method to delete a chat photo. Photos can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns True on success.
1704#[derive(Deserialize, Serialize, Debug, Clone)]
1705pub struct DeleteChatPhoto {
1706    /// Unique identifier for the target chat or username of the target channel (in the format @channelusername)
1707    pub chat_id: types::ChatId,
1708}
1709impl DeleteChatPhoto {
1710    pub fn new(chat_id: types::ChatId) -> Self {
1711        Self { chat_id }
1712    }
1713}
1714
1715impl Methods for DeleteChatPhoto {
1716    fn endpoint(&self) -> String {
1717        "deleteChatPhoto".to_string()
1718    }
1719}
1720
1721/// Use this method to change the title of a chat. Titles can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns True on success.
1722#[derive(Deserialize, Serialize, Debug, Clone)]
1723pub struct SetChatTitle {
1724    /// Unique identifier for the target chat or username of the target channel (in the format @channelusername)
1725    pub chat_id: types::ChatId,
1726    /// New chat title, 1-255 characters
1727    pub title: String,
1728}
1729impl SetChatTitle {
1730    pub fn new(chat_id: types::ChatId, title: String) -> Self {
1731        Self { chat_id, title }
1732    }
1733}
1734
1735impl Methods for SetChatTitle {
1736    fn endpoint(&self) -> String {
1737        "setChatTitle".to_string()
1738    }
1739}
1740
1741/// Use this method to change the description of a group, a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns True on success.
1742#[derive(Deserialize, Serialize, Debug, Clone)]
1743pub struct SetChatDescription {
1744    /// Unique identifier for the target chat or username of the target channel (in the format @channelusername)
1745    pub chat_id: types::ChatId,
1746    /// New chat description, 0-255 characters
1747    #[serde(skip_serializing_if = "Option::is_none")]
1748    pub description: Option<String>,
1749}
1750impl SetChatDescription {
1751    pub fn new(chat_id: types::ChatId) -> Self {
1752        Self {
1753            chat_id,
1754            description: None,
1755        }
1756    }
1757}
1758
1759impl Methods for SetChatDescription {
1760    fn endpoint(&self) -> String {
1761        "setChatDescription".to_string()
1762    }
1763}
1764
1765/// Use this method to add a message to the list of pinned messages in a chat. If the chat is not a private chat, the bot must be an administrator in the chat for this to work and must have the 'can_pin_messages' administrator right in a supergroup or 'can_edit_messages' administrator right in a channel. Returns True on success.
1766#[derive(Deserialize, Serialize, Debug, Clone)]
1767pub struct PinChatMessage {
1768    /// Unique identifier for the target chat or username of the target channel (in the format @channelusername)
1769    pub chat_id: types::ChatId,
1770    /// Identifier of a message to pin
1771    pub message_id: i64,
1772    /// Pass True if it is not necessary to send a notification to all chat members about the new pinned message. Notifications are always disabled in channels and private chats.
1773    #[serde(skip_serializing_if = "Option::is_none")]
1774    pub disable_notification: Option<bool>,
1775}
1776impl PinChatMessage {
1777    pub fn new(chat_id: types::ChatId, message_id: i64) -> Self {
1778        Self {
1779            chat_id,
1780            message_id,
1781            disable_notification: None,
1782        }
1783    }
1784}
1785
1786impl Methods for PinChatMessage {
1787    fn endpoint(&self) -> String {
1788        "pinChatMessage".to_string()
1789    }
1790}
1791
1792/// Use this method to remove a message from the list of pinned messages in a chat. If the chat is not a private chat, the bot must be an administrator in the chat for this to work and must have the 'can_pin_messages' administrator right in a supergroup or 'can_edit_messages' administrator right in a channel. Returns True on success.
1793#[derive(Deserialize, Serialize, Debug, Clone)]
1794pub struct UnpinChatMessage {
1795    /// Unique identifier for the target chat or username of the target channel (in the format @channelusername)
1796    pub chat_id: types::ChatId,
1797    /// Identifier of a message to unpin. If not specified, the most recent pinned message (by sending date) will be unpinned.
1798    #[serde(skip_serializing_if = "Option::is_none")]
1799    pub message_id: Option<i64>,
1800}
1801impl UnpinChatMessage {
1802    pub fn new(chat_id: types::ChatId) -> Self {
1803        Self {
1804            chat_id,
1805            message_id: None,
1806        }
1807    }
1808}
1809
1810impl Methods for UnpinChatMessage {
1811    fn endpoint(&self) -> String {
1812        "unpinChatMessage".to_string()
1813    }
1814}
1815
1816/// Use this method to clear the list of pinned messages in a chat. If the chat is not a private chat, the bot must be an administrator in the chat for this to work and must have the 'can_pin_messages' administrator right in a supergroup or 'can_edit_messages' administrator right in a channel. Returns True on success.
1817#[derive(Deserialize, Serialize, Debug, Clone)]
1818pub struct UnpinAllChatMessages {
1819    /// Unique identifier for the target chat or username of the target channel (in the format @channelusername)
1820    pub chat_id: types::ChatId,
1821}
1822impl UnpinAllChatMessages {
1823    pub fn new(chat_id: types::ChatId) -> Self {
1824        Self { chat_id }
1825    }
1826}
1827
1828impl Methods for UnpinAllChatMessages {
1829    fn endpoint(&self) -> String {
1830        "unpinAllChatMessages".to_string()
1831    }
1832}
1833
1834/// Use this method for your bot to leave a group, supergroup or channel. Returns True on success.
1835#[derive(Deserialize, Serialize, Debug, Clone)]
1836pub struct LeaveChat {
1837    /// Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername)
1838    pub chat_id: types::ChatId,
1839}
1840impl LeaveChat {
1841    pub fn new(chat_id: types::ChatId) -> Self {
1842        Self { chat_id }
1843    }
1844}
1845
1846impl Methods for LeaveChat {
1847    fn endpoint(&self) -> String {
1848        "leaveChat".to_string()
1849    }
1850}
1851
1852/// Use this method to get up to date information about the chat (current name of the user for one-on-one conversations, current username of a user, group or channel, etc.). Returns a Chat object on success.
1853#[derive(Deserialize, Serialize, Debug, Clone)]
1854pub struct GetChat {
1855    /// Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername)
1856    pub chat_id: types::ChatId,
1857}
1858impl GetChat {
1859    pub fn new(chat_id: types::ChatId) -> Self {
1860        Self { chat_id }
1861    }
1862}
1863
1864impl Methods for GetChat {
1865    fn endpoint(&self) -> String {
1866        "getChat".to_string()
1867    }
1868}
1869
1870/// Use this method to get a list of administrators in a chat, which aren't bots. Returns an Array of ChatMember objects.
1871#[derive(Deserialize, Serialize, Debug, Clone)]
1872pub struct GetChatAdministrators {
1873    /// Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername)
1874    pub chat_id: types::ChatId,
1875}
1876impl GetChatAdministrators {
1877    pub fn new(chat_id: types::ChatId) -> Self {
1878        Self { chat_id }
1879    }
1880}
1881
1882impl Methods for GetChatAdministrators {
1883    fn endpoint(&self) -> String {
1884        "getChatAdministrators".to_string()
1885    }
1886}
1887
1888/// Use this method to get the number of members in a chat. Returns Int on success.
1889#[derive(Deserialize, Serialize, Debug, Clone)]
1890pub struct GetChatMemberCount {
1891    /// Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername)
1892    pub chat_id: types::ChatId,
1893}
1894impl GetChatMemberCount {
1895    pub fn new(chat_id: types::ChatId) -> Self {
1896        Self { chat_id }
1897    }
1898}
1899
1900impl Methods for GetChatMemberCount {
1901    fn endpoint(&self) -> String {
1902        "getChatMemberCount".to_string()
1903    }
1904}
1905
1906/// Use this method to get information about a member of a chat. Returns a ChatMember object on success.
1907#[derive(Deserialize, Serialize, Debug, Clone)]
1908pub struct GetChatMember {
1909    /// Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername)
1910    pub chat_id: types::ChatId,
1911    /// Unique identifier of the target user
1912    pub user_id: i64,
1913}
1914impl GetChatMember {
1915    pub fn new(chat_id: types::ChatId, user_id: i64) -> Self {
1916        Self { chat_id, user_id }
1917    }
1918}
1919
1920impl Methods for GetChatMember {
1921    fn endpoint(&self) -> String {
1922        "getChatMember".to_string()
1923    }
1924}
1925
1926/// Use this method to set a new group sticker set for a supergroup. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Use the field can_set_sticker_set optionally returned in getChat requests to check if the bot can use this method. Returns True on success.
1927#[derive(Deserialize, Serialize, Debug, Clone)]
1928pub struct SetChatStickerSet {
1929    /// Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
1930    pub chat_id: types::ChatId,
1931    /// Name of the sticker set to be set as the group sticker set
1932    pub sticker_set_name: String,
1933}
1934impl SetChatStickerSet {
1935    pub fn new(chat_id: types::ChatId, sticker_set_name: String) -> Self {
1936        Self {
1937            chat_id,
1938            sticker_set_name,
1939        }
1940    }
1941}
1942
1943impl Methods for SetChatStickerSet {
1944    fn endpoint(&self) -> String {
1945        "setChatStickerSet".to_string()
1946    }
1947}
1948
1949/// Use this method to delete a group sticker set from a supergroup. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Use the field can_set_sticker_set optionally returned in getChat requests to check if the bot can use this method. Returns True on success.
1950#[derive(Deserialize, Serialize, Debug, Clone)]
1951pub struct DeleteChatStickerSet {
1952    /// Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
1953    pub chat_id: types::ChatId,
1954}
1955impl DeleteChatStickerSet {
1956    pub fn new(chat_id: types::ChatId) -> Self {
1957        Self { chat_id }
1958    }
1959}
1960
1961impl Methods for DeleteChatStickerSet {
1962    fn endpoint(&self) -> String {
1963        "deleteChatStickerSet".to_string()
1964    }
1965}
1966
1967/// Use this method to send answers to callback queries sent from inline keyboards. The answer will be displayed to the user as a notification at the top of the chat screen or as an alert. On success, True is returned.
1968#[derive(Deserialize, Serialize, Debug, Clone)]
1969pub struct AnswerCallbackQuery {
1970    /// Unique identifier for the query to be answered
1971    pub callback_query_id: String,
1972    /// Text of the notification. If not specified, nothing will be shown to the user, 0-200 characters
1973    #[serde(skip_serializing_if = "Option::is_none")]
1974    pub text: Option<String>,
1975    /// If True, an alert will be shown by the client instead of a notification at the top of the chat screen. Defaults to false.
1976    #[serde(skip_serializing_if = "Option::is_none")]
1977    pub show_alert: Option<bool>,
1978    /// URL that will be opened by the user's client. If you have created a Game and accepted the conditions via @BotFather, specify the URL that opens your game - note that this will only work if the query comes from a callback_game button.
1979    #[serde(skip_serializing_if = "Option::is_none")]
1980    pub url: Option<String>,
1981}
1982impl AnswerCallbackQuery {
1983    pub fn new(callback_query_id: String) -> Self {
1984        Self {
1985            callback_query_id,
1986            text: None,
1987            show_alert: None,
1988            url: None,
1989        }
1990    }
1991}
1992
1993impl Methods for AnswerCallbackQuery {
1994    fn endpoint(&self) -> String {
1995        "answerCallbackQuery".to_string()
1996    }
1997}
1998
1999/// Use this method to change the list of the bot's commands. See https://core.telegram.org/bots#commands for more details about bot commands. Returns True on success.
2000#[derive(Deserialize, Serialize, Debug, Clone)]
2001pub struct SetMyCommands {
2002    /// A JSON-serialized list of bot commands to be set as the list of the bot's commands. At most 100 commands can be specified.
2003    pub commands: Vec<types::BotCommand>,
2004    /// A JSON-serialized object, describing scope of users for which the commands are relevant. Defaults to BotCommandScopeDefault.
2005    #[serde(skip_serializing_if = "Option::is_none")]
2006    pub scope: Option<types::BotCommandScope>,
2007    /// A two-letter ISO 639-1 language code. If empty, commands will be applied to all users from the given scope, for whose language there are no dedicated commands
2008    #[serde(skip_serializing_if = "Option::is_none")]
2009    pub language_code: Option<String>,
2010}
2011impl SetMyCommands {
2012    pub fn new(commands: Vec<types::BotCommand>) -> Self {
2013        Self {
2014            commands,
2015            scope: None,
2016            language_code: None,
2017        }
2018    }
2019}
2020
2021impl Methods for SetMyCommands {
2022    fn endpoint(&self) -> String {
2023        "setMyCommands".to_string()
2024    }
2025}
2026
2027/// Use this method to delete the list of the bot's commands for the given scope and user language. After deletion, higher level commands will be shown to affected users. Returns True on success.
2028#[derive(Deserialize, Serialize, Debug, Clone)]
2029pub struct DeleteMyCommands {
2030    /// A JSON-serialized object, describing scope of users for which the commands are relevant. Defaults to BotCommandScopeDefault.
2031    #[serde(skip_serializing_if = "Option::is_none")]
2032    pub scope: Option<types::BotCommandScope>,
2033    /// A two-letter ISO 639-1 language code. If empty, commands will be applied to all users from the given scope, for whose language there are no dedicated commands
2034    #[serde(skip_serializing_if = "Option::is_none")]
2035    pub language_code: Option<String>,
2036}
2037impl DeleteMyCommands {
2038    pub fn new() -> Self {
2039        Self {
2040            scope: None,
2041            language_code: None,
2042        }
2043    }
2044}
2045
2046impl Methods for DeleteMyCommands {
2047    fn endpoint(&self) -> String {
2048        "deleteMyCommands".to_string()
2049    }
2050}
2051
2052/// Use this method to get the current list of the bot's commands for the given scope and user language. Returns an Array of BotCommand objects. If commands aren't set, an empty list is returned.
2053#[derive(Deserialize, Serialize, Debug, Clone)]
2054pub struct GetMyCommands {
2055    /// A JSON-serialized object, describing scope of users. Defaults to BotCommandScopeDefault.
2056    #[serde(skip_serializing_if = "Option::is_none")]
2057    pub scope: Option<types::BotCommandScope>,
2058    /// A two-letter ISO 639-1 language code or an empty string
2059    #[serde(skip_serializing_if = "Option::is_none")]
2060    pub language_code: Option<String>,
2061}
2062impl GetMyCommands {
2063    pub fn new() -> Self {
2064        Self {
2065            scope: None,
2066            language_code: None,
2067        }
2068    }
2069}
2070
2071impl Methods for GetMyCommands {
2072    fn endpoint(&self) -> String {
2073        "getMyCommands".to_string()
2074    }
2075}
2076
2077/// Use this method to change the bot's menu button in a private chat, or the default menu button. Returns True on success.
2078#[derive(Deserialize, Serialize, Debug, Clone)]
2079pub struct SetChatMenuButton {
2080    /// Unique identifier for the target private chat. If not specified, default bot's menu button will be changed
2081    #[serde(skip_serializing_if = "Option::is_none")]
2082    pub chat_id: Option<i64>,
2083    /// A JSON-serialized object for the bot's new menu button. Defaults to MenuButtonDefault
2084    #[serde(skip_serializing_if = "Option::is_none")]
2085    pub menu_button: Option<types::MenuButton>,
2086}
2087impl SetChatMenuButton {
2088    pub fn new() -> Self {
2089        Self {
2090            chat_id: None,
2091            menu_button: None,
2092        }
2093    }
2094}
2095
2096impl Methods for SetChatMenuButton {
2097    fn endpoint(&self) -> String {
2098        "setChatMenuButton".to_string()
2099    }
2100}
2101
2102/// Use this method to get the current value of the bot's menu button in a private chat, or the default menu button. Returns MenuButton on success.
2103#[derive(Deserialize, Serialize, Debug, Clone)]
2104pub struct GetChatMenuButton {
2105    /// Unique identifier for the target private chat. If not specified, default bot's menu button will be returned
2106    #[serde(skip_serializing_if = "Option::is_none")]
2107    pub chat_id: Option<i64>,
2108}
2109impl GetChatMenuButton {
2110    pub fn new() -> Self {
2111        Self { chat_id: None }
2112    }
2113}
2114
2115impl Methods for GetChatMenuButton {
2116    fn endpoint(&self) -> String {
2117        "getChatMenuButton".to_string()
2118    }
2119}
2120
2121/// Use this method to change the default administrator rights requested by the bot when it's added as an administrator to groups or channels. These rights will be suggested to users, but they are are free to modify the list before adding the bot. Returns True on success.
2122#[derive(Deserialize, Serialize, Debug, Clone)]
2123pub struct SetMyDefaultAdministratorRights {
2124    /// A JSON-serialized object describing new default administrator rights. If not specified, the default administrator rights will be cleared.
2125    #[serde(skip_serializing_if = "Option::is_none")]
2126    pub rights: Option<types::ChatAdministratorRights>,
2127    /// Pass True to change the default administrator rights of the bot in channels. Otherwise, the default administrator rights of the bot for groups and supergroups will be changed.
2128    #[serde(skip_serializing_if = "Option::is_none")]
2129    pub for_channels: Option<bool>,
2130}
2131impl SetMyDefaultAdministratorRights {
2132    pub fn new() -> Self {
2133        Self {
2134            rights: None,
2135            for_channels: None,
2136        }
2137    }
2138}
2139
2140impl Methods for SetMyDefaultAdministratorRights {
2141    fn endpoint(&self) -> String {
2142        "setMyDefaultAdministratorRights".to_string()
2143    }
2144}
2145
2146/// Use this method to get the current default administrator rights of the bot. Returns ChatAdministratorRights on success.
2147#[derive(Deserialize, Serialize, Debug, Clone)]
2148pub struct GetMyDefaultAdministratorRights {
2149    /// Pass True to get default administrator rights of the bot in channels. Otherwise, default administrator rights of the bot for groups and supergroups will be returned.
2150    #[serde(skip_serializing_if = "Option::is_none")]
2151    pub for_channels: Option<bool>,
2152}
2153impl GetMyDefaultAdministratorRights {
2154    pub fn new() -> Self {
2155        Self { for_channels: None }
2156    }
2157}
2158
2159impl Methods for GetMyDefaultAdministratorRights {
2160    fn endpoint(&self) -> String {
2161        "getMyDefaultAdministratorRights".to_string()
2162    }
2163}
2164
2165/// Use this method to receive incoming updates using long polling (wiki). Returns an Array of Update objects.
2166#[derive(Deserialize, Serialize, Debug, Clone)]
2167pub struct GetUpdates {
2168    /// Identifier of the first update to be returned. Must be greater by one than the highest among the identifiers of previously received updates. By default, updates starting with the earliest unconfirmed update are returned. An update is considered confirmed as soon as getUpdates is called with an offset higher than its update_id. The negative offset can be specified to retrieve updates starting from -offset update from the end of the updates queue. All previous updates will forgotten.
2169    #[serde(skip_serializing_if = "Option::is_none")]
2170    pub offset: Option<i64>,
2171    /// Limits the number of updates to be retrieved. Values between 1-100 are accepted. Defaults to 100.
2172    #[serde(skip_serializing_if = "Option::is_none")]
2173    pub limit: Option<i64>,
2174    /// Timeout in seconds for long polling. Defaults to 0, i.e. usual short polling. Should be positive, short polling should be used for testing purposes only.
2175    #[serde(skip_serializing_if = "Option::is_none")]
2176    pub timeout: Option<i64>,
2177    /// A JSON-serialized list of the update types you want your bot to receive. For example, specify [“message”, “edited_channel_post”, “callback_query”] to only receive updates of these types. See Update for a complete list of available update types. Specify an empty list to receive all update types except chat_member (default). If not specified, the previous setting will be used.
2178    #[serde(skip_serializing_if = "Option::is_none")]
2179    pub allowed_updates: Option<Vec<String>>,
2180}
2181impl GetUpdates {
2182    pub fn new() -> Self {
2183        Self {
2184            offset: None,
2185            limit: None,
2186            timeout: None,
2187            allowed_updates: None,
2188        }
2189    }
2190}
2191
2192impl Methods for GetUpdates {
2193    fn endpoint(&self) -> String {
2194        "getUpdates".to_string()
2195    }
2196}
2197
2198/// Use this method to specify a URL and receive incoming updates via an outgoing webhook. Whenever there is an update for the bot, we will send an HTTPS POST request to the specified URL, containing a JSON-serialized Update. In case of an unsuccessful request, we will give up after a reasonable amount of attempts. Returns True on success.
2199#[derive(Deserialize, Serialize, Debug, Clone)]
2200pub struct SetWebhook {
2201    /// HTTPS URL to send updates to. Use an empty string to remove webhook integration
2202    pub url: String,
2203    /// Upload your public key certificate so that the root certificate in use can be checked. See our self-signed guide for details.
2204    #[serde(skip_serializing)]
2205    pub certificate: Option<types::InputFile>,
2206    /// The fixed IP address which will be used to send webhook requests instead of the IP address resolved through DNS
2207    #[serde(skip_serializing_if = "Option::is_none")]
2208    pub ip_address: Option<String>,
2209    /// The maximum allowed number of simultaneous HTTPS connections to the webhook for update delivery, 1-100. Defaults to 40. Use lower values to limit the load on your bot's server, and higher values to increase your bot's throughput.
2210    #[serde(skip_serializing_if = "Option::is_none")]
2211    pub max_connections: Option<i64>,
2212    /// A JSON-serialized list of the update types you want your bot to receive. For example, specify [“message”, “edited_channel_post”, “callback_query”] to only receive updates of these types. See Update for a complete list of available update types. Specify an empty list to receive all update types except chat_member (default). If not specified, the previous setting will be used.
2213    #[serde(skip_serializing_if = "Option::is_none")]
2214    pub allowed_updates: Option<Vec<String>>,
2215    /// Pass True to drop all pending updates
2216    #[serde(skip_serializing_if = "Option::is_none")]
2217    pub drop_pending_updates: Option<bool>,
2218    /// A secret token to be sent in a header “X-Telegram-Bot-Api-Secret-Token” in every webhook request, 1-256 characters. Only characters A-Z, a-z, 0-9, _ and - are allowed. The header is useful to ensure that the request comes from a webhook set by you.
2219    #[serde(skip_serializing_if = "Option::is_none")]
2220    pub secret_token: Option<String>,
2221}
2222impl SetWebhook {
2223    pub fn new(url: String) -> Self {
2224        Self {
2225            url,
2226            certificate: None,
2227            ip_address: None,
2228            max_connections: None,
2229            allowed_updates: None,
2230            drop_pending_updates: None,
2231            secret_token: None,
2232        }
2233    }
2234}
2235
2236impl Methods for SetWebhook {
2237    fn endpoint(&self) -> String {
2238        "setWebhook".to_string()
2239    }
2240
2241    fn files(&self) -> HashMap<String, types::InputFile> {
2242        let mut result = HashMap::new();
2243        if let Some(certificate) = &self.certificate {
2244            result.insert("certificate".to_string(), certificate.clone());
2245        }
2246        result
2247    }
2248}
2249
2250/// Use this method to remove webhook integration if you decide to switch back to getUpdates. Returns True on success.
2251#[derive(Deserialize, Serialize, Debug, Clone)]
2252pub struct DeleteWebhook {
2253    /// Pass True to drop all pending updates
2254    #[serde(skip_serializing_if = "Option::is_none")]
2255    pub drop_pending_updates: Option<bool>,
2256}
2257impl DeleteWebhook {
2258    pub fn new() -> Self {
2259        Self {
2260            drop_pending_updates: None,
2261        }
2262    }
2263}
2264
2265impl Methods for DeleteWebhook {
2266    fn endpoint(&self) -> String {
2267        "deleteWebhook".to_string()
2268    }
2269}
2270
2271/// Use this method to get current webhook status. Requires no parameters. On success, returns a WebhookInfo object. If the bot is using getUpdates, will return an object with the url field empty.
2272#[derive(Deserialize, Serialize, Debug, Clone)]
2273pub struct GetWebhookInfo {}
2274impl GetWebhookInfo {
2275    pub fn new() -> Self {
2276        Self {}
2277    }
2278}
2279
2280impl Methods for GetWebhookInfo {
2281    fn endpoint(&self) -> String {
2282        "getWebhookInfo".to_string()
2283    }
2284}
2285
2286/// Use this method to send static .WEBP, animated .TGS, or video .WEBM stickers. On success, the sent Message is returned.
2287#[derive(Deserialize, Serialize, Debug, Clone)]
2288pub struct SendSticker {
2289    /// Unique identifier for the target chat or username of the target channel (in the format @channelusername)
2290    pub chat_id: types::ChatId,
2291    /// Sticker to send. Pass a file_id as String to send a file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a .WEBP file from the Internet, or upload a new one using multipart/form-data. More information on Sending Files »
2292    #[serde(skip_serializing)]
2293    pub sticker: types::InputFile,
2294    /// Sends the message silently. Users will receive a notification with no sound.
2295    #[serde(skip_serializing_if = "Option::is_none")]
2296    pub disable_notification: Option<bool>,
2297    /// Protects the contents of the sent message from forwarding and saving
2298    #[serde(skip_serializing_if = "Option::is_none")]
2299    pub protect_content: Option<bool>,
2300    /// If the message is a reply, ID of the original message
2301    #[serde(skip_serializing_if = "Option::is_none")]
2302    pub reply_to_message_id: Option<i64>,
2303    /// Pass True if the message should be sent even if the specified replied-to message is not found
2304    #[serde(skip_serializing_if = "Option::is_none")]
2305    pub allow_sending_without_reply: Option<bool>,
2306    /// Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.
2307    #[serde(skip_serializing_if = "Option::is_none")]
2308    pub reply_markup: Option<types::ReplyMarkup>,
2309}
2310impl SendSticker {
2311    pub fn new(chat_id: types::ChatId, sticker: types::InputFile) -> Self {
2312        Self {
2313            chat_id,
2314            sticker,
2315            disable_notification: None,
2316            protect_content: None,
2317            reply_to_message_id: None,
2318            allow_sending_without_reply: None,
2319            reply_markup: None,
2320        }
2321    }
2322}
2323
2324impl Methods for SendSticker {
2325    fn endpoint(&self) -> String {
2326        "sendSticker".to_string()
2327    }
2328
2329    fn files(&self) -> HashMap<String, types::InputFile> {
2330        let mut result = HashMap::new();
2331        result.insert("sticker".to_string(), self.sticker.clone());
2332        result
2333    }
2334}
2335
2336/// Use this method to get a sticker set. On success, a StickerSet object is returned.
2337#[derive(Deserialize, Serialize, Debug, Clone)]
2338pub struct GetStickerSet {
2339    /// Name of the sticker set
2340    pub name: String,
2341}
2342impl GetStickerSet {
2343    pub fn new(name: String) -> Self {
2344        Self { name }
2345    }
2346}
2347
2348impl Methods for GetStickerSet {
2349    fn endpoint(&self) -> String {
2350        "getStickerSet".to_string()
2351    }
2352}
2353
2354/// Use this method to get information about custom emoji stickers by their identifiers. Returns an Array of Sticker objects.
2355#[derive(Deserialize, Serialize, Debug, Clone)]
2356pub struct GetCustomEmojiStickers {
2357    /// List of custom emoji identifiers. At most 200 custom emoji identifiers can be specified.
2358    pub custom_emoji_ids: Vec<String>,
2359}
2360impl GetCustomEmojiStickers {
2361    pub fn new(custom_emoji_ids: Vec<String>) -> Self {
2362        Self { custom_emoji_ids }
2363    }
2364}
2365
2366impl Methods for GetCustomEmojiStickers {
2367    fn endpoint(&self) -> String {
2368        "getCustomEmojiStickers".to_string()
2369    }
2370}
2371
2372/// Use this method to upload a .PNG file with a sticker for later use in createNewStickerSet and addStickerToSet methods (can be used multiple times). Returns the uploaded File on success.
2373#[derive(Deserialize, Serialize, Debug, Clone)]
2374pub struct UploadStickerFile {
2375    /// User identifier of sticker file owner
2376    pub user_id: i64,
2377    /// PNG image with the sticker, must be up to 512 kilobytes in size, dimensions must not exceed 512px, and either width or height must be exactly 512px. More information on Sending Files »
2378    #[serde(skip_serializing)]
2379    pub png_sticker: types::InputFile,
2380}
2381impl UploadStickerFile {
2382    pub fn new(user_id: i64, png_sticker: types::InputFile) -> Self {
2383        Self {
2384            user_id,
2385            png_sticker,
2386        }
2387    }
2388}
2389
2390impl Methods for UploadStickerFile {
2391    fn endpoint(&self) -> String {
2392        "uploadStickerFile".to_string()
2393    }
2394
2395    fn files(&self) -> HashMap<String, types::InputFile> {
2396        let mut result = HashMap::new();
2397        result.insert("png_sticker".to_string(), self.png_sticker.clone());
2398        result
2399    }
2400}
2401
2402/// Use this method to create a new sticker set owned by a user. The bot will be able to edit the sticker set thus created. You must use exactly one of the fields png_sticker, tgs_sticker, or webm_sticker. Returns True on success.
2403#[derive(Deserialize, Serialize, Debug, Clone)]
2404pub struct CreateNewStickerSet {
2405    /// User identifier of created sticker set owner
2406    pub user_id: i64,
2407    /// Short name of sticker set, to be used in t.me/addstickers/ URLs (e.g., animals). Can contain only English letters, digits and underscores. Must begin with a letter, can't contain consecutive underscores and must end in _by_<bot_username>. <bot_username> is case insensitive. 1-64 characters.
2408    pub name: String,
2409    /// Sticker set title, 1-64 characters
2410    pub title: String,
2411    /// PNG image with the sticker, must be up to 512 kilobytes in size, dimensions must not exceed 512px, and either width or height must be exactly 512px. Pass a file_id as a String to send a file that already exists on the Telegram servers, pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data. More information on Sending Files »
2412    #[serde(skip_serializing)]
2413    pub png_sticker: Option<types::InputFile>,
2414    /// TGS animation with the sticker, uploaded using multipart/form-data. See https://core.telegram.org/stickers#animated-sticker-requirements for technical requirements
2415    #[serde(skip_serializing)]
2416    pub tgs_sticker: Option<types::InputFile>,
2417    /// WEBM video with the sticker, uploaded using multipart/form-data. See https://core.telegram.org/stickers#video-sticker-requirements for technical requirements
2418    #[serde(skip_serializing)]
2419    pub webm_sticker: Option<types::InputFile>,
2420    /// Type of stickers in the set, pass “regular” or “mask”. Custom emoji sticker sets can't be created via the Bot API at the moment. By default, a regular sticker set is created.
2421    #[serde(skip_serializing_if = "Option::is_none")]
2422    pub sticker_type: Option<String>,
2423    /// One or more emoji corresponding to the sticker
2424    pub emojis: String,
2425    /// A JSON-serialized object for position where the mask should be placed on faces
2426    #[serde(skip_serializing_if = "Option::is_none")]
2427    pub mask_position: Option<types::MaskPosition>,
2428}
2429impl CreateNewStickerSet {
2430    pub fn new(user_id: i64, name: String, title: String, emojis: String) -> Self {
2431        Self {
2432            user_id,
2433            name,
2434            title,
2435            png_sticker: None,
2436            tgs_sticker: None,
2437            webm_sticker: None,
2438            sticker_type: None,
2439            emojis,
2440            mask_position: None,
2441        }
2442    }
2443}
2444
2445impl Methods for CreateNewStickerSet {
2446    fn endpoint(&self) -> String {
2447        "createNewStickerSet".to_string()
2448    }
2449
2450    fn files(&self) -> HashMap<String, types::InputFile> {
2451        let mut result = HashMap::new();
2452        if let Some(png_sticker) = &self.png_sticker {
2453            result.insert("png_sticker".to_string(), png_sticker.clone());
2454        }
2455        if let Some(tgs_sticker) = &self.tgs_sticker {
2456            result.insert("tgs_sticker".to_string(), tgs_sticker.clone());
2457        }
2458        if let Some(webm_sticker) = &self.webm_sticker {
2459            result.insert("webm_sticker".to_string(), webm_sticker.clone());
2460        }
2461        result
2462    }
2463}
2464
2465/// Use this method to add a new sticker to a set created by the bot. You must use exactly one of the fields png_sticker, tgs_sticker, or webm_sticker. Animated stickers can be added to animated sticker sets and only to them. Animated sticker sets can have up to 50 stickers. Static sticker sets can have up to 120 stickers. Returns True on success.
2466#[derive(Deserialize, Serialize, Debug, Clone)]
2467pub struct AddStickerToSet {
2468    /// User identifier of sticker set owner
2469    pub user_id: i64,
2470    /// Sticker set name
2471    pub name: String,
2472    /// PNG image with the sticker, must be up to 512 kilobytes in size, dimensions must not exceed 512px, and either width or height must be exactly 512px. Pass a file_id as a String to send a file that already exists on the Telegram servers, pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data. More information on Sending Files »
2473    #[serde(skip_serializing)]
2474    pub png_sticker: Option<types::InputFile>,
2475    /// TGS animation with the sticker, uploaded using multipart/form-data. See https://core.telegram.org/stickers#animated-sticker-requirements for technical requirements
2476    #[serde(skip_serializing)]
2477    pub tgs_sticker: Option<types::InputFile>,
2478    /// WEBM video with the sticker, uploaded using multipart/form-data. See https://core.telegram.org/stickers#video-sticker-requirements for technical requirements
2479    #[serde(skip_serializing)]
2480    pub webm_sticker: Option<types::InputFile>,
2481    /// One or more emoji corresponding to the sticker
2482    pub emojis: String,
2483    /// A JSON-serialized object for position where the mask should be placed on faces
2484    #[serde(skip_serializing_if = "Option::is_none")]
2485    pub mask_position: Option<types::MaskPosition>,
2486}
2487impl AddStickerToSet {
2488    pub fn new(user_id: i64, name: String, emojis: String) -> Self {
2489        Self {
2490            user_id,
2491            name,
2492            png_sticker: None,
2493            tgs_sticker: None,
2494            webm_sticker: None,
2495            emojis,
2496            mask_position: None,
2497        }
2498    }
2499}
2500
2501impl Methods for AddStickerToSet {
2502    fn endpoint(&self) -> String {
2503        "addStickerToSet".to_string()
2504    }
2505
2506    fn files(&self) -> HashMap<String, types::InputFile> {
2507        let mut result = HashMap::new();
2508        if let Some(png_sticker) = &self.png_sticker {
2509            result.insert("png_sticker".to_string(), png_sticker.clone());
2510        }
2511        if let Some(tgs_sticker) = &self.tgs_sticker {
2512            result.insert("tgs_sticker".to_string(), tgs_sticker.clone());
2513        }
2514        if let Some(webm_sticker) = &self.webm_sticker {
2515            result.insert("webm_sticker".to_string(), webm_sticker.clone());
2516        }
2517        result
2518    }
2519}
2520
2521/// Use this method to move a sticker in a set created by the bot to a specific position. Returns True on success.
2522#[derive(Deserialize, Serialize, Debug, Clone)]
2523pub struct SetStickerPositionInSet {
2524    /// File identifier of the sticker
2525    pub sticker: String,
2526    /// New sticker position in the set, zero-based
2527    pub position: i64,
2528}
2529impl SetStickerPositionInSet {
2530    pub fn new(sticker: String, position: i64) -> Self {
2531        Self { sticker, position }
2532    }
2533}
2534
2535impl Methods for SetStickerPositionInSet {
2536    fn endpoint(&self) -> String {
2537        "setStickerPositionInSet".to_string()
2538    }
2539}
2540
2541/// Use this method to delete a sticker from a set created by the bot. Returns True on success.
2542#[derive(Deserialize, Serialize, Debug, Clone)]
2543pub struct DeleteStickerFromSet {
2544    /// File identifier of the sticker
2545    pub sticker: String,
2546}
2547impl DeleteStickerFromSet {
2548    pub fn new(sticker: String) -> Self {
2549        Self { sticker }
2550    }
2551}
2552
2553impl Methods for DeleteStickerFromSet {
2554    fn endpoint(&self) -> String {
2555        "deleteStickerFromSet".to_string()
2556    }
2557}
2558
2559/// Use this method to set the thumbnail of a sticker set. Animated thumbnails can be set for animated sticker sets only. Video thumbnails can be set only for video sticker sets only. Returns True on success.
2560#[derive(Deserialize, Serialize, Debug, Clone)]
2561pub struct SetStickerSetThumb {
2562    /// Sticker set name
2563    pub name: String,
2564    /// User identifier of the sticker set owner
2565    pub user_id: i64,
2566    /// A PNG image with the thumbnail, must be up to 128 kilobytes in size and have width and height exactly 100px, or a TGS animation with the thumbnail up to 32 kilobytes in size; see https://core.telegram.org/stickers#animated-sticker-requirements for animated sticker technical requirements, or a WEBM video with the thumbnail up to 32 kilobytes in size; see https://core.telegram.org/stickers#video-sticker-requirements for video sticker technical requirements. Pass a file_id as a String to send a file that already exists on the Telegram servers, pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data. More information on Sending Files ». Animated sticker set thumbnails can't be uploaded via HTTP URL.
2567    #[serde(skip_serializing)]
2568    pub thumb: Option<types::InputFile>,
2569}
2570impl SetStickerSetThumb {
2571    pub fn new(name: String, user_id: i64) -> Self {
2572        Self {
2573            name,
2574            user_id,
2575            thumb: None,
2576        }
2577    }
2578}
2579
2580impl Methods for SetStickerSetThumb {
2581    fn endpoint(&self) -> String {
2582        "setStickerSetThumb".to_string()
2583    }
2584
2585    fn files(&self) -> HashMap<String, types::InputFile> {
2586        let mut result = HashMap::new();
2587        if let Some(thumb) = &self.thumb {
2588            result.insert("thumb".to_string(), thumb.clone());
2589        }
2590        result
2591    }
2592}
2593
2594/// Use this method to send answers to an inline query. On success, True is returned. No more than 50 results per query are allowed.
2595#[derive(Deserialize, Serialize, Debug, Clone)]
2596pub struct AnswerInlineQuery {
2597    /// Unique identifier for the answered query
2598    pub inline_query_id: String,
2599    /// A JSON-serialized array of results for the inline query
2600    pub results: Vec<types::InlineQueryResult>,
2601    /// The maximum amount of time in seconds that the result of the inline query may be cached on the server. Defaults to 300.
2602    #[serde(skip_serializing_if = "Option::is_none")]
2603    pub cache_time: Option<i64>,
2604    /// Pass True if results may be cached on the server side only for the user that sent the query. By default, results may be returned to any user who sends the same query
2605    #[serde(skip_serializing_if = "Option::is_none")]
2606    pub is_personal: Option<bool>,
2607    /// Pass the offset that a client should send in the next query with the same text to receive more results. Pass an empty string if there are no more results or if you don't support pagination. Offset length can't exceed 64 bytes.
2608    #[serde(skip_serializing_if = "Option::is_none")]
2609    pub next_offset: Option<String>,
2610    /// If passed, clients will display a button with specified text that switches the user to a private chat with the bot and sends the bot a start message with the parameter switch_pm_parameter
2611    #[serde(skip_serializing_if = "Option::is_none")]
2612    pub switch_pm_text: Option<String>,
2613    /// Deep-linking parameter for the /start message sent to the bot when user presses the switch button. 1-64 characters, only A-Z, a-z, 0-9, _ and - are allowed.
2614    #[serde(skip_serializing_if = "Option::is_none")]
2615    pub switch_pm_parameter: Option<String>,
2616}
2617impl AnswerInlineQuery {
2618    pub fn new(inline_query_id: String, results: Vec<types::InlineQueryResult>) -> Self {
2619        Self {
2620            inline_query_id,
2621            results,
2622            cache_time: None,
2623            is_personal: None,
2624            next_offset: None,
2625            switch_pm_text: None,
2626            switch_pm_parameter: None,
2627        }
2628    }
2629}
2630
2631impl Methods for AnswerInlineQuery {
2632    fn endpoint(&self) -> String {
2633        "answerInlineQuery".to_string()
2634    }
2635}
2636
2637/// Use this method to set the result of an interaction with a Web App and send a corresponding message on behalf of the user to the chat from which the query originated. On success, a SentWebAppMessage object is returned.
2638#[derive(Deserialize, Serialize, Debug, Clone)]
2639pub struct AnswerWebAppQuery {
2640    /// Unique identifier for the query to be answered
2641    pub web_app_query_id: String,
2642    /// A JSON-serialized object describing the message to be sent
2643    pub result: types::InlineQueryResult,
2644}
2645impl AnswerWebAppQuery {
2646    pub fn new(web_app_query_id: String, result: types::InlineQueryResult) -> Self {
2647        Self {
2648            web_app_query_id,
2649            result,
2650        }
2651    }
2652}
2653
2654impl Methods for AnswerWebAppQuery {
2655    fn endpoint(&self) -> String {
2656        "answerWebAppQuery".to_string()
2657    }
2658}
2659
2660/// Use this method to send invoices. On success, the sent Message is returned.
2661#[derive(Deserialize, Serialize, Debug, Clone)]
2662pub struct SendInvoice {
2663    /// Unique identifier for the target chat or username of the target channel (in the format @channelusername)
2664    pub chat_id: types::ChatId,
2665    /// Product name, 1-32 characters
2666    pub title: String,
2667    /// Product description, 1-255 characters
2668    pub description: String,
2669    /// Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use for your internal processes.
2670    pub payload: String,
2671    /// Payment provider token, obtained via @BotFather
2672    pub provider_token: String,
2673    /// Three-letter ISO 4217 currency code, see more on currencies
2674    pub currency: String,
2675    /// Price breakdown, a JSON-serialized list of components (e.g. product price, tax, discount, delivery cost, delivery tax, bonus, etc.)
2676    pub prices: Vec<types::LabeledPrice>,
2677    /// 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
2678    #[serde(skip_serializing_if = "Option::is_none")]
2679    pub max_tip_amount: Option<i64>,
2680    /// 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.
2681    #[serde(skip_serializing_if = "Option::is_none")]
2682    pub suggested_tip_amounts: Option<Vec<i64>>,
2683    /// 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
2684    #[serde(skip_serializing_if = "Option::is_none")]
2685    pub start_parameter: Option<String>,
2686    /// 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.
2687    #[serde(skip_serializing_if = "Option::is_none")]
2688    pub provider_data: Option<String>,
2689    /// 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.
2690    #[serde(skip_serializing_if = "Option::is_none")]
2691    pub photo_url: Option<String>,
2692    /// Photo size in bytes
2693    #[serde(skip_serializing_if = "Option::is_none")]
2694    pub photo_size: Option<i64>,
2695    /// Photo width
2696    #[serde(skip_serializing_if = "Option::is_none")]
2697    pub photo_width: Option<i64>,
2698    /// Photo height
2699    #[serde(skip_serializing_if = "Option::is_none")]
2700    pub photo_height: Option<i64>,
2701    /// Pass True if you require the user's full name to complete the order
2702    #[serde(skip_serializing_if = "Option::is_none")]
2703    pub need_name: Option<bool>,
2704    /// Pass True if you require the user's phone number to complete the order
2705    #[serde(skip_serializing_if = "Option::is_none")]
2706    pub need_phone_number: Option<bool>,
2707    /// Pass True if you require the user's email address to complete the order
2708    #[serde(skip_serializing_if = "Option::is_none")]
2709    pub need_email: Option<bool>,
2710    /// Pass True if you require the user's shipping address to complete the order
2711    #[serde(skip_serializing_if = "Option::is_none")]
2712    pub need_shipping_address: Option<bool>,
2713    /// Pass True if the user's phone number should be sent to provider
2714    #[serde(skip_serializing_if = "Option::is_none")]
2715    pub send_phone_number_to_provider: Option<bool>,
2716    /// Pass True if the user's email address should be sent to provider
2717    #[serde(skip_serializing_if = "Option::is_none")]
2718    pub send_email_to_provider: Option<bool>,
2719    /// Pass True if the final price depends on the shipping method
2720    #[serde(skip_serializing_if = "Option::is_none")]
2721    pub is_flexible: Option<bool>,
2722    /// Sends the message silently. Users will receive a notification with no sound.
2723    #[serde(skip_serializing_if = "Option::is_none")]
2724    pub disable_notification: Option<bool>,
2725    /// Protects the contents of the sent message from forwarding and saving
2726    #[serde(skip_serializing_if = "Option::is_none")]
2727    pub protect_content: Option<bool>,
2728    /// If the message is a reply, ID of the original message
2729    #[serde(skip_serializing_if = "Option::is_none")]
2730    pub reply_to_message_id: Option<i64>,
2731    /// Pass True if the message should be sent even if the specified replied-to message is not found
2732    #[serde(skip_serializing_if = "Option::is_none")]
2733    pub allow_sending_without_reply: Option<bool>,
2734    /// A JSON-serialized object for an inline keyboard. If empty, one 'Pay total price' button will be shown. If not empty, the first button must be a Pay button.
2735    #[serde(skip_serializing_if = "Option::is_none")]
2736    pub reply_markup: Option<types::InlineKeyboardMarkup>,
2737}
2738impl SendInvoice {
2739    pub fn new(
2740        chat_id: types::ChatId,
2741        title: String,
2742        description: String,
2743        payload: String,
2744        provider_token: String,
2745        currency: String,
2746        prices: Vec<types::LabeledPrice>,
2747    ) -> Self {
2748        Self {
2749            chat_id,
2750            title,
2751            description,
2752            payload,
2753            provider_token,
2754            currency,
2755            prices,
2756            max_tip_amount: None,
2757            suggested_tip_amounts: None,
2758            start_parameter: None,
2759            provider_data: None,
2760            photo_url: None,
2761            photo_size: None,
2762            photo_width: None,
2763            photo_height: None,
2764            need_name: None,
2765            need_phone_number: None,
2766            need_email: None,
2767            need_shipping_address: None,
2768            send_phone_number_to_provider: None,
2769            send_email_to_provider: None,
2770            is_flexible: None,
2771            disable_notification: None,
2772            protect_content: None,
2773            reply_to_message_id: None,
2774            allow_sending_without_reply: None,
2775            reply_markup: None,
2776        }
2777    }
2778}
2779
2780impl Methods for SendInvoice {
2781    fn endpoint(&self) -> String {
2782        "sendInvoice".to_string()
2783    }
2784}
2785
2786/// Use this method to create a link for an invoice. Returns the created invoice link as String on success.
2787#[derive(Deserialize, Serialize, Debug, Clone)]
2788pub struct CreateInvoiceLink {
2789    /// Product name, 1-32 characters
2790    pub title: String,
2791    /// Product description, 1-255 characters
2792    pub description: String,
2793    /// Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use for your internal processes.
2794    pub payload: String,
2795    /// Payment provider token, obtained via BotFather
2796    pub provider_token: String,
2797    /// Three-letter ISO 4217 currency code, see more on currencies
2798    pub currency: String,
2799    /// Price breakdown, a JSON-serialized list of components (e.g. product price, tax, discount, delivery cost, delivery tax, bonus, etc.)
2800    pub prices: Vec<types::LabeledPrice>,
2801    /// 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
2802    #[serde(skip_serializing_if = "Option::is_none")]
2803    pub max_tip_amount: Option<i64>,
2804    /// 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.
2805    #[serde(skip_serializing_if = "Option::is_none")]
2806    pub suggested_tip_amounts: Option<Vec<i64>>,
2807    /// 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.
2808    #[serde(skip_serializing_if = "Option::is_none")]
2809    pub provider_data: Option<String>,
2810    /// URL of the product photo for the invoice. Can be a photo of the goods or a marketing image for a service.
2811    #[serde(skip_serializing_if = "Option::is_none")]
2812    pub photo_url: Option<String>,
2813    /// Photo size in bytes
2814    #[serde(skip_serializing_if = "Option::is_none")]
2815    pub photo_size: Option<i64>,
2816    /// Photo width
2817    #[serde(skip_serializing_if = "Option::is_none")]
2818    pub photo_width: Option<i64>,
2819    /// Photo height
2820    #[serde(skip_serializing_if = "Option::is_none")]
2821    pub photo_height: Option<i64>,
2822    /// Pass True if you require the user's full name to complete the order
2823    #[serde(skip_serializing_if = "Option::is_none")]
2824    pub need_name: Option<bool>,
2825    /// Pass True if you require the user's phone number to complete the order
2826    #[serde(skip_serializing_if = "Option::is_none")]
2827    pub need_phone_number: Option<bool>,
2828    /// Pass True if you require the user's email address to complete the order
2829    #[serde(skip_serializing_if = "Option::is_none")]
2830    pub need_email: Option<bool>,
2831    /// Pass True if you require the user's shipping address to complete the order
2832    #[serde(skip_serializing_if = "Option::is_none")]
2833    pub need_shipping_address: Option<bool>,
2834    /// Pass True if the user's phone number should be sent to the provider
2835    #[serde(skip_serializing_if = "Option::is_none")]
2836    pub send_phone_number_to_provider: Option<bool>,
2837    /// Pass True if the user's email address should be sent to the provider
2838    #[serde(skip_serializing_if = "Option::is_none")]
2839    pub send_email_to_provider: Option<bool>,
2840    /// Pass True if the final price depends on the shipping method
2841    #[serde(skip_serializing_if = "Option::is_none")]
2842    pub is_flexible: Option<bool>,
2843}
2844impl CreateInvoiceLink {
2845    pub fn new(
2846        title: String,
2847        description: String,
2848        payload: String,
2849        provider_token: String,
2850        currency: String,
2851        prices: Vec<types::LabeledPrice>,
2852    ) -> Self {
2853        Self {
2854            title,
2855            description,
2856            payload,
2857            provider_token,
2858            currency,
2859            prices,
2860            max_tip_amount: None,
2861            suggested_tip_amounts: None,
2862            provider_data: None,
2863            photo_url: None,
2864            photo_size: None,
2865            photo_width: None,
2866            photo_height: None,
2867            need_name: None,
2868            need_phone_number: None,
2869            need_email: None,
2870            need_shipping_address: None,
2871            send_phone_number_to_provider: None,
2872            send_email_to_provider: None,
2873            is_flexible: None,
2874        }
2875    }
2876}
2877
2878impl Methods for CreateInvoiceLink {
2879    fn endpoint(&self) -> String {
2880        "createInvoiceLink".to_string()
2881    }
2882}
2883
2884/// If you sent an invoice requesting a shipping address and the parameter is_flexible was specified, the Bot API will send an Update with a shipping_query field to the bot. Use this method to reply to shipping queries. On success, True is returned.
2885#[derive(Deserialize, Serialize, Debug, Clone)]
2886pub struct AnswerShippingQuery {
2887    /// Unique identifier for the query to be answered
2888    pub shipping_query_id: String,
2889    /// Pass True if delivery to the specified address is possible and False if there are any problems (for example, if delivery to the specified address is not possible)
2890    pub ok: bool,
2891    /// Required if ok is True. A JSON-serialized array of available shipping options.
2892    #[serde(skip_serializing_if = "Option::is_none")]
2893    pub shipping_options: Option<Vec<types::ShippingOption>>,
2894    /// Required if ok is False. Error message in human readable form that explains why it is impossible to complete the order (e.g. 'Sorry, delivery to your desired address is unavailable'). Telegram will display this message to the user.
2895    #[serde(skip_serializing_if = "Option::is_none")]
2896    pub error_message: Option<String>,
2897}
2898impl AnswerShippingQuery {
2899    pub fn new(shipping_query_id: String, ok: bool) -> Self {
2900        Self {
2901            shipping_query_id,
2902            ok,
2903            shipping_options: None,
2904            error_message: None,
2905        }
2906    }
2907}
2908
2909impl Methods for AnswerShippingQuery {
2910    fn endpoint(&self) -> String {
2911        "answerShippingQuery".to_string()
2912    }
2913}
2914
2915/// Once the user has confirmed their payment and shipping details, the Bot API sends the final confirmation in the form of an Update with the field pre_checkout_query. Use this method to respond to such pre-checkout queries. On success, True is returned. Note: The Bot API must receive an answer within 10 seconds after the pre-checkout query was sent.
2916#[derive(Deserialize, Serialize, Debug, Clone)]
2917pub struct AnswerPreCheckoutQuery {
2918    /// Unique identifier for the query to be answered
2919    pub pre_checkout_query_id: String,
2920    /// Specify True if everything is alright (goods are available, etc.) and the bot is ready to proceed with the order. Use False if there are any problems.
2921    pub ok: bool,
2922    /// Required if ok is False. Error message in human readable form that explains the reason for failure to proceed with the checkout (e.g. 'Sorry, somebody just bought the last of our amazing black T-shirts while you were busy filling out your payment details. Please choose a different color or garment!'). Telegram will display this message to the user.
2923    #[serde(skip_serializing_if = "Option::is_none")]
2924    pub error_message: Option<String>,
2925}
2926impl AnswerPreCheckoutQuery {
2927    pub fn new(pre_checkout_query_id: String, ok: bool) -> Self {
2928        Self {
2929            pre_checkout_query_id,
2930            ok,
2931            error_message: None,
2932        }
2933    }
2934}
2935
2936impl Methods for AnswerPreCheckoutQuery {
2937    fn endpoint(&self) -> String {
2938        "answerPreCheckoutQuery".to_string()
2939    }
2940}
2941
2942/// Informs a user that some of the Telegram Passport elements they provided contains errors. The user will not be able to re-submit their Passport to you until the errors are fixed (the contents of the field for which you returned the error must change). Returns True on success.
2943#[derive(Deserialize, Serialize, Debug, Clone)]
2944pub struct SetPassportDataErrors {
2945    /// User identifier
2946    pub user_id: i64,
2947    /// A JSON-serialized array describing the errors
2948    pub errors: Vec<types::PassportElementError>,
2949}
2950impl SetPassportDataErrors {
2951    pub fn new(user_id: i64, errors: Vec<types::PassportElementError>) -> Self {
2952        Self { user_id, errors }
2953    }
2954}
2955
2956impl Methods for SetPassportDataErrors {
2957    fn endpoint(&self) -> String {
2958        "setPassportDataErrors".to_string()
2959    }
2960}
2961
2962/// Use this method to send a game. On success, the sent Message is returned.
2963#[derive(Deserialize, Serialize, Debug, Clone)]
2964pub struct SendGame {
2965    /// Unique identifier for the target chat
2966    pub chat_id: i64,
2967    /// Short name of the game, serves as the unique identifier for the game. Set up your games via @BotFather.
2968    pub game_short_name: String,
2969    /// Sends the message silently. Users will receive a notification with no sound.
2970    #[serde(skip_serializing_if = "Option::is_none")]
2971    pub disable_notification: Option<bool>,
2972    /// Protects the contents of the sent message from forwarding and saving
2973    #[serde(skip_serializing_if = "Option::is_none")]
2974    pub protect_content: Option<bool>,
2975    /// If the message is a reply, ID of the original message
2976    #[serde(skip_serializing_if = "Option::is_none")]
2977    pub reply_to_message_id: Option<i64>,
2978    /// Pass True if the message should be sent even if the specified replied-to message is not found
2979    #[serde(skip_serializing_if = "Option::is_none")]
2980    pub allow_sending_without_reply: Option<bool>,
2981    /// A JSON-serialized object for an inline keyboard. If empty, one 'Play game_title' button will be shown. If not empty, the first button must launch the game.
2982    #[serde(skip_serializing_if = "Option::is_none")]
2983    pub reply_markup: Option<types::InlineKeyboardMarkup>,
2984}
2985impl SendGame {
2986    pub fn new(chat_id: i64, game_short_name: String) -> Self {
2987        Self {
2988            chat_id,
2989            game_short_name,
2990            disable_notification: None,
2991            protect_content: None,
2992            reply_to_message_id: None,
2993            allow_sending_without_reply: None,
2994            reply_markup: None,
2995        }
2996    }
2997}
2998
2999impl Methods for SendGame {
3000    fn endpoint(&self) -> String {
3001        "sendGame".to_string()
3002    }
3003}
3004
3005/// Use this method to set the score of the specified user in a game message. On success, if the message is not an inline message, the Message is returned, otherwise True is returned. Returns an error, if the new score is not greater than the user's current score in the chat and force is False.
3006#[derive(Deserialize, Serialize, Debug, Clone)]
3007pub struct SetGameScore {
3008    /// User identifier
3009    pub user_id: i64,
3010    /// New score, must be non-negative
3011    pub score: i64,
3012    /// Pass True if the high score is allowed to decrease. This can be useful when fixing mistakes or banning cheaters
3013    #[serde(skip_serializing_if = "Option::is_none")]
3014    pub force: Option<bool>,
3015    /// Pass True if the game message should not be automatically edited to include the current scoreboard
3016    #[serde(skip_serializing_if = "Option::is_none")]
3017    pub disable_edit_message: Option<bool>,
3018    /// Required if inline_message_id is not specified. Unique identifier for the target chat
3019    #[serde(skip_serializing_if = "Option::is_none")]
3020    pub chat_id: Option<i64>,
3021    /// Required if inline_message_id is not specified. Identifier of the sent message
3022    #[serde(skip_serializing_if = "Option::is_none")]
3023    pub message_id: Option<i64>,
3024    /// Required if chat_id and message_id are not specified. Identifier of the inline message
3025    #[serde(skip_serializing_if = "Option::is_none")]
3026    pub inline_message_id: Option<String>,
3027}
3028impl SetGameScore {
3029    pub fn new(user_id: i64, score: i64) -> Self {
3030        Self {
3031            user_id,
3032            score,
3033            force: None,
3034            disable_edit_message: None,
3035            chat_id: None,
3036            message_id: None,
3037            inline_message_id: None,
3038        }
3039    }
3040}
3041
3042impl Methods for SetGameScore {
3043    fn endpoint(&self) -> String {
3044        "setGameScore".to_string()
3045    }
3046}
3047
3048/// Use this method to get data for high score tables. Will return the score of the specified user and several of their neighbors in a game. Returns an Array of GameHighScore objects.
3049#[derive(Deserialize, Serialize, Debug, Clone)]
3050pub struct GetGameHighScores {
3051    /// Target user id
3052    pub user_id: i64,
3053    /// Required if inline_message_id is not specified. Unique identifier for the target chat
3054    #[serde(skip_serializing_if = "Option::is_none")]
3055    pub chat_id: Option<i64>,
3056    /// Required if inline_message_id is not specified. Identifier of the sent message
3057    #[serde(skip_serializing_if = "Option::is_none")]
3058    pub message_id: Option<i64>,
3059    /// Required if chat_id and message_id are not specified. Identifier of the inline message
3060    #[serde(skip_serializing_if = "Option::is_none")]
3061    pub inline_message_id: Option<String>,
3062}
3063impl GetGameHighScores {
3064    pub fn new(user_id: i64) -> Self {
3065        Self {
3066            user_id,
3067            chat_id: None,
3068            message_id: None,
3069            inline_message_id: None,
3070        }
3071    }
3072}
3073
3074impl Methods for GetGameHighScores {
3075    fn endpoint(&self) -> String {
3076        "getGameHighScores".to_string()
3077    }
3078}