use crate::errors::Result;
use crate::types::*;
use uuid::Uuid;
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct SupergroupFullInfo {
#[doc(hidden)]
#[serde(rename(serialize = "@extra", deserialize = "@extra"))]
extra: Option<String>,
#[serde(rename(serialize = "@client_id", deserialize = "@client_id"))]
client_id: Option<i32>,
photo: Option<ChatPhoto>,
#[serde(default)]
description: String,
#[serde(default)]
member_count: i32,
#[serde(default)]
administrator_count: i32,
#[serde(default)]
restricted_count: i32,
#[serde(default)]
banned_count: i32,
#[serde(default)]
linked_chat_id: i64,
#[serde(default)]
slow_mode_delay: i32,
#[serde(default)]
slow_mode_delay_expires_in: f32,
#[serde(default)]
can_get_members: bool,
#[serde(default)]
can_set_username: bool,
#[serde(default)]
can_set_sticker_set: bool,
#[serde(default)]
can_set_location: bool,
#[serde(default)]
can_get_statistics: bool,
#[serde(default)]
is_all_history_available: bool,
#[serde(
deserialize_with = "super::_common::number_from_string",
serialize_with = "super::_common::string_to_number"
)]
#[serde(default)]
sticker_set_id: i64,
location: Option<ChatLocation>,
invite_link: Option<ChatInviteLink>,
#[serde(default)]
bot_commands: Vec<BotCommands>,
#[serde(default)]
upgraded_from_basic_group_id: i64,
#[serde(default)]
upgraded_from_max_message_id: i64,
}
impl RObject for SupergroupFullInfo {
#[doc(hidden)]
fn extra(&self) -> Option<&str> {
self.extra.as_deref()
}
#[doc(hidden)]
fn client_id(&self) -> Option<i32> {
self.client_id
}
}
impl SupergroupFullInfo {
pub fn from_json<S: AsRef<str>>(json: S) -> Result<Self> {
Ok(serde_json::from_str(json.as_ref())?)
}
pub fn builder() -> SupergroupFullInfoBuilder {
let mut inner = SupergroupFullInfo::default();
inner.extra = Some(Uuid::new_v4().to_string());
SupergroupFullInfoBuilder { inner }
}
pub fn photo(&self) -> &Option<ChatPhoto> {
&self.photo
}
pub fn description(&self) -> &String {
&self.description
}
pub fn member_count(&self) -> i32 {
self.member_count
}
pub fn administrator_count(&self) -> i32 {
self.administrator_count
}
pub fn restricted_count(&self) -> i32 {
self.restricted_count
}
pub fn banned_count(&self) -> i32 {
self.banned_count
}
pub fn linked_chat_id(&self) -> i64 {
self.linked_chat_id
}
pub fn slow_mode_delay(&self) -> i32 {
self.slow_mode_delay
}
pub fn slow_mode_delay_expires_in(&self) -> f32 {
self.slow_mode_delay_expires_in
}
pub fn can_get_members(&self) -> bool {
self.can_get_members
}
pub fn can_set_username(&self) -> bool {
self.can_set_username
}
pub fn can_set_sticker_set(&self) -> bool {
self.can_set_sticker_set
}
pub fn can_set_location(&self) -> bool {
self.can_set_location
}
pub fn can_get_statistics(&self) -> bool {
self.can_get_statistics
}
pub fn is_all_history_available(&self) -> bool {
self.is_all_history_available
}
pub fn sticker_set_id(&self) -> i64 {
self.sticker_set_id
}
pub fn location(&self) -> &Option<ChatLocation> {
&self.location
}
pub fn invite_link(&self) -> &Option<ChatInviteLink> {
&self.invite_link
}
pub fn bot_commands(&self) -> &Vec<BotCommands> {
&self.bot_commands
}
pub fn upgraded_from_basic_group_id(&self) -> i64 {
self.upgraded_from_basic_group_id
}
pub fn upgraded_from_max_message_id(&self) -> i64 {
self.upgraded_from_max_message_id
}
}
#[doc(hidden)]
pub struct SupergroupFullInfoBuilder {
inner: SupergroupFullInfo,
}
#[deprecated]
pub type RTDSupergroupFullInfoBuilder = SupergroupFullInfoBuilder;
impl SupergroupFullInfoBuilder {
pub fn build(&self) -> SupergroupFullInfo {
self.inner.clone()
}
pub fn photo<T: AsRef<ChatPhoto>>(&mut self, photo: T) -> &mut Self {
self.inner.photo = Some(photo.as_ref().clone());
self
}
pub fn description<T: AsRef<str>>(&mut self, description: T) -> &mut Self {
self.inner.description = description.as_ref().to_string();
self
}
pub fn member_count(&mut self, member_count: i32) -> &mut Self {
self.inner.member_count = member_count;
self
}
pub fn administrator_count(&mut self, administrator_count: i32) -> &mut Self {
self.inner.administrator_count = administrator_count;
self
}
pub fn restricted_count(&mut self, restricted_count: i32) -> &mut Self {
self.inner.restricted_count = restricted_count;
self
}
pub fn banned_count(&mut self, banned_count: i32) -> &mut Self {
self.inner.banned_count = banned_count;
self
}
pub fn linked_chat_id(&mut self, linked_chat_id: i64) -> &mut Self {
self.inner.linked_chat_id = linked_chat_id;
self
}
pub fn slow_mode_delay(&mut self, slow_mode_delay: i32) -> &mut Self {
self.inner.slow_mode_delay = slow_mode_delay;
self
}
pub fn slow_mode_delay_expires_in(&mut self, slow_mode_delay_expires_in: f32) -> &mut Self {
self.inner.slow_mode_delay_expires_in = slow_mode_delay_expires_in;
self
}
pub fn can_get_members(&mut self, can_get_members: bool) -> &mut Self {
self.inner.can_get_members = can_get_members;
self
}
pub fn can_set_username(&mut self, can_set_username: bool) -> &mut Self {
self.inner.can_set_username = can_set_username;
self
}
pub fn can_set_sticker_set(&mut self, can_set_sticker_set: bool) -> &mut Self {
self.inner.can_set_sticker_set = can_set_sticker_set;
self
}
pub fn can_set_location(&mut self, can_set_location: bool) -> &mut Self {
self.inner.can_set_location = can_set_location;
self
}
pub fn can_get_statistics(&mut self, can_get_statistics: bool) -> &mut Self {
self.inner.can_get_statistics = can_get_statistics;
self
}
pub fn is_all_history_available(&mut self, is_all_history_available: bool) -> &mut Self {
self.inner.is_all_history_available = is_all_history_available;
self
}
pub fn sticker_set_id(&mut self, sticker_set_id: i64) -> &mut Self {
self.inner.sticker_set_id = sticker_set_id;
self
}
pub fn location<T: AsRef<ChatLocation>>(&mut self, location: T) -> &mut Self {
self.inner.location = Some(location.as_ref().clone());
self
}
pub fn invite_link<T: AsRef<ChatInviteLink>>(&mut self, invite_link: T) -> &mut Self {
self.inner.invite_link = Some(invite_link.as_ref().clone());
self
}
pub fn bot_commands(&mut self, bot_commands: Vec<BotCommands>) -> &mut Self {
self.inner.bot_commands = bot_commands;
self
}
pub fn upgraded_from_basic_group_id(&mut self, upgraded_from_basic_group_id: i64) -> &mut Self {
self.inner.upgraded_from_basic_group_id = upgraded_from_basic_group_id;
self
}
pub fn upgraded_from_max_message_id(&mut self, upgraded_from_max_message_id: i64) -> &mut Self {
self.inner.upgraded_from_max_message_id = upgraded_from_max_message_id;
self
}
}
impl AsRef<SupergroupFullInfo> for SupergroupFullInfo {
fn as_ref(&self) -> &SupergroupFullInfo {
self
}
}
impl AsRef<SupergroupFullInfo> for SupergroupFullInfoBuilder {
fn as_ref(&self) -> &SupergroupFullInfo {
&self.inner
}
}