rustigram_api/methods/
miniapp.rs1use rustigram_types::keyboard::PreparedKeyboardButton;
2
3use crate::client::BotClient;
4use crate::error::Result;
5use rustigram_types::keyboard::KeyboardButton;
6use serde::Serialize;
7use std::future::{Future, IntoFuture};
8use std::pin::Pin;
9
10macro_rules! impl_into_future {
13 ($builder:ident, $return_ty:ty, $method:literal) => {
14 impl IntoFuture for $builder {
15 type Output = Result<$return_ty>;
16 type IntoFuture = Pin<Box<dyn Future<Output = Self::Output> + Send>>;
17 fn into_future(self) -> Self::IntoFuture {
18 Box::pin(async move { self.client.post_json($method, &self.params).await })
19 }
20 }
21 };
22}
23
24#[derive(Serialize)]
27struct SavePreparedKeyboardButtonParams {
28 user_id: i64,
29 button: KeyboardButton,
30}
31
32pub struct SavePreparedKeyboardButton {
39 client: BotClient,
40 params: SavePreparedKeyboardButtonParams,
41}
42
43impl SavePreparedKeyboardButton {
44 pub(crate) fn new(client: BotClient, user_id: i64, button: KeyboardButton) -> Self {
45 Self {
46 client,
47 params: SavePreparedKeyboardButtonParams { user_id, button },
48 }
49 }
50}
51impl_into_future!(
52 SavePreparedKeyboardButton,
53 PreparedKeyboardButton,
54 "savePreparedKeyboardButton"
55);
56
57#[derive(Serialize)]
60struct SetUserEmojiStatusParams {
61 user_id: i64,
62 #[serde(skip_serializing_if = "Option::is_none")]
63 emoji_status_custom_emoji_id: Option<String>,
64 #[serde(skip_serializing_if = "Option::is_none")]
65 emoji_status_expiration_date: Option<i64>,
66}
67
68pub struct SetUserEmojiStatus {
75 client: BotClient,
76 params: SetUserEmojiStatusParams,
77}
78
79impl SetUserEmojiStatus {
80 pub(crate) fn new(client: BotClient, user_id: i64) -> Self {
81 Self {
82 client,
83 params: SetUserEmojiStatusParams {
84 user_id,
85 emoji_status_custom_emoji_id: None,
86 emoji_status_expiration_date: None,
87 },
88 }
89 }
90 pub fn emoji_status_custom_emoji_id(mut self, id: impl Into<String>) -> Self {
93 self.params.emoji_status_custom_emoji_id = Some(id.into());
94 self
95 }
96 pub fn emoji_status_expiration_date(mut self, ts: i64) -> Self {
98 self.params.emoji_status_expiration_date = Some(ts);
99 self
100 }
101}
102
103impl_into_future!(SetUserEmojiStatus, bool, "setUserEmojiStatus");