diff --git a/src/lib.rs b/src/lib.rs index dd11c51..331c419 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -22,9 +22,7 @@ pub fn guild(name: &str) -> Result> { } pub fn guild_by_prefix(prefix: &str) -> Result, Box> { - 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, Box> { Ok(None) } +pub fn guild_leaderboard() -> Result> { + 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