conogram/methods/
get_business_connection.rs

1use std::{
2    future::{Future, IntoFuture},
3    pin::Pin,
4};
5
6use serde::Serialize;
7
8use crate::{
9    api::API, entities::business_connection::BusinessConnection, errors::ConogramError,
10    impl_into_future, request::RequestT,
11};
12
13#[derive(Debug, Clone, Serialize)]
14pub struct GetBusinessConnectionParams {
15    pub business_connection_id: String,
16}
17
18impl_into_future!(GetBusinessConnectionRequest<'a>);
19
20///Use this method to get information about the connection of the bot with a business account. Returns a [BusinessConnection](https://core.telegram.org/bots/api/#businessconnection) object on success.
21#[derive(Clone)]
22pub struct GetBusinessConnectionRequest<'a> {
23    api: &'a API,
24    params: GetBusinessConnectionParams,
25}
26
27impl<'a> RequestT for GetBusinessConnectionRequest<'a> {
28    type ParamsType = GetBusinessConnectionParams;
29    type ReturnType = BusinessConnection;
30    fn get_name() -> &'static str {
31        "getBusinessConnection"
32    }
33    fn get_api_ref(&self) -> &API {
34        self.api
35    }
36    fn get_params_ref(&self) -> &Self::ParamsType {
37        &self.params
38    }
39    fn is_multipart() -> bool {
40        false
41    }
42}
43impl<'a> GetBusinessConnectionRequest<'a> {
44    pub fn new(api: &'a API, business_connection_id: impl Into<String>) -> Self {
45        Self {
46            api,
47            params: GetBusinessConnectionParams {
48                business_connection_id: business_connection_id.into(),
49            },
50        }
51    }
52
53    ///Unique identifier of the business connection
54    #[must_use]
55    pub fn business_connection_id(mut self, business_connection_id: impl Into<String>) -> Self {
56        self.params.business_connection_id = business_connection_id.into();
57        self
58    }
59}
60
61impl API {
62    ///Use this method to get information about the connection of the bot with a business account. Returns a [BusinessConnection](https://core.telegram.org/bots/api/#businessconnection) object on success.
63    pub fn get_business_connection(
64        &self,
65        business_connection_id: impl Into<String>,
66    ) -> GetBusinessConnectionRequest {
67        GetBusinessConnectionRequest::new(self, business_connection_id)
68    }
69}
70
71// Divider: all content below this line will be preserved after code regen