Skip to content

Commit

Permalink
feat: support runes
Browse files Browse the repository at this point in the history
  • Loading branch information
kade-robertson committed Jan 19, 2023
1 parent 7121963 commit 8faaf87
Show file tree
Hide file tree
Showing 3 changed files with 35 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 @@ -5,7 +5,7 @@ use url::Url;
#[cfg(test)]
use mockito;

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

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

pub fn runes(&self) -> Result<Runes, DDragonClientError> {
self.get_data::<Runes>("./item.json")
}

pub fn translations(&self) -> Result<Translations, DDragonClientError> {
self.get_data::<Translations>("./language.json")
}
Expand Down
2 changes: 2 additions & 0 deletions src/models/mod.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
pub mod challenges;
pub mod champions;
pub mod items;
pub mod runes;
pub mod shared;
pub mod translations;

pub use challenges::Challenges;
pub use champions::Champions;
pub use items::Items;
pub use runes::Runes;
pub use translations::Translations;
28 changes: 28 additions & 0 deletions src/models/runes.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
use serde::{Deserialize, Serialize};
pub type Runes = Vec<Rune>;

#[derive(Serialize, Deserialize)]
pub struct Rune {
pub id: i64,
pub key: String,
pub icon: String,
pub name: String,
pub slots: Vec<Slot>,
}

#[derive(Serialize, Deserialize)]
pub struct Slot {
pub runes: Vec<RuneElement>,
}

#[derive(Serialize, Deserialize)]
pub struct RuneElement {
pub id: i64,
pub key: String,
pub icon: String,
pub name: String,
#[serde(rename = "shortDesc")]
pub short_desc: String,
#[serde(rename = "longDesc")]
pub long_desc: String,
}

0 comments on commit 8faaf87

Please sign in to comment.