Skip to main content

rustigram_api/methods/
passport.rs

1use rustigram_types::passport::PassportElementError;
2
3use crate::client::BotClient;
4use crate::error::Result;
5use serde::Serialize;
6use std::future::{Future, IntoFuture};
7use std::pin::Pin;
8
9// ─── setPassportDataErrors ────────────────────────────────────────────────────
10
11#[derive(Serialize)]
12struct SetPassportDataErrorsParams {
13    user_id: i64,
14    /// Array of `PassportElementError` objects describing the errors.
15    ///
16    /// Errors describing why the submitted documents are unacceptable.
17    errors: Vec<PassportElementError>,
18}
19
20/// Builder for the [`setPassportDataErrors`](https://core.telegram.org/bots/api#setpassportdataerrors) method.
21///
22/// Informs a user that some Telegram Passport elements they provided contain
23/// errors. The user will not be able to re-submit their Passport to the bot
24/// until the errors are fixed — the contents of the affected field must change.
25///
26pub struct SetPassportDataErrors {
27    client: BotClient,
28    params: SetPassportDataErrorsParams,
29}
30
31impl SetPassportDataErrors {
32    pub(crate) fn new(client: BotClient, user_id: i64, errors: Vec<PassportElementError>) -> Self {
33        Self {
34            client,
35            params: SetPassportDataErrorsParams { user_id, errors },
36        }
37    }
38}
39
40impl IntoFuture for SetPassportDataErrors {
41    type Output = Result<bool>;
42    type IntoFuture = Pin<Box<dyn Future<Output = Self::Output> + Send>>;
43    fn into_future(self) -> Self::IntoFuture {
44        Box::pin(async move {
45            self.client
46                .post_json("setPassportDataErrors", &self.params)
47                .await
48        })
49    }
50}