1use rustigram_types::file::InputProfilePhoto;
2
3use crate::client::BotClient;
4use crate::error::Result;
5use rustigram_types::payments::StarAmount;
6use rustigram_types::update::BusinessConnection;
7use rustigram_types::user::ChatId;
8use serde::Serialize;
9use std::future::{Future, IntoFuture};
10use std::pin::Pin;
11
12#[derive(Serialize)]
15struct GetBusinessConnectionParams {
16 business_connection_id: String,
17}
18
19pub struct GetBusinessConnection {
21 client: BotClient,
22 params: GetBusinessConnectionParams,
23}
24
25impl GetBusinessConnection {
26 pub(crate) fn new(client: BotClient, id: impl Into<String>) -> Self {
27 Self {
28 client,
29 params: GetBusinessConnectionParams {
30 business_connection_id: id.into(),
31 },
32 }
33 }
34}
35
36impl IntoFuture for GetBusinessConnection {
37 type Output = Result<BusinessConnection>;
38 type IntoFuture = Pin<Box<dyn Future<Output = Self::Output> + Send>>;
39 fn into_future(self) -> Self::IntoFuture {
40 Box::pin(async move {
41 self.client
42 .post_json("getBusinessConnection", &self.params)
43 .await
44 })
45 }
46}
47
48#[derive(Serialize)]
51struct ReadBusinessMessageParams {
52 business_connection_id: String,
53 chat_id: ChatId,
54 message_id: i64,
55}
56
57pub struct ReadBusinessMessage {
59 client: BotClient,
60 params: ReadBusinessMessageParams,
61}
62
63impl ReadBusinessMessage {
64 pub(crate) fn new(
65 client: BotClient,
66 business_connection_id: impl Into<String>,
67 chat_id: impl Into<ChatId>,
68 message_id: i64,
69 ) -> Self {
70 Self {
71 client,
72 params: ReadBusinessMessageParams {
73 business_connection_id: business_connection_id.into(),
74 chat_id: chat_id.into(),
75 message_id,
76 },
77 }
78 }
79}
80
81impl IntoFuture for ReadBusinessMessage {
82 type Output = Result<bool>;
83 type IntoFuture = Pin<Box<dyn Future<Output = Self::Output> + Send>>;
84 fn into_future(self) -> Self::IntoFuture {
85 Box::pin(async move {
86 self.client
87 .post_json("readBusinessMessage", &self.params)
88 .await
89 })
90 }
91}
92
93#[derive(Serialize)]
96struct DeleteBusinessMessagesParams {
97 business_connection_id: String,
98 message_ids: Vec<i64>,
99}
100
101pub struct DeleteBusinessMessages {
103 client: BotClient,
104 params: DeleteBusinessMessagesParams,
105}
106
107impl DeleteBusinessMessages {
108 pub(crate) fn new(
109 client: BotClient,
110 business_connection_id: impl Into<String>,
111 message_ids: Vec<i64>,
112 ) -> Self {
113 Self {
114 client,
115 params: DeleteBusinessMessagesParams {
116 business_connection_id: business_connection_id.into(),
117 message_ids,
118 },
119 }
120 }
121}
122
123impl IntoFuture for DeleteBusinessMessages {
124 type Output = Result<bool>;
125 type IntoFuture = Pin<Box<dyn Future<Output = Self::Output> + Send>>;
126 fn into_future(self) -> Self::IntoFuture {
127 Box::pin(async move {
128 self.client
129 .post_json("deleteBusinessMessages", &self.params)
130 .await
131 })
132 }
133}
134
135#[derive(Serialize)]
138struct SetBusinessAccountNameParams {
139 business_connection_id: String,
140 first_name: String,
141 #[serde(skip_serializing_if = "Option::is_none")]
142 last_name: Option<String>,
143}
144
145pub struct SetBusinessAccountName {
147 client: BotClient,
148 params: SetBusinessAccountNameParams,
149}
150
151impl SetBusinessAccountName {
152 pub(crate) fn new(
153 client: BotClient,
154 business_connection_id: impl Into<String>,
155 first_name: String,
156 last_name: Option<String>,
157 ) -> Self {
158 Self {
159 client,
160 params: SetBusinessAccountNameParams {
161 business_connection_id: business_connection_id.into(),
162 first_name,
163 last_name,
164 },
165 }
166 }
167}
168
169impl IntoFuture for SetBusinessAccountName {
170 type Output = Result<bool>;
171 type IntoFuture = Pin<Box<dyn Future<Output = Self::Output> + Send>>;
172 fn into_future(self) -> Self::IntoFuture {
173 Box::pin(async move {
174 self.client
175 .post_json("setBusinessAccountName", &self.params)
176 .await
177 })
178 }
179}
180
181#[derive(Serialize)]
184struct SetBusinessAccountUsernameParams {
185 business_connection_id: String,
186 #[serde(skip_serializing_if = "Option::is_none")]
187 username: Option<String>,
188}
189
190pub struct SetBusinessAccountUsername {
192 client: BotClient,
193 params: SetBusinessAccountUsernameParams,
194}
195
196impl SetBusinessAccountUsername {
197 pub(crate) fn new(
198 client: BotClient,
199 business_connection_id: impl Into<String>,
200 username: Option<String>,
201 ) -> Self {
202 Self {
203 client,
204 params: SetBusinessAccountUsernameParams {
205 business_connection_id: business_connection_id.into(),
206 username,
207 },
208 }
209 }
210}
211
212impl IntoFuture for SetBusinessAccountUsername {
213 type Output = Result<bool>;
214 type IntoFuture = Pin<Box<dyn Future<Output = Self::Output> + Send>>;
215 fn into_future(self) -> Self::IntoFuture {
216 Box::pin(async move {
217 self.client
218 .post_json("setBusinessAccountUsername", &self.params)
219 .await
220 })
221 }
222}
223
224#[derive(Serialize)]
227struct SetBusinessAccountBioParams {
228 business_connection_id: String,
229 #[serde(skip_serializing_if = "Option::is_none")]
230 bio: Option<String>,
231}
232
233pub struct SetBusinessAccountBio {
235 client: BotClient,
236 params: SetBusinessAccountBioParams,
237}
238
239impl SetBusinessAccountBio {
240 pub(crate) fn new(
241 client: BotClient,
242 business_connection_id: impl Into<String>,
243 bio: Option<String>,
244 ) -> Self {
245 Self {
246 client,
247 params: SetBusinessAccountBioParams {
248 business_connection_id: business_connection_id.into(),
249 bio,
250 },
251 }
252 }
253}
254
255impl IntoFuture for SetBusinessAccountBio {
256 type Output = Result<bool>;
257 type IntoFuture = Pin<Box<dyn Future<Output = Self::Output> + Send>>;
258 fn into_future(self) -> Self::IntoFuture {
259 Box::pin(async move {
260 self.client
261 .post_json("setBusinessAccountBio", &self.params)
262 .await
263 })
264 }
265}
266
267#[derive(Serialize)]
270struct BizConnectionIdParams {
271 business_connection_id: String,
272}
273
274pub struct GetBusinessAccountStarBalance {
276 client: BotClient,
277 params: BizConnectionIdParams,
278}
279
280impl GetBusinessAccountStarBalance {
281 pub(crate) fn new(client: BotClient, id: impl Into<String>) -> Self {
282 Self {
283 client,
284 params: BizConnectionIdParams {
285 business_connection_id: id.into(),
286 },
287 }
288 }
289}
290
291impl IntoFuture for GetBusinessAccountStarBalance {
292 type Output = Result<StarAmount>;
293 type IntoFuture = Pin<Box<dyn Future<Output = Self::Output> + Send>>;
294 fn into_future(self) -> Self::IntoFuture {
295 Box::pin(async move {
296 self.client
297 .post_json("getBusinessAccountStarBalance", &self.params)
298 .await
299 })
300 }
301}
302
303#[derive(Serialize)]
306struct TransferBusinessAccountStarsParams {
307 business_connection_id: String,
308 star_count: u64,
309}
310
311pub struct TransferBusinessAccountStars {
313 client: BotClient,
314 params: TransferBusinessAccountStarsParams,
315}
316
317impl TransferBusinessAccountStars {
318 pub(crate) fn new(
319 client: BotClient,
320 business_connection_id: impl Into<String>,
321 star_count: u64,
322 ) -> Self {
323 Self {
324 client,
325 params: TransferBusinessAccountStarsParams {
326 business_connection_id: business_connection_id.into(),
327 star_count,
328 },
329 }
330 }
331}
332
333impl IntoFuture for TransferBusinessAccountStars {
334 type Output = Result<bool>;
335 type IntoFuture = Pin<Box<dyn Future<Output = Self::Output> + Send>>;
336 fn into_future(self) -> Self::IntoFuture {
337 Box::pin(async move {
338 self.client
339 .post_json("transferBusinessAccountStars", &self.params)
340 .await
341 })
342 }
343}
344
345#[derive(Serialize)]
348struct SetBusinessAccountProfilePhotoParams {
349 business_connection_id: String,
350 photo: InputProfilePhoto,
353 #[serde(skip_serializing_if = "Option::is_none")]
354 is_public: Option<bool>,
355}
356
357pub struct SetBusinessAccountProfilePhoto {
364 client: BotClient,
365 params: SetBusinessAccountProfilePhotoParams,
366}
367
368impl SetBusinessAccountProfilePhoto {
369 pub(crate) fn new(
370 client: BotClient,
371 business_connection_id: impl Into<String>,
372 photo: InputProfilePhoto,
373 ) -> Self {
374 Self {
375 client,
376 params: SetBusinessAccountProfilePhotoParams {
377 business_connection_id: business_connection_id.into(),
378 photo,
379 is_public: None,
380 },
381 }
382 }
383 pub fn is_public(mut self, v: bool) -> Self {
386 self.params.is_public = Some(v);
387 self
388 }
389}
390
391impl IntoFuture for SetBusinessAccountProfilePhoto {
392 type Output = Result<bool>;
393 type IntoFuture = Pin<Box<dyn Future<Output = Self::Output> + Send>>;
394 fn into_future(self) -> Self::IntoFuture {
395 Box::pin(async move {
396 self.client
397 .post_json("setBusinessAccountProfilePhoto", &self.params)
398 .await
399 })
400 }
401}
402
403#[derive(Serialize)]
406struct RemoveBusinessAccountProfilePhotoParams {
407 business_connection_id: String,
408 #[serde(skip_serializing_if = "Option::is_none")]
409 is_public: Option<bool>,
410}
411
412pub struct RemoveBusinessAccountProfilePhoto {
417 client: BotClient,
418 params: RemoveBusinessAccountProfilePhotoParams,
419}
420
421impl RemoveBusinessAccountProfilePhoto {
422 pub(crate) fn new(client: BotClient, business_connection_id: impl Into<String>) -> Self {
423 Self {
424 client,
425 params: RemoveBusinessAccountProfilePhotoParams {
426 business_connection_id: business_connection_id.into(),
427 is_public: None,
428 },
429 }
430 }
431 pub fn is_public(mut self, v: bool) -> Self {
433 self.params.is_public = Some(v);
434 self
435 }
436}
437
438impl IntoFuture for RemoveBusinessAccountProfilePhoto {
439 type Output = Result<bool>;
440 type IntoFuture = Pin<Box<dyn Future<Output = Self::Output> + Send>>;
441 fn into_future(self) -> Self::IntoFuture {
442 Box::pin(async move {
443 self.client
444 .post_json("removeBusinessAccountProfilePhoto", &self.params)
445 .await
446 })
447 }
448}
449
450#[derive(Serialize)]
453struct SetBusinessAccountGiftSettingsParams {
454 business_connection_id: String,
455 show_gift_button: bool,
456 accepted_gift_types: rustigram_types::payments::AcceptedGiftTypes,
457}
458
459pub struct SetBusinessAccountGiftSettings {
464 client: BotClient,
465 params: SetBusinessAccountGiftSettingsParams,
466}
467
468impl SetBusinessAccountGiftSettings {
469 pub(crate) fn new(
470 client: BotClient,
471 business_connection_id: impl Into<String>,
472 show_gift_button: bool,
473 accepted_gift_types: rustigram_types::payments::AcceptedGiftTypes,
474 ) -> Self {
475 Self {
476 client,
477 params: SetBusinessAccountGiftSettingsParams {
478 business_connection_id: business_connection_id.into(),
479 show_gift_button,
480 accepted_gift_types,
481 },
482 }
483 }
484}
485
486impl IntoFuture for SetBusinessAccountGiftSettings {
487 type Output = Result<bool>;
488 type IntoFuture = Pin<Box<dyn Future<Output = Self::Output> + Send>>;
489 fn into_future(self) -> Self::IntoFuture {
490 Box::pin(async move {
491 self.client
492 .post_json("setBusinessAccountGiftSettings", &self.params)
493 .await
494 })
495 }
496}