use crate::errors::*;
use crate::types::*;
use uuid::Uuid;
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct AvailableReactions {
#[doc(hidden)]
#[serde(rename(serialize = "@type", deserialize = "@type"))]
td_name: String,
#[doc(hidden)]
#[serde(rename(serialize = "@extra", deserialize = "@extra"))]
extra: Option<String>,
top_reactions: Vec<AvailableReaction>,
recent_reactions: Vec<AvailableReaction>,
popular_reactions: Vec<AvailableReaction>,
allow_custom_emoji: bool,
are_tags: bool,
unavailability_reason: Option<ReactionUnavailabilityReason>,
}
impl RObject for AvailableReactions {
#[doc(hidden)]
fn td_name(&self) -> &'static str {
"availableReactions"
}
#[doc(hidden)]
fn extra(&self) -> Option<String> {
self.extra.clone()
}
fn to_json(&self) -> RTDResult<String> {
Ok(serde_json::to_string(self)?)
}
}
impl AvailableReactions {
pub fn from_json<S: AsRef<str>>(json: S) -> RTDResult<Self> {
Ok(serde_json::from_str(json.as_ref())?)
}
pub fn builder() -> RTDAvailableReactionsBuilder {
let inner = AvailableReactions {
td_name: "availableReactions".to_string(),
extra: Some(Uuid::new_v4().to_string()),
..Default::default()
};
RTDAvailableReactionsBuilder { inner }
}
pub fn top_reactions(&self) -> &Vec<AvailableReaction> {
&self.top_reactions
}
pub fn recent_reactions(&self) -> &Vec<AvailableReaction> {
&self.recent_reactions
}
pub fn popular_reactions(&self) -> &Vec<AvailableReaction> {
&self.popular_reactions
}
pub fn allow_custom_emoji(&self) -> bool {
self.allow_custom_emoji
}
pub fn are_tags(&self) -> bool {
self.are_tags
}
pub fn unavailability_reason(&self) -> &Option<ReactionUnavailabilityReason> {
&self.unavailability_reason
}
}
#[doc(hidden)]
pub struct RTDAvailableReactionsBuilder {
inner: AvailableReactions,
}
impl RTDAvailableReactionsBuilder {
pub fn build(&self) -> AvailableReactions {
self.inner.clone()
}
pub fn top_reactions(&mut self, top_reactions: Vec<AvailableReaction>) -> &mut Self {
self.inner.top_reactions = top_reactions;
self
}
pub fn recent_reactions(&mut self, recent_reactions: Vec<AvailableReaction>) -> &mut Self {
self.inner.recent_reactions = recent_reactions;
self
}
pub fn popular_reactions(&mut self, popular_reactions: Vec<AvailableReaction>) -> &mut Self {
self.inner.popular_reactions = popular_reactions;
self
}
pub fn allow_custom_emoji(&mut self, allow_custom_emoji: bool) -> &mut Self {
self.inner.allow_custom_emoji = allow_custom_emoji;
self
}
pub fn are_tags(&mut self, are_tags: bool) -> &mut Self {
self.inner.are_tags = are_tags;
self
}
pub fn unavailability_reason<T: AsRef<ReactionUnavailabilityReason>>(
&mut self,
unavailability_reason: T,
) -> &mut Self {
self.inner.unavailability_reason = Some(unavailability_reason.as_ref().clone());
self
}
}
impl AsRef<AvailableReactions> for AvailableReactions {
fn as_ref(&self) -> &AvailableReactions {
self
}
}
impl AsRef<AvailableReactions> for RTDAvailableReactionsBuilder {
fn as_ref(&self) -> &AvailableReactions {
&self.inner
}
}