use std::{
future::{Future, IntoFuture},
pin::Pin,
};
use serde::Serialize;
use crate::{
api::API, entities::misc::chat_id::ChatId, errors::ConogramError, impl_into_future,
request::RequestT,
};
#[derive(Debug, Clone, Serialize)]
pub struct ExportChatInviteLinkParams {
pub chat_id: ChatId,
}
impl_into_future!(ExportChatInviteLinkRequest<'a>);
#[derive(Clone)]
pub struct ExportChatInviteLinkRequest<'a> {
api: &'a API,
params: ExportChatInviteLinkParams,
}
impl<'a> RequestT for ExportChatInviteLinkRequest<'a> {
type ParamsType = ExportChatInviteLinkParams;
type ReturnType = String;
fn get_name() -> &'static str {
"exportChatInviteLink"
}
fn get_api_ref(&self) -> &API {
self.api
}
fn get_params_ref(&self) -> &Self::ParamsType {
&self.params
}
fn is_multipart() -> bool {
false
}
}
impl<'a> ExportChatInviteLinkRequest<'a> {
pub fn new(api: &'a API, chat_id: impl Into<ChatId>) -> Self {
Self {
api,
params: ExportChatInviteLinkParams {
chat_id: chat_id.into(),
},
}
}
#[must_use]
pub fn chat_id(mut self, chat_id: impl Into<ChatId>) -> Self {
self.params.chat_id = chat_id.into();
self
}
}
impl API {
pub fn export_chat_invite_link(
&self,
chat_id: impl Into<ChatId>,
) -> ExportChatInviteLinkRequest {
ExportChatInviteLinkRequest::new(self, chat_id)
}
}