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