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