aboutsummaryrefslogtreecommitdiff
path: root/src/api
diff options
context:
space:
mode:
authorDaniel Schadt <kingdread@gmx.de>2019-12-07 03:16:43 +0100
committerDaniel Schadt <kingdread@gmx.de>2019-12-07 03:16:43 +0100
commitc09d449902f529db6fe390b22307a237124410de (patch)
tree64c04077d2795ae4f288f4fed05e1996238d122c /src/api
parentd35534c0795caeda46e57fc515b74eba701110a2 (diff)
downloadkondou-c09d449902f529db6fe390b22307a237124410de.tar.gz
kondou-c09d449902f529db6fe390b22307a237124410de.tar.bz2
kondou-c09d449902f529db6fe390b22307a237124410de.zip
add chatlink + revenant legends support
Diffstat (limited to 'src/api')
-rw-r--r--src/api/legends.rs23
-rw-r--r--src/api/mod.rs11
2 files changed, 33 insertions, 1 deletions
diff --git a/src/api/legends.rs b/src/api/legends.rs
new file mode 100644
index 0000000..395d6b9
--- /dev/null
+++ b/src/api/legends.rs
@@ -0,0 +1,23 @@
+//! Struct definitions for the legends API endpoint.
+//!
+//! * [Example](https://api.guildwars2.com/v2/legends/Legend2)
+//! * [Wiki](https://wiki.guildwars2.com/wiki/API:2/legends)
+
+use super::HasId;
+use serde::{Deserialize, Serialize};
+
+#[derive(Deserialize, Serialize, Debug, Clone)]
+pub struct Legend {
+ /// The legend id.
+ pub id: String,
+ pub heal: u32,
+ pub elite: u32,
+ pub utilities: Vec<u32>,
+}
+
+impl HasId for Legend {
+ type Id = String;
+ fn get_id(&self) -> String {
+ self.id.clone()
+ }
+}
diff --git a/src/api/mod.rs b/src/api/mod.rs
index 6e1b457..41034ec 100644
--- a/src/api/mod.rs
+++ b/src/api/mod.rs
@@ -3,13 +3,15 @@
//! It contains `Deserialize`able definitions for the required API responses, as well as a wrapper
//! around the HTTP library. Note that only the required fields are modelled here, which means this
//! does not provide a full-featured mapping for all API types.
+pub mod legends;
pub mod professions;
pub mod skills;
pub mod specializations;
pub mod traits;
pub use self::{
- professions::Profession, skills::Skill, specializations::Specialization, traits::Trait,
+ legends::Legend, professions::Profession, skills::Skill, specializations::Specialization,
+ traits::Trait,
};
use image::DynamicImage;
@@ -187,6 +189,13 @@ impl Api {
self.get_multiple_cached("traits", "traits/", ids)
}
+ /// Retrieve detailed information about the given legends.
+ ///
+ /// Traits that are found in the cache are taken from there.
+ pub fn get_legends(&mut self, ids: &[String]) -> Result<Vec<Legend>, ApiError> {
+ self.get_multiple_cached("legends", "legends/", ids)
+ }
+
/// Loads the image from the given URL.
///
/// This automatically caches and also decodes the resulting data.