use serde::{Deserialize, Serialize};
#[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 Beatmap {
pub approved: String, pub submit_date: String, pub approved_date: Option<String>, pub last_update: String, pub artist: String,
pub beatmap_id: String, pub beatmapset_id: String, pub bpm: String,
pub creator: String,
pub creator_id: String,
pub difficultyrating: String, pub diff_aim: Option<String>,
pub diff_speed: Option<String>,
pub diff_size: String, pub diff_overall: String, pub diff_approach: String, pub diff_drain: String, pub hit_length: String, pub source: String,
pub genre_id: String, pub language_id: String, pub title: String, pub total_length: String, pub version: String, pub file_md5: String, pub mode: String, pub tags: String, pub favourite_count: String, pub rating: String,
pub packs: Option<String>, pub playcount: String, pub passcount: String, pub count_normal: String,
pub count_slider: String,
pub count_spinner: String,
pub max_combo: String, pub storyboard: String, pub video: String, pub download_unavailable: String, pub audio_unavailable: String, }
#[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 GetBeatmapsParamsRaw {
pub k: Option<String>, pub since: Option<String>, pub s: Option<String>, pub b: Option<String>, pub u: Option<String>, pub t: Option<String>, pub m: Option<u8>, pub a: Option<u8>, pub h: Option<String>, pub limit: Option<u32>, pub mods: Option<u32>, }
#[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 GetBeatmapsParams {
pub api_key: Option<String>, pub since: Option<String>, pub sid: Option<String>, pub bid: Option<String>, pub uid: Option<String>, pub typee: Option<String>, pub mode: Option<u8>, pub has_converted: Option<u8>, pub hash: Option<String>, pub limit: Option<u32>, pub mods: Option<u32>, }
impl GetBeatmapsParams {
pub fn api_key(mut self, api_key: String) -> Self {
self.api_key = Some(api_key);
self
}
pub fn since(mut self, since: String) -> Self {
self.since = Some(since);
self
}
pub fn sid(mut self, sid: String) -> Self {
self.sid = Some(sid);
self
}
pub fn bid(mut self, bid: String) -> Self {
self.bid = Some(bid);
self
}
pub fn uid(mut self, uid: String) -> Self {
self.uid = Some(uid);
self
}
pub fn typee(mut self, typee: String) -> Self {
self.typee = Some(typee);
self
}
pub fn mode(mut self, mode: u8) -> Self {
self.mode = Some(mode);
self
}
pub fn has_converted(mut self, has_converted: u8) -> Self {
self.has_converted = Some(has_converted);
self
}
pub fn hash(mut self, hash: String) -> Self {
self.hash = Some(hash);
self
}
pub fn limit(mut self, limit: u32) -> Self {
self.limit = Some(limit);
self
}
pub fn mods(mut self, mods: u32) -> Self {
self.mods = Some(mods);
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 since) = self.since {
params.push(("since".to_string(), since.clone()));
}
if let Some(ref sid) = self.sid {
params.push(("s".to_string(), sid.clone()));
}
if let Some(ref bid) = self.bid {
params.push(("b".to_string(), bid.clone()));
}
if let Some(ref uid) = self.uid {
params.push(("u".to_string(), uid.clone()));
}
if let Some(ref typee) = self.typee {
params.push(("type".to_string(), typee.clone()));
}
if let Some(ref mode) = self.mode {
params.push(("m".to_string(), mode.to_string()));
}
if let Some(ref has_converted) = self.has_converted {
params.push(("a".to_string(), has_converted.to_string()));
}
if let Some(ref hash) = self.hash {
params.push(("h".to_string(), hash.clone()));
}
if let Some(ref limit) = self.limit {
params.push(("limit".to_string(), limit.to_string()));
}
if let Some(ref mods) = self.mods {
params.push(("mods".to_string(), mods.to_string()));
}
params
}
pub fn to_raw(&self) -> GetBeatmapsParamsRaw {
GetBeatmapsParamsRaw {
k: self.api_key.clone(),
since: self.since.clone(),
s: self.sid.clone(),
b: self.bid.clone(),
u: self.uid.clone(),
t: self.typee.clone(),
m: self.mode,
a: self.has_converted,
h: self.hash.clone(),
limit: self.limit,
mods: self.mods,
}
}
}
impl GetBeatmapsParamsRaw {
pub fn k(mut self, api_key: String) -> Self {
self.k = Some(api_key);
self
}
pub fn since(mut self, since: String) -> Self {
self.since = Some(since);
self
}
pub fn s(mut self, sid: String) -> Self {
self.s = Some(sid);
self
}
pub fn b(mut self, bid: String) -> Self {
self.b = Some(bid);
self
}
pub fn u(mut self, uid: String) -> Self {
self.u = Some(uid);
self
}
pub fn t(mut self, typee: String) -> Self {
self.t = Some(typee);
self
}
pub fn m(mut self, mode: u8) -> Self {
self.m = Some(mode);
self
}
pub fn a(mut self, has_converted: u8) -> Self {
self.a = Some(has_converted);
self
}
pub fn h(mut self, hash: String) -> Self {
self.h = Some(hash);
self
}
pub fn limit(mut self, limit: u32) -> Self {
self.limit = Some(limit);
self
}
pub fn mods(mut self, mods: u32) -> Self {
self.mods = Some(mods);
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 since) = self.since {
params.push(("since".to_string(), since.clone()));
}
if let Some(ref sid) = self.s {
params.push(("s".to_string(), sid.clone()));
}
if let Some(ref bid) = self.b {
params.push(("b".to_string(), bid.clone()));
}
if let Some(ref uid) = self.u {
params.push(("u".to_string(), uid.clone()));
}
if let Some(ref typee) = self.t {
params.push(("type".to_string(), typee.clone()));
}
if let Some(ref mode) = self.m {
params.push(("m".to_string(), mode.to_string()));
}
if let Some(ref has_converted) = self.a {
params.push(("a".to_string(), has_converted.to_string()));
}
if let Some(ref hash) = self.h {
params.push(("h".to_string(), hash.clone()));
}
if let Some(ref limit) = self.limit {
params.push(("limit".to_string(), limit.to_string()));
}
if let Some(ref mods) = self.mods {
params.push(("mods".to_string(), mods.to_string()));
}
params
}
}