use serde::Serialize;
use crate::{
api::{Method, Payload, PayloadError},
types::{ChatId, Integer},
};
#[serde_with::skip_serializing_none]
#[derive(Clone, Debug, Serialize)]
pub struct PinChatMessage {
chat_id: ChatId,
message_id: Integer,
business_connection_id: Option<String>,
disable_notification: Option<bool>,
}
impl PinChatMessage {
pub fn new<T>(chat_id: T, message_id: Integer) -> Self
where
T: Into<ChatId>,
{
PinChatMessage {
chat_id: chat_id.into(),
message_id,
business_connection_id: None,
disable_notification: None,
}
}
pub fn with_business_connection_id<T>(mut self, value: T) -> Self
where
T: Into<String>,
{
self.business_connection_id = Some(value.into());
self
}
pub fn with_disable_notification(mut self, value: bool) -> Self {
self.disable_notification = Some(value);
self
}
}
impl Method for PinChatMessage {
type Response = bool;
fn into_payload(self) -> Result<Payload, PayloadError> {
Payload::json("pinChatMessage", self)
}
}
#[serde_with::skip_serializing_none]
#[derive(Clone, Debug, Serialize)]
pub struct UnpinChatMessage {
chat_id: ChatId,
business_connection_id: Option<String>,
message_id: Option<Integer>,
}
impl UnpinChatMessage {
pub fn new<T>(chat_id: T) -> Self
where
T: Into<ChatId>,
{
UnpinChatMessage {
chat_id: chat_id.into(),
business_connection_id: None,
message_id: None,
}
}
pub fn with_business_connection_id<T>(mut self, value: T) -> Self
where
T: Into<String>,
{
self.business_connection_id = Some(value.into());
self
}
pub fn with_message_id(mut self, value: Integer) -> Self {
self.message_id = Some(value);
self
}
}
impl Method for UnpinChatMessage {
type Response = bool;
fn into_payload(self) -> Result<Payload, PayloadError> {
Payload::json("unpinChatMessage", self)
}
}
#[derive(Clone, Debug, Serialize)]
pub struct UnpinAllChatMessages {
chat_id: ChatId,
}
impl UnpinAllChatMessages {
pub fn new<T>(chat_id: T) -> Self
where
T: Into<ChatId>,
{
UnpinAllChatMessages {
chat_id: chat_id.into(),
}
}
}
impl Method for UnpinAllChatMessages {
type Response = bool;
fn into_payload(self) -> Result<Payload, PayloadError> {
Payload::json("unpinAllChatMessages", self)
}
}