tgbot/types/inline_mode/prepared/
mod.rs1use serde::{Deserialize, Serialize};
2
3use crate::{
4 api::{Method, Payload},
5 types::{InlineQueryResult, Integer},
6};
7
8#[cfg(test)]
9mod tests;
10
11#[derive(Clone, Debug, Deserialize, PartialEq, PartialOrd, Serialize)]
13pub struct PreparedInlineMessage {
14 pub id: String,
16 pub expiration_date: Integer,
19}
20
21impl PreparedInlineMessage {
22 pub fn new<T>(id: T, expiration_date: Integer) -> Self
29 where
30 T: Into<String>,
31 {
32 Self {
33 id: id.into(),
34 expiration_date,
35 }
36 }
37}
38
39#[serde_with::skip_serializing_none]
41#[derive(Clone, Debug, Serialize)]
42pub struct SavePreparedInlineMessage {
43 result: InlineQueryResult,
44 user_id: Integer,
45 allow_bot_chats: Option<bool>,
46 allow_channel_chats: Option<bool>,
47 allow_group_chats: Option<bool>,
48 allow_user_chats: Option<bool>,
49}
50
51impl SavePreparedInlineMessage {
52 pub fn new<T>(user_id: Integer, result: T) -> Self
59 where
60 T: Into<InlineQueryResult>,
61 {
62 Self {
63 user_id,
64 result: result.into(),
65 allow_bot_chats: None,
66 allow_channel_chats: None,
67 allow_group_chats: None,
68 allow_user_chats: None,
69 }
70 }
71
72 pub fn with_allow_bot_chats(mut self, value: bool) -> Self {
78 self.allow_bot_chats = Some(value);
79 self
80 }
81
82 pub fn with_allow_channel_chats(mut self, value: bool) -> Self {
88 self.allow_channel_chats = Some(value);
89 self
90 }
91
92 pub fn with_allow_group_chats(mut self, value: bool) -> Self {
98 self.allow_group_chats = Some(value);
99 self
100 }
101
102 pub fn with_allow_user_chats(mut self, value: bool) -> Self {
108 self.allow_user_chats = Some(value);
109 self
110 }
111}
112
113impl Method for SavePreparedInlineMessage {
114 type Response = PreparedInlineMessage;
115
116 fn into_payload(self) -> Payload {
117 Payload::json("savePreparedInlineMessage", self)
118 }
119}