Add BusinessIntro class and corres. field to ChatPrivate

This commit is contained in:
Akshett Rai Jindal 2024-08-21 01:02:32 +05:30
parent 1a5eca0a75
commit fa17b48793
5 changed files with 35 additions and 4 deletions

View file

@ -9,6 +9,7 @@ pub use bot_command_scope::*;
pub use bot_description::*;
pub use bot_name::*;
pub use bot_short_description::*;
pub use business_intro::*;
pub use callback_game::*;
pub use callback_query::*;
pub use chat::*;
@ -164,6 +165,7 @@ mod bot_command_scope;
mod bot_description;
mod bot_name;
mod bot_short_description;
mod business_intro;
mod callback_game;
mod callback_query;
mod chat;

View file

@ -0,0 +1,15 @@
use serde::{Deserialize, Serialize};
use crate::types::Sticker;
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct BusinessIntro {
/// Title text of the business intro
pub title: Option<String>,
/// Message text of the business intro
pub message: Option<String>,
/// Sticker of the business intro
pub sticker: Option<Sticker>,
}

View file

@ -1,8 +1,8 @@
use serde::{Deserialize, Serialize};
use crate::types::{
ChatFullInfo, ChatId, ChatLocation, ChatPermissions, ChatPhoto, Message, ReactionType, Seconds,
True, User,
BusinessIntro, ChatFullInfo, ChatId, ChatLocation, ChatPermissions, ChatPhoto, Message,
ReactionType, Seconds, True, User,
};
use super::Birthdate;
@ -147,6 +147,12 @@ pub struct ChatPrivate {
///
/// [`GetChat`]: crate::payloads::GetChat
pub birthdate: Option<Birthdate>,
/// For private chats with business accounts, the intro of the business.
/// Returned only in [`GetChat`].
///
/// [`GetChat`]: crate::payloads::GetChat
pub business_intro: Option<BusinessIntro>,
}
#[serde_with::skip_serializing_none]
@ -577,8 +583,7 @@ impl Chat {
}
mod serde_helper {
use super::Birthdate;
use crate::types::True;
use crate::types::{Birthdate, BusinessIntro, True};
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize)]
@ -601,6 +606,7 @@ mod serde_helper {
has_restricted_voice_and_video_messages: Option<True>,
personal_chat: Option<Box<super::Chat>>,
birthdate: Option<Birthdate>,
business_intro: Option<BusinessIntro>,
}
impl From<ChatPrivate> for super::ChatPrivate {
@ -615,6 +621,7 @@ mod serde_helper {
has_restricted_voice_and_video_messages,
personal_chat,
birthdate,
business_intro,
}: ChatPrivate,
) -> Self {
Self {
@ -626,6 +633,7 @@ mod serde_helper {
has_restricted_voice_and_video_messages,
personal_chat,
birthdate,
business_intro,
}
}
}
@ -641,6 +649,7 @@ mod serde_helper {
has_restricted_voice_and_video_messages,
personal_chat,
birthdate,
business_intro,
}: super::ChatPrivate,
) -> Self {
Self {
@ -653,6 +662,7 @@ mod serde_helper {
has_restricted_voice_and_video_messages,
personal_chat,
birthdate,
business_intro,
}
}
}
@ -717,6 +727,7 @@ mod tests {
has_restricted_voice_and_video_messages: None,
personal_chat: None,
birthdate: None,
business_intro: None,
}),
photo: None,
available_reactions: Some(vec![ReactionType::Emoji { emoji: "🌭".to_owned() }]),
@ -757,6 +768,7 @@ mod tests {
has_restricted_voice_and_video_messages: None,
personal_chat: None,
birthdate: None,
business_intro: None,
}),
photo: None,
available_reactions: None,

View file

@ -1904,6 +1904,7 @@ mod tests {
has_restricted_voice_and_video_messages: None,
personal_chat: None,
birthdate: None,
business_intro: None,
}),
photo: None,
available_reactions: None,

View file

@ -537,6 +537,7 @@ mod test {
has_restricted_voice_and_video_messages: None,
personal_chat: None,
birthdate: None,
business_intro: None,
}),
photo: None,
available_reactions: None,