1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
use super::call_method;
use crate::{
bot::InnerBot,
errors,
types::{parameters::AllowedUpdates, update::RawUpdate},
};
use serde::Serialize;
#[derive(Serialize, Debug, Clone)]
#[must_use]
pub struct GetUpdates<'a> {
#[serde(skip)]
bot: &'a InnerBot,
#[serde(skip_serializing_if = "Option::is_none")]
offset: Option<isize>,
#[serde(skip_serializing_if = "Option::is_none")]
limit: Option<u8>,
#[serde(skip_serializing_if = "Option::is_none")]
timeout: Option<u64>,
#[serde(skip_serializing_if = "Option::is_none")]
allowed_updates: Option<AllowedUpdates>,
}
impl<'a> GetUpdates<'a> {
pub(crate) const fn new(
bot: &'a InnerBot,
offset: Option<isize>,
limit: Option<u8>,
timeout: Option<u64>,
allowed_updates: Option<AllowedUpdates>,
) -> Self {
Self {
bot,
offset,
limit,
timeout,
allowed_updates,
}
}
}
impl GetUpdates<'_> {
pub(crate) async fn call(
self,
) -> Result<Vec<RawUpdate>, errors::MethodCall> {
call_method(
self.bot,
"getUpdates",
None,
serde_json::to_vec(&self).unwrap(),
)
.await
}
}