use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};
use url::Url;
#[derive(Clone, Copy, Debug, Deserialize, Serialize, Eq, PartialEq)]
#[serde(rename_all = "lowercase")]
pub enum UserRole {
Admin,
Moderator,
Pyro,
Developer,
#[serde(other)]
Unknown,
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct PayoutData {
#[serde(default)]
pub balance: Option<f64>,
#[serde(default)]
pub payout_wallet: Option<String>,
#[serde(default)]
pub payout_wallet_type: Option<String>,
#[serde(default)]
pub payout_address: Option<String>,
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct User {
pub id: String,
pub username: String,
#[serde(default)]
pub name: Option<String>,
#[serde(default)]
pub email: Option<String>,
#[serde(default)]
pub bio: Option<String>,
#[serde(default)]
pub payout_data: Option<PayoutData>,
#[serde(default)]
pub avatar_url: Option<Url>,
pub created: DateTime<Utc>,
pub role: UserRole,
#[serde(default)]
pub badges: u32,
#[serde(default)]
pub auth_providers: Option<Vec<String>>,
#[serde(default)]
pub email_verified: Option<bool>,
#[serde(default)]
pub has_password: Option<bool>,
#[serde(default)]
pub has_totp: Option<bool>,
}
#[derive(Clone, Debug, Default, Serialize)]
pub struct ModifyUserRequest {
#[serde(skip_serializing_if = "Option::is_none")]
pub username: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub name: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub email: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub bio: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub payout_data: Option<serde_json::Value>,
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct PayoutHistory {
pub all_time: String,
pub last_month: String,
#[serde(default)]
pub payouts: Vec<serde_json::Value>,
}