use super::{InlineKeyboardMarkup, InputMessageContent, MessageEntity};
use serde::{Deserialize, Serialize};
use serde_with::skip_serializing_none;
#[skip_serializing_none]
#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)]
pub struct InlineQueryResultDocument {
pub id: String,
pub title: String,
pub document_url: String,
pub mime_type: String,
pub caption: Option<String>,
pub parse_mode: Option<String>,
pub caption_entities: Option<Vec<MessageEntity>>,
pub description: Option<String>,
pub reply_markup: Option<InlineKeyboardMarkup>,
pub input_message_content: Option<InputMessageContent>,
pub thumbnail_url: Option<String>,
pub thumbnail_width: Option<i64>,
pub thumbnail_height: Option<i64>,
}
impl InlineQueryResultDocument {
#[must_use]
pub fn new(
id: impl Into<String>,
title: impl Into<String>,
document_url: impl Into<String>,
mime_type: impl Into<String>,
) -> InlineQueryResultDocument {
Self {
id: id.into(),
title: title.into(),
document_url: document_url.into(),
mime_type: mime_type.into(),
caption: None,
parse_mode: None,
caption_entities: None,
description: None,
reply_markup: None,
input_message_content: None,
thumbnail_url: None,
thumbnail_width: None,
thumbnail_height: None,
}
}
#[must_use]
pub fn id(self, val: impl Into<String>) -> Self {
Self {
id: val.into(),
..self
}
}
#[must_use]
pub fn title(self, val: impl Into<String>) -> Self {
Self {
title: val.into(),
..self
}
}
#[must_use]
pub fn document_url(self, val: impl Into<String>) -> Self {
Self {
document_url: val.into(),
..self
}
}
#[must_use]
pub fn mime_type(self, val: impl Into<String>) -> Self {
Self {
mime_type: val.into(),
..self
}
}
#[must_use]
pub fn caption(self, val: impl Into<String>) -> Self {
Self {
caption: Some(val.into()),
..self
}
}
#[must_use]
pub fn parse_mode(self, val: impl Into<String>) -> Self {
Self {
parse_mode: Some(val.into()),
..self
}
}
#[must_use]
pub fn caption_entity(self, val: MessageEntity) -> Self {
Self {
caption_entities: Some(
self.caption_entities
.unwrap_or_default()
.into_iter()
.chain(Some(val))
.collect(),
),
..self
}
}
#[must_use]
pub fn caption_entities(self, val: impl IntoIterator<Item = MessageEntity>) -> Self {
Self {
caption_entities: Some(
self.caption_entities
.unwrap_or_default()
.into_iter()
.chain(val)
.collect(),
),
..self
}
}
#[must_use]
pub fn description(self, val: impl Into<String>) -> Self {
Self {
description: Some(val.into()),
..self
}
}
#[must_use]
pub fn reply_markup(self, val: impl Into<InlineKeyboardMarkup>) -> Self {
Self {
reply_markup: Some(val.into()),
..self
}
}
#[must_use]
pub fn input_message_content(self, val: impl Into<InputMessageContent>) -> Self {
Self {
input_message_content: Some(val.into()),
..self
}
}
#[must_use]
pub fn thumbnail_url(self, val: impl Into<String>) -> Self {
Self {
thumbnail_url: Some(val.into()),
..self
}
}
#[must_use]
pub fn thumbnail_width(self, val: i64) -> Self {
Self {
thumbnail_width: Some(val),
..self
}
}
#[must_use]
pub fn thumbnail_height(self, val: i64) -> Self {
Self {
thumbnail_height: Some(val),
..self
}
}
}
impl InlineQueryResultDocument {
#[must_use]
pub fn caption_option(self, val: Option<impl Into<String>>) -> Self {
Self {
caption: val.map(Into::into),
..self
}
}
#[must_use]
pub fn parse_mode_option(self, val: Option<impl Into<String>>) -> Self {
Self {
parse_mode: val.map(Into::into),
..self
}
}
#[must_use]
pub fn caption_entities_option(
self,
val: Option<impl IntoIterator<Item = MessageEntity>>,
) -> Self {
Self {
caption_entities: val.map(|val| {
self.caption_entities
.unwrap_or_default()
.into_iter()
.chain(val)
.collect()
}),
..self
}
}
#[must_use]
pub fn description_option(self, val: Option<impl Into<String>>) -> Self {
Self {
description: val.map(Into::into),
..self
}
}
#[must_use]
pub fn reply_markup_option(self, val: Option<impl Into<InlineKeyboardMarkup>>) -> Self {
Self {
reply_markup: val.map(Into::into),
..self
}
}
#[must_use]
pub fn thumbnail_url_option(self, val: Option<impl Into<String>>) -> Self {
Self {
thumbnail_url: val.map(Into::into),
..self
}
}
#[must_use]
pub fn thumbnail_width_option(self, val: Option<i64>) -> Self {
Self {
thumbnail_width: val,
..self
}
}
#[must_use]
pub fn thumbnail_height_option(self, val: Option<i64>) -> Self {
Self {
thumbnail_height: val,
..self
}
}
}