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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
use crate::client::Bot;
use serde::Serialize;
/// If you sent an invoice requesting a shipping address and the parameter `is_flexible` was specified, the Bot API will send an Update with a `shipping_query` field to the bot. Use this method to reply to shipping queries. On success, `true` is returned.
/// # Documentation
/// <https://core.telegram.org/bots/api#answershippingquery>
/// # Returns
/// - `bool`
#[derive(Clone, Debug, Serialize)]
pub struct AnswerShippingQuery {
/// Unique identifier for the query to be answered
pub shipping_query_id: Box<str>,
/// Pass `true` if delivery to the specified address is possible and `false` if there are any problems (for example, if delivery to the specified address is not possible)
pub ok: bool,
/// Required if ok is `true`. A JSON-serialized array of available shipping options.
#[serde(skip_serializing_if = "Option::is_none")]
pub shipping_options: Option<Box<[crate::types::ShippingOption]>>,
/// Required if ok is `false`. Error message in human readable form that explains why it is impossible to complete the order (e.g. `Sorry, delivery to your desired address is unavailable`). Telegram will display this message to the user.
#[serde(skip_serializing_if = "Option::is_none")]
pub error_message: Option<Box<str>>,
}
impl AnswerShippingQuery {
/// Creates a new `AnswerShippingQuery`.
///
/// # Arguments
/// * `shipping_query_id` - Unique identifier for the query to be answered
/// * `ok` - Pass `true` if delivery to the specified address is possible and `false` if there are any problems (for example, if delivery to the specified address is not possible)
///
/// # Notes
/// Use builder methods to set optional fields.
#[must_use]
pub fn new<T0: Into<Box<str>>, T1: Into<bool>>(shipping_query_id: T0, ok: T1) -> Self {
Self {
shipping_query_id: shipping_query_id.into(),
ok: ok.into(),
shipping_options: None,
error_message: None,
}
}
/// Unique identifier for the query to be answered
#[must_use]
pub fn shipping_query_id<T: Into<Box<str>>>(self, val: T) -> Self {
let mut this = self;
this.shipping_query_id = val.into();
this
}
/// Pass `true` if delivery to the specified address is possible and `false` if there are any problems (for example, if delivery to the specified address is not possible)
#[must_use]
pub fn ok<T: Into<bool>>(self, val: T) -> Self {
let mut this = self;
this.ok = val.into();
this
}
/// Required if ok is `true`. A JSON-serialized array of available shipping options.
///
/// # Notes
/// Adds multiple elements.
#[must_use]
pub fn shipping_options<
TItem: Into<crate::types::ShippingOption>,
T: IntoIterator<Item = TItem>,
>(
self,
val: T,
) -> Self {
let mut this = self;
this.shipping_options = Some(
this.shipping_options
.unwrap_or_default()
.into_vec()
.into_iter()
.chain(val.into_iter().map(Into::into))
.collect(),
);
this
}
/// Required if ok is `true`. A JSON-serialized array of available shipping options.
///
/// # Notes
/// Adds a single element.
#[must_use]
pub fn shipping_option<T: Into<crate::types::ShippingOption>>(self, val: T) -> Self {
let mut this = self;
this.shipping_options = Some(
this.shipping_options
.unwrap_or_default()
.into_vec()
.into_iter()
.chain(Some(val.into()))
.collect(),
);
this
}
/// Required if ok is `true`. A JSON-serialized array of available shipping options.
///
/// # Notes
/// Adds multiple elements.
#[must_use]
pub fn shipping_options_option<
TItem: Into<crate::types::ShippingOption>,
T: IntoIterator<Item = TItem>,
>(
self,
val: Option<T>,
) -> Self {
let mut this = self;
this.shipping_options = val.map(|v| v.into_iter().map(Into::into).collect());
this
}
/// Required if ok is `false`. Error message in human readable form that explains why it is impossible to complete the order (e.g. `Sorry, delivery to your desired address is unavailable`). Telegram will display this message to the user.
#[must_use]
pub fn error_message<T: Into<Box<str>>>(self, val: T) -> Self {
let mut this = self;
this.error_message = Some(val.into());
this
}
/// Required if ok is `false`. Error message in human readable form that explains why it is impossible to complete the order (e.g. `Sorry, delivery to your desired address is unavailable`). Telegram will display this message to the user.
#[must_use]
pub fn error_message_option<T: Into<Box<str>>>(self, val: Option<T>) -> Self {
let mut this = self;
this.error_message = val.map(Into::into);
this
}
}
impl super::TelegramMethod for AnswerShippingQuery {
type Method = Self;
type Return = bool;
fn build_request<Client>(self, _bot: &Bot<Client>) -> super::Request<Self::Method> {
super::Request::new("answerShippingQuery", self, None)
}
}