use serde::{Deserialize, Serialize};
#[cfg_attr(feature = "export", derive(tsify::Tsify))]
#[cfg_attr(feature = "export", tsify(into_wasm_abi, from_wasm_abi))]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct UserEvent {
pub display_html: String, pub beatmap_id: String, pub beatmapset_id: String, pub date: String, pub epicfactor: String, }
#[cfg_attr(feature = "export", derive(tsify::Tsify))]
#[cfg_attr(
feature = "export",
tsify(into_wasm_abi, from_wasm_abi, type_suffix = "V1")
)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct User {
pub user_id: String, pub username: String, pub join_date: String, pub count300: String, pub count100: String, pub count50: String, pub playcount: String, pub ranked_score: String, pub total_score: String, pub pp_rank: String, pub level: String, pub pp_raw: String, pub accuracy: String, pub count_rank_ss: String, pub count_rank_ssh: String, pub count_rank_s: String, pub count_rank_sh: String, pub count_rank_a: String, pub country: String, pub total_seconds_played: String, pub pp_country_rank: String, #[cfg_attr(feature = "export", tsify(type = "UserEvent"))]
pub events: Vec<UserEvent>, }
#[cfg_attr(feature = "export", derive(tsify::Tsify))]
#[cfg_attr(feature = "export", tsify(into_wasm_abi, from_wasm_abi))]
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct GetUserParamsRaw {
pub k: Option<String>, pub u: Option<String>, pub m: Option<u8>, pub t: Option<String>, pub event_days: Option<u8>, }
#[cfg_attr(feature = "export", derive(tsify::Tsify))]
#[cfg_attr(feature = "export", tsify(into_wasm_abi, from_wasm_abi))]
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct GetUserParams {
pub api_key: Option<String>, pub user: Option<String>, pub mode: Option<u8>, pub typee: Option<String>, pub event_days: Option<u8>, }
impl GetUserParams {
pub fn api_key(mut self, api_key: String) -> Self {
self.api_key = Some(api_key);
self
}
pub fn user(mut self, user: String) -> Self {
self.user = Some(user);
self
}
pub fn mode(mut self, mode: u8) -> Self {
self.mode = Some(mode);
self
}
pub fn typee(mut self, typee: String) -> Self {
self.typee = Some(typee);
self
}
pub fn event_days(mut self, event_days: u8) -> Self {
self.event_days = Some(event_days);
self
}
pub fn build_params(&self) -> Vec<(String, String)> {
let mut params = Vec::new();
if let Some(ref api_key) = self.api_key {
params.push(("k".to_string(), api_key.clone()));
}
if let Some(ref user) = self.user {
params.push(("u".to_string(), user.clone()));
}
if let Some(ref mode) = self.mode {
params.push(("m".to_string(), mode.to_string()));
}
if let Some(ref typee) = self.typee {
params.push(("type".to_string(), typee.clone()));
}
if let Some(ref event_days) = self.event_days {
params.push(("event_days".to_string(), event_days.to_string()));
}
params
}
pub fn to_raw(&self) -> GetUserParamsRaw {
GetUserParamsRaw {
k: self.api_key.clone(),
u: self.user.clone(),
m: self.mode,
t: self.typee.clone(),
event_days: self.event_days,
}
}
}
impl GetUserParamsRaw {
pub fn k(mut self, api_key: String) -> Self {
self.k = Some(api_key);
self
}
pub fn u(mut self, user: String) -> Self {
self.u = Some(user);
self
}
pub fn m(mut self, mode: u8) -> Self {
self.m = Some(mode);
self
}
pub fn t(mut self, typee: String) -> Self {
self.t = Some(typee);
self
}
pub fn event_days(mut self, event_days: u8) -> Self {
self.event_days = Some(event_days);
self
}
pub fn build_params(&self) -> Vec<(String, String)> {
let mut params = Vec::new();
if let Some(ref api_key) = self.k {
params.push(("k".to_string(), api_key.clone()));
}
if let Some(ref user) = self.u {
params.push(("u".to_string(), user.clone()));
}
if let Some(ref mode) = self.m {
params.push(("m".to_string(), mode.to_string()));
}
if let Some(ref typee) = self.t {
params.push(("type".to_string(), typee.clone()));
}
if let Some(ref event_days) = self.event_days {
params.push(("event_days".to_string(), event_days.to_string()));
}
params
}
}