diff --git a/src/consts/champion.rs b/src/consts/champion.rs
index efa56dd..1b397c5 100644
--- a/src/consts/champion.rs
+++ b/src/consts/champion.rs
@@ -1,16 +1,27 @@
-// This file is automatically generated.
-// Do not directly edit.
+///////////////////////////////////////////////
+// //
+// ! //
+// This file is automatically generated! //
+// Do not directly edit! //
+// //
+///////////////////////////////////////////////
use std::fmt;
-use num_derive;
+use num_derive::{ FromPrimitive, ToPrimitive };
+use serde_repr::{ Serialize_repr, Deserialize_repr };
/// League of Legend's champions.
///
/// The documentation of each variant specifies:
/// NAME (`IDENTIFIER`, ID).
#[derive(Debug, Copy, Clone)]
-#[derive(num_derive::FromPrimitive, num_derive::ToPrimitive)]
+#[derive(FromPrimitive, ToPrimitive)]
+#[derive(Serialize_repr, Deserialize_repr)]
+#[repr(i16)]
pub enum Champion {
+ /// A champion that doesn't exist. Used in TeamBans when no ban occured.
+ None = -1,
+
/** Aatrox (`Aatrox`, 266). */ Aatrox = 266,
/** Ahri (`Ahri`, 103). */ Ahri = 103,
/** Akali (`Akali`, 84). */ Akali = 84,
@@ -161,6 +172,7 @@ pub enum Champion {
impl Champion {
pub fn name(self) -> &'static str {
match self {
+ Self::None => "None",
Self::Aatrox => "Aatrox",
Self::Ahri => "Ahri",
Self::Akali => "Akali",
@@ -311,6 +323,7 @@ impl Champion {
pub fn identifier(self) -> &'static str {
match self {
+ Self::None => "None",
Self::Aatrox => "Aatrox",
Self::Ahri => "Ahri",
Self::Akali => "Akali",
diff --git a/src/consts/division.rs b/src/consts/division.rs
index 28a4764..4a33634 100644
--- a/src/consts/division.rs
+++ b/src/consts/division.rs
@@ -1,10 +1,12 @@
#![allow(deprecated)]
use strum_macros::{ EnumString, Display, AsRefStr };
+use serde_repr::{ Serialize_repr, Deserialize_repr };
#[derive(Debug, Copy, Clone)]
#[derive(Eq, PartialEq, Hash, PartialOrd, Ord)]
#[derive(EnumString, Display, AsRefStr)]
+#[derive(Serialize_repr, Deserialize_repr)]
#[repr(u8)]
pub enum Division {
I = 1,
diff --git a/src/consts/game_mode.rs b/src/consts/game_mode.rs
index 19d061f..d71d103 100644
--- a/src/consts/game_mode.rs
+++ b/src/consts/game_mode.rs
@@ -1,5 +1,10 @@
-// This file is automatically generated.
-// Do not directly edit.
+///////////////////////////////////////////////
+// //
+// ! //
+// This file is automatically generated! //
+// Do not directly edit! //
+// //
+///////////////////////////////////////////////
use strum_macros::{ EnumString, Display, AsRefStr };
@@ -65,3 +70,5 @@ pub enum GameMode {
#[strum(to_string="ODYSSEY")]
Odyssey,
}
+
+serde_string!(GameMode);
diff --git a/src/consts/game_type.rs b/src/consts/game_type.rs
index 0b0f219..1ab286b 100644
--- a/src/consts/game_type.rs
+++ b/src/consts/game_type.rs
@@ -1,5 +1,10 @@
-// This file is automatically generated.
-// Do not directly edit.
+///////////////////////////////////////////////
+// //
+// ! //
+// This file is automatically generated! //
+// Do not directly edit! //
+// //
+///////////////////////////////////////////////
use strum_macros::{ EnumString, Display, AsRefStr };
@@ -19,3 +24,5 @@ pub enum GameType {
#[strum(to_string="MATCHED_GAME")]
MatchedGame,
}
+
+serde_string!(GameType);
diff --git a/src/consts/macro_serde_string.rs b/src/consts/macro_serde_string.rs
new file mode 100644
index 0000000..2d3762a
--- /dev/null
+++ b/src/consts/macro_serde_string.rs
@@ -0,0 +1,24 @@
+#![macro_use]
+#[macro_export]
+macro_rules! serde_string {
+ ( $x:ty ) => {
+ impl<'de> serde::de::Deserialize<'de> for $x
+ {
+ fn deserialize(deserializer: D) -> Result
+ where
+ D: serde::de::Deserializer<'de>
+ {
+ let s = String::deserialize(deserializer)?;
+ s.parse().map_err(serde::de::Error::custom)
+ }
+ }
+ impl serde::ser::Serialize for $x {
+ fn serialize(&self, serializer: S) -> Result
+ where
+ S: serde::ser::Serializer,
+ {
+ serializer.serialize_str(self.as_ref())
+ }
+ }
+ };
+}
diff --git a/src/consts/map.rs b/src/consts/map.rs
index 992408a..cb46e4f 100644
--- a/src/consts/map.rs
+++ b/src/consts/map.rs
@@ -1,9 +1,17 @@
-// This file is automatically generated.
-// Do not directly edit.
+///////////////////////////////////////////////
+// //
+// ! //
+// This file is automatically generated! //
+// Do not directly edit! //
+// //
+///////////////////////////////////////////////
+
+use serde_repr::{ Serialize_repr, Deserialize_repr };
/// League of Legends maps.
#[derive(Debug, Copy, Clone)]
#[derive(Eq, PartialEq, Hash, PartialOrd, Ord)]
+#[derive(Serialize_repr, Deserialize_repr)]
#[repr(u8)]
pub enum Map {
diff --git a/src/consts/mod.rs b/src/consts/mod.rs
index 5b8826b..35c3853 100644
--- a/src/consts/mod.rs
+++ b/src/consts/mod.rs
@@ -1,5 +1,7 @@
//! Constant data and Enums relevant to the Riot Games API.
+mod macro_serde_string;
+
mod champion;
pub use champion::*;
diff --git a/src/consts/queue.rs b/src/consts/queue.rs
index df1e86a..1202b7e 100644
--- a/src/consts/queue.rs
+++ b/src/consts/queue.rs
@@ -1,5 +1,10 @@
-// This file is automatically generated.
-// Do not directly edit.
+///////////////////////////////////////////////
+// //
+// ! //
+// This file is automatically generated! //
+// Do not directly edit! //
+// //
+///////////////////////////////////////////////
#![allow(deprecated)]
use serde_repr::{ Serialize_repr, Deserialize_repr };
diff --git a/src/consts/queue_type.rs b/src/consts/queue_type.rs
index 163ae2f..2d45172 100644
--- a/src/consts/queue_type.rs
+++ b/src/consts/queue_type.rs
@@ -18,6 +18,8 @@ pub enum QueueType {
RankedTft,
}
+serde_string!(QueueType);
+
#[cfg(test)]
mod test {
use super::*;
diff --git a/src/consts/season.rs b/src/consts/season.rs
index 256429c..ef8f61d 100644
--- a/src/consts/season.rs
+++ b/src/consts/season.rs
@@ -1,9 +1,17 @@
-// This file is automatically generated.
-// Do not directly edit.
+///////////////////////////////////////////////
+// //
+// ! //
+// This file is automatically generated! //
+// Do not directly edit! //
+// //
+///////////////////////////////////////////////
+
+use serde_repr::{ Serialize_repr, Deserialize_repr };
/// League of Legends matchmaking seasons.
#[derive(Debug, Copy, Clone)]
#[derive(Eq, PartialEq, Hash, PartialOrd, Ord)]
+#[derive(Serialize_repr, Deserialize_repr)]
#[repr(u8)]
pub enum Season {
Preseason3 = 0,
diff --git a/src/consts/team.rs b/src/consts/team.rs
index 92b806b..73dcc0d 100644
--- a/src/consts/team.rs
+++ b/src/consts/team.rs
@@ -1,6 +1,10 @@
+use serde_repr::{ Serialize_repr, Deserialize_repr };
+
+/// League of Legends team.
#[derive(Debug, Copy, Clone)]
#[derive(Eq, PartialEq, Hash, Ord, PartialOrd)]
-/// League of Legends team.
+#[derive(Serialize_repr, Deserialize_repr)]
+#[repr(u8)]
pub enum Team {
/// Blue team (bottom left on Summoner's Rift).
Blue = 100,
diff --git a/src/consts/tier.rs b/src/consts/tier.rs
index 2450455..c6b67ca 100644
--- a/src/consts/tier.rs
+++ b/src/consts/tier.rs
@@ -18,6 +18,8 @@ pub enum Tier {
#[strum(to_string="CHALLENGER")] Challenger = 240,
}
+serde_string!(Tier);
+
impl Tier {
/// If this tier is "standard".
/// Standard means non-apex (not master+), and not unranked.
diff --git a/src/endpoints.rs b/src/endpoints.rs
index 5cc1078..473a72d 100644
--- a/src/endpoints.rs
+++ b/src/endpoints.rs
@@ -1,5 +1,10 @@
-// This file is automatically generated.
-// Do not directly edit.
+///////////////////////////////////////////////
+// //
+// ! //
+// This file is automatically generated! //
+// Do not directly edit! //
+// //
+///////////////////////////////////////////////
// http://www.mingweisamuel.com/riotapi-schema/tool/
// Version b2fb0513c3cdb6baa0ba78bd2a50b43670161980
@@ -125,7 +130,7 @@ impl<'a> ChampionMasteryV4<'a> {
/// * `region` - Region to query.
/// * `championId` - Champion ID to retrieve Champion Mastery for
/// * `encryptedSummonerId` - Summoner ID associated with the player
- pub fn get_champion_mastery(&self, region: Region, encrypted_summoner_id: &str, champion_id: i64)
+ pub fn get_champion_mastery(&self, region: Region, encrypted_summoner_id: &str, champion_id: crate::consts::Champion)
-> impl Future