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;
/// Stores a message that can be sent by a user of a Mini App. Returns a [`crate::types::PreparedInlineMessage`] object.
/// # Documentation
/// <https://core.telegram.org/bots/api#savepreparedinlinemessage>
/// # Returns
/// - `crate::types::PreparedInlineMessage`
#[derive(Clone, Debug, Serialize)]
pub struct SavePreparedInlineMessage {
/// Unique identifier of the target user that can use the prepared message
pub user_id: i64,
/// A JSON-serialized object describing the message to be sent
pub result: crate::types::InlineQueryResult,
/// Pass `true` if the message can be sent to private chats with users
#[serde(skip_serializing_if = "Option::is_none")]
pub allow_user_chats: Option<bool>,
/// Pass `true` if the message can be sent to private chats with bots
#[serde(skip_serializing_if = "Option::is_none")]
pub allow_bot_chats: Option<bool>,
/// Pass `true` if the message can be sent to group and supergroup chats
#[serde(skip_serializing_if = "Option::is_none")]
pub allow_group_chats: Option<bool>,
/// Pass `true` if the message can be sent to channel chats
#[serde(skip_serializing_if = "Option::is_none")]
pub allow_channel_chats: Option<bool>,
}
impl SavePreparedInlineMessage {
/// Creates a new `SavePreparedInlineMessage`.
///
/// # Arguments
/// * `user_id` - Unique identifier of the target user that can use the prepared message
/// * `result` - A JSON-serialized object describing the message to be sent
///
/// # Notes
/// Use builder methods to set optional fields.
#[must_use]
pub fn new<T0: Into<i64>, T1: Into<crate::types::InlineQueryResult>>(
user_id: T0,
result: T1,
) -> Self {
Self {
user_id: user_id.into(),
result: result.into(),
allow_user_chats: None,
allow_bot_chats: None,
allow_group_chats: None,
allow_channel_chats: None,
}
}
/// Unique identifier of the target user that can use the prepared message
#[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 object describing the message to be sent
#[must_use]
pub fn result<T: Into<crate::types::InlineQueryResult>>(self, val: T) -> Self {
let mut this = self;
this.result = val.into();
this
}
/// Pass `true` if the message can be sent to private chats with users
#[must_use]
pub fn allow_user_chats<T: Into<bool>>(self, val: T) -> Self {
let mut this = self;
this.allow_user_chats = Some(val.into());
this
}
/// Pass `true` if the message can be sent to private chats with users
#[must_use]
pub fn allow_user_chats_option<T: Into<bool>>(self, val: Option<T>) -> Self {
let mut this = self;
this.allow_user_chats = val.map(Into::into);
this
}
/// Pass `true` if the message can be sent to private chats with bots
#[must_use]
pub fn allow_bot_chats<T: Into<bool>>(self, val: T) -> Self {
let mut this = self;
this.allow_bot_chats = Some(val.into());
this
}
/// Pass `true` if the message can be sent to private chats with bots
#[must_use]
pub fn allow_bot_chats_option<T: Into<bool>>(self, val: Option<T>) -> Self {
let mut this = self;
this.allow_bot_chats = val.map(Into::into);
this
}
/// Pass `true` if the message can be sent to group and supergroup chats
#[must_use]
pub fn allow_group_chats<T: Into<bool>>(self, val: T) -> Self {
let mut this = self;
this.allow_group_chats = Some(val.into());
this
}
/// Pass `true` if the message can be sent to group and supergroup chats
#[must_use]
pub fn allow_group_chats_option<T: Into<bool>>(self, val: Option<T>) -> Self {
let mut this = self;
this.allow_group_chats = val.map(Into::into);
this
}
/// Pass `true` if the message can be sent to channel chats
#[must_use]
pub fn allow_channel_chats<T: Into<bool>>(self, val: T) -> Self {
let mut this = self;
this.allow_channel_chats = Some(val.into());
this
}
/// Pass `true` if the message can be sent to channel chats
#[must_use]
pub fn allow_channel_chats_option<T: Into<bool>>(self, val: Option<T>) -> Self {
let mut this = self;
this.allow_channel_chats = val.map(Into::into);
this
}
}
impl super::TelegramMethod for SavePreparedInlineMessage {
type Method = Self;
type Return = crate::types::PreparedInlineMessage;
fn build_request<Client>(self, _bot: &Bot<Client>) -> super::Request<Self::Method> {
super::Request::new("savePreparedInlineMessage", self, None)
}
}