use super::call_method;
use crate::{
connectors::Client,
errors, token,
types::parameters::{ChatId, ImplicitChatId},
};
use serde::Serialize;
#[derive(Serialize, Debug, Clone)]
#[must_use = "methods do nothing unless turned into a future"]
pub struct UnpinChatMessage<'a> {
#[serde(skip)]
client: &'a Client,
#[serde(skip)]
token: token::Ref<'a>,
chat_id: ChatId<'a>,
}
impl<'a> UnpinChatMessage<'a> {
pub(crate) fn new(
client: &'a Client,
token: token::Ref<'a>,
chat_id: impl ImplicitChatId<'a>,
) -> Self {
Self {
client,
token,
chat_id: chat_id.into(),
}
}
}
impl UnpinChatMessage<'_> {
pub async fn call(self) -> Result<(), errors::MethodCall> {
call_method::<bool>(
self.client,
self.token,
"unpinChatMessage",
None,
serde_json::to_vec(&self).unwrap(),
)
.await?;
Ok(())
}
}