Skip to content

Commit

Permalink
feat: support maps (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
kade-robertson authored Jan 20, 2023
1 parent 9abce52 commit 74d4ca1
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use mockito;
#[cfg(feature = "local-cache")]
use crate::cache_middleware::CacheMiddleware;

use crate::models::{Challenges, Champions, Items, Runes, SummonerSpells, Translations};
use crate::models::{Challenges, Champions, Items, Maps, Runes, SummonerSpells, Translations};

#[derive(Error, Debug)]
pub enum DDragonClientError {
Expand Down Expand Up @@ -107,6 +107,10 @@ impl DDragonClient {
self.get_data::<Items>("./item.json")
}

pub fn maps(&self) -> Result<Maps, DDragonClientError> {
self.get_data::<Maps>("./map.json")
}

pub fn runes(&self) -> Result<Runes, DDragonClientError> {
self.get_data::<Runes>("./runesReforged.json")
}
Expand Down
30 changes: 30 additions & 0 deletions src/models/maps.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
use serde::{Deserialize, Serialize};
use std::collections::HashMap;

#[derive(Serialize, Deserialize)]
pub struct Maps {
#[serde(rename = "type")]
pub maps_type: String,
pub version: String,
pub data: HashMap<String, Map>,
}

#[derive(Serialize, Deserialize)]
pub struct Map {
#[serde(rename = "MapName")]
pub map_name: String,
#[serde(rename = "MapId")]
pub map_id: String,
pub image: Image,
}

#[derive(Serialize, Deserialize)]
pub struct Image {
pub full: String,
pub sprite: String,
pub group: String,
pub x: i64,
pub y: i64,
pub w: i64,
pub h: i64,
}
2 changes: 2 additions & 0 deletions src/models/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
pub mod challenges;
pub mod champions;
pub mod items;
pub mod maps;
pub mod runes;
pub mod shared;
pub mod summoner_spells;
Expand All @@ -9,6 +10,7 @@ pub mod translations;
pub use challenges::Challenges;
pub use champions::Champions;
pub use items::Items;
pub use maps::Maps;
pub use runes::Runes;
pub use summoner_spells::SummonerSpells;
pub use translations::Translations;
2 changes: 2 additions & 0 deletions tests/health.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ fn health_check() {
client.challenges().unwrap();
client.champions().unwrap();
client.items().unwrap();
client.maps().unwrap();
client.runes().unwrap();
client.summoner_spells().unwrap();
client.translations().unwrap();
Expand All @@ -23,6 +24,7 @@ fn health_check() {
client.challenges().unwrap();
client.champions().unwrap();
client.items().unwrap();
client.maps().unwrap();
client.runes().unwrap();
client.summoner_spells().unwrap();
client.translations().unwrap();
Expand Down

0 comments on commit 74d4ca1

Please sign in to comment.