use crate::b_api_concat;
#[non_exhaustive]
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
pub enum Route {
Player(String),
PlayerBattlelogs(String),
Club(String),
ClubMembers(String),
PlayerRankings {
country_code: String,
limit: u8,
},
ClubRankings {
country_code: String,
limit: u8,
},
BrawlerRankings {
country_code: String,
brawler_id: usize,
limit: u8,
},
Brawlers,
Brawler(usize),
}
impl Route {
pub fn to_url_str(&self) -> String {
match self {
Route::Player(ref s) => format!("{}{}", b_api_concat!("players/"), s),
Route::PlayerBattlelogs(ref s) => format!(
"{}{}/battlelog", b_api_concat!("players/"), s
),
Route::Club(ref s) => format!("{}{}", b_api_concat!("clubs/"), s),
Route::ClubMembers(ref s) => format!(
"{}{}/members", b_api_concat!("clubs/"), s
),
Route::PlayerRankings {
ref country_code,
limit
} => format!(
"{}{}/players?limit={}", b_api_concat!("rankings/"), country_code, limit
),
Route::ClubRankings {
ref country_code,
limit
} => format!(
"{}{}/clubs?limit={}", b_api_concat!("rankings/"), country_code, limit
),
Route::BrawlerRankings {
ref country_code,
brawler_id,
limit
} => format!(
"{}{}/brawlers/{}?limit={}",
b_api_concat!("rankings/"), country_code, brawler_id, limit
),
Route::Brawlers => String::from(b_api_concat!("brawlers/")),
Route::Brawler(id) => format!(
"{}/{}",
b_api_concat!("brawlers"),
id,
)
}
}
}