use crate::responses::GenericResponse;
use std::fmt::{Debug, Display, Formatter};
pub use serde::Deserialize;
use crate::responses::listing::GenericListing;
use serde_json::Value;
#[derive(Deserialize, Clone)]
pub struct MeResponse {
#[serde(flatten)]
pub about: AboutUser,
pub features: Value,
}
impl Debug for MeResponse {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "[Me Response] User: {}", self.about.name)
}
}
#[derive(Deserialize, Clone)]
pub struct PersonalInformation {
pub pref_no_profanity: bool,
pub has_external_account: bool,
pub pref_geopopular: String,
pub pref_show_trending: bool,
pub pref_show_presence: bool,
pub gold_expiration: Option<i64>,
pub has_gold_subscription: bool,
pub coins: i64,
pub has_paypal_subscription: bool,
pub has_subscribed_to_premium: bool,
}
impl Debug for PersonalInformation {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "[Personal Information]")
}
}
#[derive(Deserialize, Clone)]
pub struct AboutUser {
#[serde(default)]
pub is_employee: bool,
#[serde(default)]
pub is_friend: bool,
pub subreddit: Value,
pub snoovatar_size: Option<Vec<i64>>,
#[serde(default)]
pub awardee_karma: i64,
pub id: String,
pub verified: bool,
pub is_gold: bool,
#[serde(default)]
pub is_suspended: bool,
#[serde(default)]
pub is_mod: bool,
#[serde(default)]
pub awarder_karma: i64,
pub has_verified_email: bool,
pub icon_img: String,
pub hide_from_robots: bool,
#[serde(default)]
pub link_karma: i64,
#[serde(default)]
pub is_blocked: bool,
#[serde(default)]
pub total_karma: i64,
pub pref_show_snoovatar: bool,
pub name: String,
#[serde(default)]
pub created: f64,
#[serde(default)]
pub created_utc: f64,
pub snoovatar_img: String,
#[serde(default)]
pub comment_karma: i64,
pub accept_followers: bool,
pub has_subscribed: bool,
#[serde(flatten)]
pub personal_details: Option<PersonalInformation>,
}
impl Display for AboutUser {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.name)
}
}
impl Debug for AboutUser {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(
f,
"[User]. name: {}. Contains Personal Information {}",
self.name,
self.personal_details.is_some()
)
}
}
pub type UserResponse = GenericResponse<AboutUser>;
pub type Users = GenericListing<AboutUser>;