apid_telegram_bot/calls/update/
get_updates.rs

1use apid::Call;
2use serde::{Deserialize, Serialize};
3
4use crate::types::{Update, UpdateKind};
5
6/// Use this method to receive incoming updates using long polling ([wiki](https://en.wikipedia.org/wiki/Push_technology#Long_polling)).
7/// Returns an Array of [`Update`] objects.
8#[derive(Debug, PartialEq, Serialize, Deserialize)]
9pub struct GetUpdates {
10    /// Identifier of the first update to be returned.
11    /// Must be greater by one than the highest among the identifiers of previously received updates.
12    /// By default, updates starting with the earliest unconfirmed update are returned.
13    /// An update is considered confirmed as soon as [getUpdates](https://core.telegram.org/bots/api#getupdates) is called with an *offset* higher than its *update_id*.
14    /// The negative offset can be specified to retrieve updates starting from -*offset* update from the end of the updates queue.
15    /// All previous updates will forgotten.
16    #[serde(skip_serializing_if = "Option::is_none")]
17    pub offset: Option<i32>,
18
19    /// Limits the number of updates to be retrieved.
20    /// Values between 1-100 are accepted.
21    /// Defaults to 100.
22    #[serde(skip_serializing_if = "Option::is_none")]
23    pub limit: Option<i32>,
24
25    /// Timeout in seconds for long polling.
26    /// Defaults to 0, i.e. usual short polling.
27    /// Should be positive, short polling should be used for testing purposes only.
28    #[serde(skip_serializing_if = "Option::is_none")]
29    pub timeout: Option<i32>,
30
31    /// A JSON-serialized list of the update types you want your bot to receive.
32    /// For example, specify [“message”, “edited_channel_post”, “callback_query”] to only receive updates of these types.
33    /// See [`UpdateKind`] for a complete list of available update types.
34    /// Specify an empty list to receive all update types except *chat_member* (default).
35    /// If not specified, the previous setting will be used.
36    ///
37    /// Please note that this parameter doesn't affect updates created before the call to the getUpdates, so unwanted updates may be received for a short period of time.
38    #[serde(skip_serializing_if = "Option::is_none")]
39    pub allowed_updates: Option<Vec<UpdateKind>>,
40}
41
42impl Call for GetUpdates {
43    type Response = Vec<Update>;
44}