use crate::errors::*;
use crate::types::*;
use uuid::Uuid;
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct Story {
#[doc(hidden)]
#[serde(rename(serialize = "@type", deserialize = "@type"))]
td_name: String,
#[doc(hidden)]
#[serde(rename(serialize = "@extra", deserialize = "@extra"))]
extra: Option<String>,
id: i64,
poster_chat_id: i64,
poster_id: Option<MessageSender>,
date: i64,
is_being_posted: bool,
is_being_edited: bool,
is_edited: bool,
is_posted_to_chat_page: bool,
is_visible_only_for_self: bool,
can_be_added_to_album: bool,
can_be_deleted: bool,
can_be_edited: bool,
can_be_forwarded: bool,
can_be_replied: bool,
can_set_privacy_settings: bool,
can_toggle_is_posted_to_chat_page: bool,
can_get_statistics: bool,
can_get_interactions: bool,
has_expired_viewers: bool,
repost_info: Option<StoryRepostInfo>,
interaction_info: Option<StoryInteractionInfo>,
chosen_reaction_type: Option<ReactionType>,
privacy_settings: StoryPrivacySettings,
content: StoryContent,
areas: Vec<StoryArea>,
caption: FormattedText,
album_ids: Vec<i64>,
}
impl RObject for Story {
#[doc(hidden)]
fn td_name(&self) -> &'static str {
"story"
}
#[doc(hidden)]
fn extra(&self) -> Option<String> {
self.extra.clone()
}
fn to_json(&self) -> RTDResult<String> {
Ok(serde_json::to_string(self)?)
}
}
impl Story {
pub fn from_json<S: AsRef<str>>(json: S) -> RTDResult<Self> {
Ok(serde_json::from_str(json.as_ref())?)
}
pub fn builder() -> RTDStoryBuilder {
let inner = Story {
td_name: "story".to_string(),
extra: Some(Uuid::new_v4().to_string()),
..Default::default()
};
RTDStoryBuilder { inner }
}
pub fn id(&self) -> i64 {
self.id
}
pub fn poster_chat_id(&self) -> i64 {
self.poster_chat_id
}
pub fn poster_id(&self) -> &Option<MessageSender> {
&self.poster_id
}
pub fn date(&self) -> i64 {
self.date
}
pub fn is_being_posted(&self) -> bool {
self.is_being_posted
}
pub fn is_being_edited(&self) -> bool {
self.is_being_edited
}
pub fn is_edited(&self) -> bool {
self.is_edited
}
pub fn is_posted_to_chat_page(&self) -> bool {
self.is_posted_to_chat_page
}
pub fn is_visible_only_for_self(&self) -> bool {
self.is_visible_only_for_self
}
pub fn can_be_added_to_album(&self) -> bool {
self.can_be_added_to_album
}
pub fn can_be_deleted(&self) -> bool {
self.can_be_deleted
}
pub fn can_be_edited(&self) -> bool {
self.can_be_edited
}
pub fn can_be_forwarded(&self) -> bool {
self.can_be_forwarded
}
pub fn can_be_replied(&self) -> bool {
self.can_be_replied
}
pub fn can_set_privacy_settings(&self) -> bool {
self.can_set_privacy_settings
}
pub fn can_toggle_is_posted_to_chat_page(&self) -> bool {
self.can_toggle_is_posted_to_chat_page
}
pub fn can_get_statistics(&self) -> bool {
self.can_get_statistics
}
pub fn can_get_interactions(&self) -> bool {
self.can_get_interactions
}
pub fn has_expired_viewers(&self) -> bool {
self.has_expired_viewers
}
pub fn repost_info(&self) -> &Option<StoryRepostInfo> {
&self.repost_info
}
pub fn interaction_info(&self) -> &Option<StoryInteractionInfo> {
&self.interaction_info
}
pub fn chosen_reaction_type(&self) -> &Option<ReactionType> {
&self.chosen_reaction_type
}
pub fn privacy_settings(&self) -> &StoryPrivacySettings {
&self.privacy_settings
}
pub fn content(&self) -> &StoryContent {
&self.content
}
pub fn areas(&self) -> &Vec<StoryArea> {
&self.areas
}
pub fn caption(&self) -> &FormattedText {
&self.caption
}
pub fn album_ids(&self) -> &Vec<i64> {
&self.album_ids
}
}
#[doc(hidden)]
pub struct RTDStoryBuilder {
inner: Story,
}
impl RTDStoryBuilder {
pub fn build(&self) -> Story {
self.inner.clone()
}
pub fn id(&mut self, id: i64) -> &mut Self {
self.inner.id = id;
self
}
pub fn poster_chat_id(&mut self, poster_chat_id: i64) -> &mut Self {
self.inner.poster_chat_id = poster_chat_id;
self
}
pub fn poster_id<T: AsRef<MessageSender>>(&mut self, poster_id: T) -> &mut Self {
self.inner.poster_id = Some(poster_id.as_ref().clone());
self
}
pub fn date(&mut self, date: i64) -> &mut Self {
self.inner.date = date;
self
}
pub fn is_being_posted(&mut self, is_being_posted: bool) -> &mut Self {
self.inner.is_being_posted = is_being_posted;
self
}
pub fn is_being_edited(&mut self, is_being_edited: bool) -> &mut Self {
self.inner.is_being_edited = is_being_edited;
self
}
pub fn is_edited(&mut self, is_edited: bool) -> &mut Self {
self.inner.is_edited = is_edited;
self
}
pub fn is_posted_to_chat_page(&mut self, is_posted_to_chat_page: bool) -> &mut Self {
self.inner.is_posted_to_chat_page = is_posted_to_chat_page;
self
}
pub fn is_visible_only_for_self(&mut self, is_visible_only_for_self: bool) -> &mut Self {
self.inner.is_visible_only_for_self = is_visible_only_for_self;
self
}
pub fn can_be_added_to_album(&mut self, can_be_added_to_album: bool) -> &mut Self {
self.inner.can_be_added_to_album = can_be_added_to_album;
self
}
pub fn can_be_deleted(&mut self, can_be_deleted: bool) -> &mut Self {
self.inner.can_be_deleted = can_be_deleted;
self
}
pub fn can_be_edited(&mut self, can_be_edited: bool) -> &mut Self {
self.inner.can_be_edited = can_be_edited;
self
}
pub fn can_be_forwarded(&mut self, can_be_forwarded: bool) -> &mut Self {
self.inner.can_be_forwarded = can_be_forwarded;
self
}
pub fn can_be_replied(&mut self, can_be_replied: bool) -> &mut Self {
self.inner.can_be_replied = can_be_replied;
self
}
pub fn can_set_privacy_settings(&mut self, can_set_privacy_settings: bool) -> &mut Self {
self.inner.can_set_privacy_settings = can_set_privacy_settings;
self
}
pub fn can_toggle_is_posted_to_chat_page(
&mut self,
can_toggle_is_posted_to_chat_page: bool,
) -> &mut Self {
self.inner.can_toggle_is_posted_to_chat_page = can_toggle_is_posted_to_chat_page;
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 can_get_interactions(&mut self, can_get_interactions: bool) -> &mut Self {
self.inner.can_get_interactions = can_get_interactions;
self
}
pub fn has_expired_viewers(&mut self, has_expired_viewers: bool) -> &mut Self {
self.inner.has_expired_viewers = has_expired_viewers;
self
}
pub fn repost_info<T: AsRef<StoryRepostInfo>>(&mut self, repost_info: T) -> &mut Self {
self.inner.repost_info = Some(repost_info.as_ref().clone());
self
}
pub fn interaction_info<T: AsRef<StoryInteractionInfo>>(
&mut self,
interaction_info: T,
) -> &mut Self {
self.inner.interaction_info = Some(interaction_info.as_ref().clone());
self
}
pub fn chosen_reaction_type<T: AsRef<ReactionType>>(
&mut self,
chosen_reaction_type: T,
) -> &mut Self {
self.inner.chosen_reaction_type = Some(chosen_reaction_type.as_ref().clone());
self
}
pub fn privacy_settings<T: AsRef<StoryPrivacySettings>>(
&mut self,
privacy_settings: T,
) -> &mut Self {
self.inner.privacy_settings = privacy_settings.as_ref().clone();
self
}
pub fn content<T: AsRef<StoryContent>>(&mut self, content: T) -> &mut Self {
self.inner.content = content.as_ref().clone();
self
}
pub fn areas(&mut self, areas: Vec<StoryArea>) -> &mut Self {
self.inner.areas = areas;
self
}
pub fn caption<T: AsRef<FormattedText>>(&mut self, caption: T) -> &mut Self {
self.inner.caption = caption.as_ref().clone();
self
}
pub fn album_ids(&mut self, album_ids: Vec<i64>) -> &mut Self {
self.inner.album_ids = album_ids;
self
}
}
impl AsRef<Story> for Story {
fn as_ref(&self) -> &Story {
self
}
}
impl AsRef<Story> for RTDStoryBuilder {
fn as_ref(&self) -> &Story {
&self.inner
}
}