This commit is contained in:
Sakuhl 2018-01-02 00:40:38 +01:00
parent 2a9a7d55e9
commit 97d6bb6a07

View File

@ -22,9 +22,7 @@ pub fn guild(name: &str) -> Result<Guild, Box<Error>> {
}
pub fn guild_by_prefix(prefix: &str) -> Result<Option<GuildEntry>, Box<Error>> {
let resp = reqwest::get("https://api.wynncraft.com/public_api.php?action=statsLeaderboard&type=guild&timeframe=alltime")?;
let top_100: Top100Guilds = serde_json::from_reader(resp)?;
let top_100 = guild_leaderboard()?;
for guild in top_100.data.into_iter() {
if guild.prefix == prefix {
@ -35,6 +33,12 @@ pub fn guild_by_prefix(prefix: &str) -> Result<Option<GuildEntry>, Box<Error>> {
Ok(None)
}
pub fn guild_leaderboard() -> Result<Top100Guilds, Box<Error>> {
let resp = reqwest::get("https://api.wynncraft.com/public_api.php?action=statsLeaderboard&type=guild&timeframe=alltime")?;
Ok(serde_json::from_reader(resp)?)
}
#[derive(Deserialize)]
pub struct Top100Guilds {
pub data: Vec<GuildEntry>