add method

This commit is contained in:
P0lunin 2019-10-01 17:42:10 +03:00
parent 142d65186f
commit e75d40425b
2 changed files with 57 additions and 0 deletions

View file

@ -22,6 +22,7 @@ pub use self::{
send_video_note::SendVideoNote, send_voice::SendVoice,
stop_message_live_location::StopMessageLiveLocation,
unban_chat_member::UnbanChatMember,
unpin_chat_message::UnpinChatMessage,
};
mod form_builder;
@ -111,3 +112,4 @@ mod send_video_note;
mod send_voice;
mod stop_message_live_location;
mod unban_chat_member;
mod unpin_chat_message;

View file

@ -0,0 +1,55 @@
use async_trait::async_trait;
use crate::{
network,
requests::{Request, RequestContext, ResponseResult, ChatId},
types::True
};
#[derive(Debug, Clone, Serialize)]
pub struct UnpinChatMessage<'a> {
#[serde(skip_serializing)]
pub ctx: RequestContext<'a>,
pub chat_id: ChatId
}
#[async_trait]
impl Request for UnpinChatMessage<'_> {
type ReturnValue = True;
async fn send_boxed(self) -> ResponseResult<Self::ReturnValue> {
self.send().await
}
}
impl UnpinChatMessage<'_> {
pub async fn send(self) -> ResponseResult<True> {
network::request_json(
&self.ctx.client,
&self.ctx.token,
"unpinChatMessage",
&self
).await
}
}
impl<'a> UnpinChatMessage<'a> {
pub(crate) fn new(
ctx: RequestContext<'a>,
chat_id: ChatId,
) -> Self {
Self {
ctx,
chat_id
}
}
pub fn chat_id<T>(mut self, chat_id: T) -> Self
where
T: Into<ChatId>
{
self.chat_id = chat_id.into();
self
}
}