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
91
use crate::api::API;
use crate::errors::ConogramError;
use crate::impl_into_future;
use crate::request::RequestT;
use serde::Serialize;
use std::future::{Future, IntoFuture};
use std::pin::Pin;

#[derive(Debug, Clone, Serialize)]
pub struct AnswerPreCheckoutQueryParams {
    pub pre_checkout_query_id: String,
    pub ok: bool,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub error_message: Option<String>,
}

impl_into_future!(AnswerPreCheckoutQueryRequest<'a>);

///Once the user has confirmed their payment and shipping details, the Bot API sends the final confirmation in the form of an [Update](https://core.telegram.org/bots/api/#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.
#[derive(Clone)]
pub struct AnswerPreCheckoutQueryRequest<'a> {
    api: &'a API,
    params: AnswerPreCheckoutQueryParams,
}

impl<'a> RequestT for AnswerPreCheckoutQueryRequest<'a> {
    type ParamsType = AnswerPreCheckoutQueryParams;
    type ReturnType = bool;
    fn get_name() -> &'static str {
        "answerPreCheckoutQuery"
    }
    fn get_api_ref(&self) -> &API {
        self.api
    }
    fn get_params_ref(&self) -> &Self::ParamsType {
        &self.params
    }
    fn is_multipart() -> bool {
        false
    }
}
impl<'a> AnswerPreCheckoutQueryRequest<'a> {
    pub fn new(
        api: &'a API,
        pre_checkout_query_id: impl Into<String>,
        ok: impl Into<bool>,
    ) -> Self {
        Self {
            api,
            params: AnswerPreCheckoutQueryParams {
                pre_checkout_query_id: pre_checkout_query_id.into(),
                ok: ok.into(),
                error_message: Option::default(),
            },
        }
    }

    ///Unique identifier for the query to be answered
    #[must_use]
    pub fn pre_checkout_query_id(mut self, pre_checkout_query_id: impl Into<String>) -> Self {
        self.params.pre_checkout_query_id = pre_checkout_query_id.into();
        self
    }

    ///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.
    #[must_use]
    pub fn ok(mut self, ok: impl Into<bool>) -> Self {
        self.params.ok = ok.into();
        self
    }

    ///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.
    #[must_use]
    pub fn error_message(mut self, error_message: impl Into<String>) -> Self {
        self.params.error_message = Some(error_message.into());
        self
    }
}

impl<'a> API {
    ///Once the user has confirmed their payment and shipping details, the Bot API sends the final confirmation in the form of an [Update](https://core.telegram.org/bots/api/#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.
    pub fn answer_pre_checkout_query(
        &'a self,
        pre_checkout_query_id: impl Into<String>,
        ok: impl Into<bool>,
    ) -> AnswerPreCheckoutQueryRequest {
        AnswerPreCheckoutQueryRequest::new(self, pre_checkout_query_id, ok)
    }
}

// Divider: all content below this line will be preserved after code regen