rustigram_api/methods/
verification.rs1use crate::client::BotClient;
2use crate::error::Result;
3use rustigram_types::user::ChatId;
4use serde::Serialize;
5use std::future::{Future, IntoFuture};
6use std::pin::Pin;
7
8#[derive(Serialize)]
11struct VerifyUserParams {
12 user_id: i64,
13 #[serde(skip_serializing_if = "Option::is_none")]
14 custom_description: Option<String>,
15}
16
17pub struct VerifyUser {
19 client: BotClient,
20 params: VerifyUserParams,
21}
22
23impl VerifyUser {
24 pub(crate) fn new(client: BotClient, user_id: i64) -> Self {
25 Self {
26 client,
27 params: VerifyUserParams {
28 user_id,
29 custom_description: None,
30 },
31 }
32 }
33 pub fn custom_description(mut self, d: impl Into<String>) -> Self {
35 self.params.custom_description = Some(d.into());
36 self
37 }
38}
39
40impl IntoFuture for VerifyUser {
41 type Output = Result<bool>;
42 type IntoFuture = Pin<Box<dyn Future<Output = Self::Output> + Send>>;
43 fn into_future(self) -> Self::IntoFuture {
44 Box::pin(async move { self.client.post_json("verifyUser", &self.params).await })
45 }
46}
47
48#[derive(Serialize)]
51struct VerifyChatParams {
52 chat_id: ChatId,
53 #[serde(skip_serializing_if = "Option::is_none")]
54 custom_description: Option<String>,
55}
56
57pub struct VerifyChat {
59 client: BotClient,
60 params: VerifyChatParams,
61}
62
63impl VerifyChat {
64 pub(crate) fn new(client: BotClient, chat_id: impl Into<ChatId>) -> Self {
65 Self {
66 client,
67 params: VerifyChatParams {
68 chat_id: chat_id.into(),
69 custom_description: None,
70 },
71 }
72 }
73 pub fn custom_description(mut self, d: impl Into<String>) -> Self {
75 self.params.custom_description = Some(d.into());
76 self
77 }
78}
79
80impl IntoFuture for VerifyChat {
81 type Output = Result<bool>;
82 type IntoFuture = Pin<Box<dyn Future<Output = Self::Output> + Send>>;
83 fn into_future(self) -> Self::IntoFuture {
84 Box::pin(async move { self.client.post_json("verifyChat", &self.params).await })
85 }
86}
87
88#[derive(Serialize)]
91struct RemoveUserVerificationParams {
92 user_id: i64,
93}
94
95pub struct RemoveUserVerification {
97 client: BotClient,
98 params: RemoveUserVerificationParams,
99}
100
101impl RemoveUserVerification {
102 pub(crate) fn new(client: BotClient, user_id: i64) -> Self {
103 Self {
104 client,
105 params: RemoveUserVerificationParams { user_id },
106 }
107 }
108}
109
110impl IntoFuture for RemoveUserVerification {
111 type Output = Result<bool>;
112 type IntoFuture = Pin<Box<dyn Future<Output = Self::Output> + Send>>;
113 fn into_future(self) -> Self::IntoFuture {
114 Box::pin(async move {
115 self.client
116 .post_json("removeUserVerification", &self.params)
117 .await
118 })
119 }
120}
121
122#[derive(Serialize)]
125struct RemoveChatVerificationParams {
126 chat_id: ChatId,
127}
128
129pub struct RemoveChatVerification {
131 client: BotClient,
132 params: RemoveChatVerificationParams,
133}
134
135impl RemoveChatVerification {
136 pub(crate) fn new(client: BotClient, chat_id: impl Into<ChatId>) -> Self {
137 Self {
138 client,
139 params: RemoveChatVerificationParams {
140 chat_id: chat_id.into(),
141 },
142 }
143 }
144}
145
146impl IntoFuture for RemoveChatVerification {
147 type Output = Result<bool>;
148 type IntoFuture = Pin<Box<dyn Future<Output = Self::Output> + Send>>;
149 fn into_future(self) -> Self::IntoFuture {
150 Box::pin(async move {
151 self.client
152 .post_json("removeChatVerification", &self.params)
153 .await
154 })
155 }
156}