1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
use crate::client::Bot;
use serde::Serialize;
/// 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.
/// Use this if the data submitted by the user doesn't satisfy the standards your service requires for any reason. For example, if a birthday date seems invalid, a submitted document is blurry, a scan shows evidence of tampering, etc. Supply some details in the error message to make sure the user knows how to correct the issues.
/// # Documentation
/// <https://core.telegram.org/bots/api#setpassportdataerrors>
/// # Returns
/// - `bool`
#[derive(Clone, Debug, Serialize)]
pub struct SetPassportDataErrors {
/// User identifier
pub user_id: i64,
/// A JSON-serialized array describing the errors
pub errors: Box<[crate::types::PassportElementError]>,
}
impl SetPassportDataErrors {
/// Creates a new `SetPassportDataErrors`.
///
/// # Arguments
/// * `user_id` - User identifier
/// * `errors` - A JSON-serialized array describing the errors
#[must_use]
pub fn new<
T0: Into<i64>,
T1Item: Into<crate::types::PassportElementError>,
T1: IntoIterator<Item = T1Item>,
>(
user_id: T0,
errors: T1,
) -> Self {
Self {
user_id: user_id.into(),
errors: errors.into_iter().map(Into::into).collect(),
}
}
/// User identifier
#[must_use]
pub fn user_id<T: Into<i64>>(self, val: T) -> Self {
let mut this = self;
this.user_id = val.into();
this
}
/// A JSON-serialized array describing the errors
///
/// # Notes
/// Adds multiple elements.
#[must_use]
pub fn errors<
TItem: Into<crate::types::PassportElementError>,
T: IntoIterator<Item = TItem>,
>(
self,
val: T,
) -> Self {
let mut this = self;
this.errors = this
.errors
.into_vec()
.into_iter()
.chain(val.into_iter().map(Into::into))
.collect();
this
}
/// A JSON-serialized array describing the errors
///
/// # Notes
/// Adds a single element.
#[must_use]
pub fn error<T: Into<crate::types::PassportElementError>>(self, val: T) -> Self {
let mut this = self;
this.errors = this
.errors
.into_vec()
.into_iter()
.chain(Some(val.into()))
.collect();
this
}
}
impl super::TelegramMethod for SetPassportDataErrors {
type Method = Self;
type Return = bool;
fn build_request<Client>(self, _bot: &Bot<Client>) -> super::Request<Self::Method> {
super::Request::new("setPassportDataErrors", self, None)
}
}