From 346e12656b207b507495fa94eb971af520745685 Mon Sep 17 00:00:00 2001 From: Mingwei Samuel Date: Sat, 19 Oct 2019 14:39:53 -0700 Subject: [PATCH] code generation working --- Cargo.toml | 5 +- src/consts/region.rs | 16 +- src/lib.rs | 15 + src/req/regional_requester.rs | 14 +- src/req/requester_manager.rs | 8 +- src/riot_api.rs | 15 +- srcgen/.gitignore | 2 - srcgen/champion.rs | 636 +++++++++++++++ srcgen/dotUtils.js | 91 ++- srcgen/dto.rs | 1366 +++++++++++++++++++++++++++++++++ srcgen/dto.rs.dt | 18 +- srcgen/endpoints.rs | 448 +++++++++++ srcgen/endpoints.rs.dt | 133 ++++ srcgen/mod.rs | 5 + srcgen/package-lock.json | 170 ++++ srcgen/package.json | 7 +- 16 files changed, 2882 insertions(+), 67 deletions(-) create mode 100644 srcgen/champion.rs create mode 100644 srcgen/dto.rs create mode 100644 srcgen/endpoints.rs create mode 100644 srcgen/endpoints.rs.dt diff --git a/Cargo.toml b/Cargo.toml index eb261c3..d5b81d7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "riven" -version = "0.0.1" +version = "0.0.2" authors = ["Mingwei Samuel "] description = "Riot API Library (WIP)" license = "LGPL-3.0" @@ -19,7 +19,8 @@ num-derive = "0.3" parking_lot = { version = "0.9", features = [ "nightly" ] } reqwest = { version = "0.10.0-alpha.1", features = [ "gzip", "json" ] } scan_fmt = "0.2" -serde = "^1.0" +serde = { version = "1.0", features = [ "derive" ] } +url = "2.1" [dev-dependencies] env_logger = "0.7" diff --git a/src/consts/region.rs b/src/consts/region.rs index 5722f48..69add5f 100644 --- a/src/consts/region.rs +++ b/src/consts/region.rs @@ -1,7 +1,9 @@ -#[derive(Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] -pub struct Region<'a> { - pub key: &'a str, - pub platform: &'a str, +#[derive(Debug)] +#[derive(PartialEq, Eq, Hash, PartialOrd, Ord)] +#[derive(Clone, Copy)] +pub struct Region { + pub key: &'static str, + pub platform: &'static str, } macro_rules! regions { @@ -11,7 +13,7 @@ macro_rules! regions { )* ) => { $( - pub const $key: &'static Region<'static> = &Region { + pub const $key: Region = Region { key: stringify!($key), platform: $plat, }; @@ -23,7 +25,7 @@ macro_rules! regions { #[doc="# Returns"] #[doc="`Some(&Region)` if match found, `None` if no match found."] #[allow(unreachable_patterns)] - pub fn get(name: &str) -> Option<&Region> { + pub fn get(name: &str) -> Option { match &*name.to_ascii_uppercase() { $( stringify!($key) | $plat => Some(Self::$key), @@ -34,7 +36,7 @@ macro_rules! regions { } } -impl Region<'_> { +impl Region { // Is this stupid? regions! { BR => "BR1"; diff --git a/src/lib.rs b/src/lib.rs index 340e0b0..5fbf9d8 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,5 +1,7 @@ include!("../srcgen/mod.rs"); +pub use dto::*; + pub mod consts; mod riot_api_config; @@ -11,11 +13,24 @@ pub use riot_api::*; mod req; mod util; + #[cfg(test)] mod tests { use tokio::runtime::Runtime; use super::*; + + use url::form_urlencoded::Serializer; + #[test] + fn checkme() { + let mut query = Serializer::new(String::new()); + query.append_pair("hello", "false"); + query.append_pair("hello", "world"); + let result = query.finish(); + println!("{}", result); + } + + #[test] fn it_works() { env_logger::init(); diff --git a/src/req/regional_requester.rs b/src/req/regional_requester.rs index 7acbead..c770c78 100644 --- a/src/req/regional_requester.rs +++ b/src/req/regional_requester.rs @@ -1,7 +1,7 @@ use std::sync::Arc; use async_std::task; -use reqwest::{ Client, StatusCode }; +use reqwest::{ Client, StatusCode, Url }; use crate::riot_api_config::RiotApiConfig; use crate::consts::Region; @@ -40,8 +40,8 @@ impl<'a> RegionalRequester<'a> { } pub async fn get( - &self, method_id: &'a str, region: &'_ Region<'_>, relative_url: &'_ str, - query: &[(&'_ str, &'_ str)]) -> Result, reqwest::Error> + &self, method_id: &'a str, region: Region, path: &str, + query: Option<&str>) -> Result, reqwest::Error> { let mut attempts: u8 = 0; @@ -57,10 +57,14 @@ impl<'a> RegionalRequester<'a> { } // Send request. - let url = &*format!("https://{}.api.riotgames.com{}", region.platform, relative_url); + let url_base = format!("https://{}.api.riotgames.com", region.platform); + let mut url = Url::parse(&*url_base) + .unwrap_or_else(|_| panic!("Failed to parse url_base: \"{}\".", url_base)); + url.set_path(path); + url.set_query(query); + let result = self.client.get(url) .header(Self::RIOT_KEY_HEADER, self.riot_api_config.api_key) - .query(query) .send() .await; diff --git a/src/req/requester_manager.rs b/src/req/requester_manager.rs index 702fed8..a232f7d 100644 --- a/src/req/requester_manager.rs +++ b/src/req/requester_manager.rs @@ -14,7 +14,7 @@ pub struct RequesterManager<'a> { client: Client, /// Per-region requesters. - regional_requesters: InsertOnlyCHashMap<&'a Region<'a>, RegionalRequester<'a>>, + regional_requesters: InsertOnlyCHashMap>, } impl<'a> RequesterManager<'a> { @@ -31,12 +31,12 @@ impl<'a> RequesterManager<'a> { } pub async fn get( - &'a self, method_id: &'a str, region: &'a Region<'a>, relative_url: &'_ str, - query: &[(&'_ str, &'_ str)]) -> Result, reqwest::Error> + &'a self, method_id: &'a str, region: Region, path: &str, + query: Option<&str>) -> Result, reqwest::Error> { // TODO: max concurrent requests? Or can configure client? let regional_requester = self.regional_requesters .get_or_insert_with(region, || RegionalRequester::new(&self.riot_api_config, &self.client)); - regional_requester.get(method_id, region, relative_url, query).await + regional_requester.get(method_id, region, path, query).await } } diff --git a/src/riot_api.rs b/src/riot_api.rs index 345b857..643cb61 100644 --- a/src/riot_api.rs +++ b/src/riot_api.rs @@ -1,15 +1,18 @@ -use crate::RiotApiConfig; +use crate::*; use crate::consts::Region; use crate::req::RequesterManager; pub struct RiotApi<'a> { - requester_manager: RequesterManager<'a>, + pub requester_manager: RequesterManager<'a>, + _private: (), } impl<'a> RiotApi<'a> { pub fn with_config(config: RiotApiConfig<'a>) -> Self { + let req_man = RequesterManager::new(config); Self { - requester_manager: RequesterManager::new(config), + requester_manager: req_man, + _private: (), } } @@ -18,9 +21,9 @@ impl<'a> RiotApi<'a> { } pub async fn get( - &'a self, method_id: &'a str, region: &'a Region<'a>, relative_url: &'_ str, - query: &[(&'_ str, &'_ str)]) -> Result, reqwest::Error> + &'a self, method_id: &'a str, region: Region, path: &str, + query: Option<&str>) -> Result, reqwest::Error> { - self.requester_manager.get(method_id, region, relative_url, query).await + self.requester_manager.get(method_id, region, path, query).await } } diff --git a/srcgen/.gitignore b/srcgen/.gitignore index 78f44ec..b204397 100644 --- a/srcgen/.gitignore +++ b/srcgen/.gitignore @@ -1,4 +1,2 @@ node_modules/ -*.rs -!mod.rs .*.json diff --git a/srcgen/champion.rs b/srcgen/champion.rs new file mode 100644 index 0000000..1a2a673 --- /dev/null +++ b/srcgen/champion.rs @@ -0,0 +1,636 @@ + +// This file is automatically generated. +// Do not directly edit. +// Generated on 2019-10-20T06:19:43.696Z + +use std::fmt; +use num_derive; + +#[derive(fmt::Debug, Copy, Clone)] +#[derive(num_derive::FromPrimitive, num_derive::ToPrimitive)] +pub enum Champion { + Aatrox = 266, + Ahri = 103, + Akali = 84, + Alistar = 12, + Amumu = 32, + Anivia = 34, + Annie = 1, + Ashe = 22, + AurelionSol = 136, + Azir = 268, + Bard = 432, + Blitzcrank = 53, + Brand = 63, + Braum = 201, + Caitlyn = 51, + Camille = 164, + Cassiopeia = 69, + ChoGath = 31, + Corki = 42, + Darius = 122, + Diana = 131, + DrMundo = 36, + Draven = 119, + Ekko = 245, + Elise = 60, + Evelynn = 28, + Ezreal = 81, + Fiddlesticks = 9, + Fiora = 114, + Fizz = 105, + Galio = 3, + Gangplank = 41, + Garen = 86, + Gnar = 150, + Gragas = 79, + Graves = 104, + Hecarim = 120, + Heimerdinger = 74, + Illaoi = 420, + Irelia = 39, + Ivern = 427, + Janna = 40, + JarvanIV = 59, + Jax = 24, + Jayce = 126, + Jhin = 202, + Jinx = 222, + KaiSa = 145, + Kalista = 429, + Karma = 43, + Karthus = 30, + Kassadin = 38, + Katarina = 55, + Kayle = 10, + Kayn = 141, + Kennen = 85, + KhaZix = 121, + Kindred = 203, + Kled = 240, + KogMaw = 96, + LeBlanc = 7, + LeeSin = 64, + Leona = 89, + Lissandra = 127, + Lucian = 236, + Lulu = 117, + Lux = 99, + Malphite = 54, + Malzahar = 90, + Maokai = 57, + MasterYi = 11, + MissFortune = 21, + Mordekaiser = 82, + Morgana = 25, + Nami = 267, + Nasus = 75, + Nautilus = 111, + Neeko = 518, + Nidalee = 76, + Nocturne = 56, + NunuWillump = 20, + Olaf = 2, + Orianna = 61, + Ornn = 516, + Pantheon = 80, + Poppy = 78, + Pyke = 555, + Qiyana = 246, + Quinn = 133, + Rakan = 497, + Rammus = 33, + RekSai = 421, + Renekton = 58, + Rengar = 107, + Riven = 92, + Rumble = 68, + Ryze = 13, + Sejuani = 113, + Shaco = 35, + Shen = 98, + Shyvana = 102, + Singed = 27, + Sion = 14, + Sivir = 15, + Skarner = 72, + Sona = 37, + Soraka = 16, + Swain = 50, + Sylas = 517, + Syndra = 134, + TahmKench = 223, + Taliyah = 163, + Talon = 91, + Taric = 44, + Teemo = 17, + Thresh = 412, + Tristana = 18, + Trundle = 48, + Tryndamere = 23, + TwistedFate = 4, + Twitch = 29, + Udyr = 77, + Urgot = 6, + Varus = 110, + Vayne = 67, + Veigar = 45, + VelKoz = 161, + Vi = 254, + Viktor = 112, + Vladimir = 8, + Volibear = 106, + Warwick = 19, + Wukong = 62, + Xayah = 498, + Xerath = 101, + XinZhao = 5, + Yasuo = 157, + Yorick = 83, + Yuumi = 350, + Zac = 154, + Zed = 238, + Ziggs = 115, + Zilean = 26, + Zoe = 142, + Zyra = 143, + } + +impl Champion { + pub fn name(self) -> &'static str { + match self { + Self::Aatrox => "Aatrox", + Self::Ahri => "Ahri", + Self::Akali => "Akali", + Self::Alistar => "Alistar", + Self::Amumu => "Amumu", + Self::Anivia => "Anivia", + Self::Annie => "Annie", + Self::Ashe => "Ashe", + Self::AurelionSol => "Aurelion Sol", + Self::Azir => "Azir", + Self::Bard => "Bard", + Self::Blitzcrank => "Blitzcrank", + Self::Brand => "Brand", + Self::Braum => "Braum", + Self::Caitlyn => "Caitlyn", + Self::Camille => "Camille", + Self::Cassiopeia => "Cassiopeia", + Self::ChoGath => "Cho'Gath", + Self::Corki => "Corki", + Self::Darius => "Darius", + Self::Diana => "Diana", + Self::DrMundo => "Dr. Mundo", + Self::Draven => "Draven", + Self::Ekko => "Ekko", + Self::Elise => "Elise", + Self::Evelynn => "Evelynn", + Self::Ezreal => "Ezreal", + Self::Fiddlesticks => "Fiddlesticks", + Self::Fiora => "Fiora", + Self::Fizz => "Fizz", + Self::Galio => "Galio", + Self::Gangplank => "Gangplank", + Self::Garen => "Garen", + Self::Gnar => "Gnar", + Self::Gragas => "Gragas", + Self::Graves => "Graves", + Self::Hecarim => "Hecarim", + Self::Heimerdinger => "Heimerdinger", + Self::Illaoi => "Illaoi", + Self::Irelia => "Irelia", + Self::Ivern => "Ivern", + Self::Janna => "Janna", + Self::JarvanIV => "Jarvan IV", + Self::Jax => "Jax", + Self::Jayce => "Jayce", + Self::Jhin => "Jhin", + Self::Jinx => "Jinx", + Self::KaiSa => "Kai'Sa", + Self::Kalista => "Kalista", + Self::Karma => "Karma", + Self::Karthus => "Karthus", + Self::Kassadin => "Kassadin", + Self::Katarina => "Katarina", + Self::Kayle => "Kayle", + Self::Kayn => "Kayn", + Self::Kennen => "Kennen", + Self::KhaZix => "Kha'Zix", + Self::Kindred => "Kindred", + Self::Kled => "Kled", + Self::KogMaw => "Kog'Maw", + Self::LeBlanc => "LeBlanc", + Self::LeeSin => "Lee Sin", + Self::Leona => "Leona", + Self::Lissandra => "Lissandra", + Self::Lucian => "Lucian", + Self::Lulu => "Lulu", + Self::Lux => "Lux", + Self::Malphite => "Malphite", + Self::Malzahar => "Malzahar", + Self::Maokai => "Maokai", + Self::MasterYi => "Master Yi", + Self::MissFortune => "Miss Fortune", + Self::Mordekaiser => "Mordekaiser", + Self::Morgana => "Morgana", + Self::Nami => "Nami", + Self::Nasus => "Nasus", + Self::Nautilus => "Nautilus", + Self::Neeko => "Neeko", + Self::Nidalee => "Nidalee", + Self::Nocturne => "Nocturne", + Self::NunuWillump => "Nunu & Willump", + Self::Olaf => "Olaf", + Self::Orianna => "Orianna", + Self::Ornn => "Ornn", + Self::Pantheon => "Pantheon", + Self::Poppy => "Poppy", + Self::Pyke => "Pyke", + Self::Qiyana => "Qiyana", + Self::Quinn => "Quinn", + Self::Rakan => "Rakan", + Self::Rammus => "Rammus", + Self::RekSai => "Rek'Sai", + Self::Renekton => "Renekton", + Self::Rengar => "Rengar", + Self::Riven => "Riven", + Self::Rumble => "Rumble", + Self::Ryze => "Ryze", + Self::Sejuani => "Sejuani", + Self::Shaco => "Shaco", + Self::Shen => "Shen", + Self::Shyvana => "Shyvana", + Self::Singed => "Singed", + Self::Sion => "Sion", + Self::Sivir => "Sivir", + Self::Skarner => "Skarner", + Self::Sona => "Sona", + Self::Soraka => "Soraka", + Self::Swain => "Swain", + Self::Sylas => "Sylas", + Self::Syndra => "Syndra", + Self::TahmKench => "Tahm Kench", + Self::Taliyah => "Taliyah", + Self::Talon => "Talon", + Self::Taric => "Taric", + Self::Teemo => "Teemo", + Self::Thresh => "Thresh", + Self::Tristana => "Tristana", + Self::Trundle => "Trundle", + Self::Tryndamere => "Tryndamere", + Self::TwistedFate => "Twisted Fate", + Self::Twitch => "Twitch", + Self::Udyr => "Udyr", + Self::Urgot => "Urgot", + Self::Varus => "Varus", + Self::Vayne => "Vayne", + Self::Veigar => "Veigar", + Self::VelKoz => "Vel'Koz", + Self::Vi => "Vi", + Self::Viktor => "Viktor", + Self::Vladimir => "Vladimir", + Self::Volibear => "Volibear", + Self::Warwick => "Warwick", + Self::Wukong => "Wukong", + Self::Xayah => "Xayah", + Self::Xerath => "Xerath", + Self::XinZhao => "Xin Zhao", + Self::Yasuo => "Yasuo", + Self::Yorick => "Yorick", + Self::Yuumi => "Yuumi", + Self::Zac => "Zac", + Self::Zed => "Zed", + Self::Ziggs => "Ziggs", + Self::Zilean => "Zilean", + Self::Zoe => "Zoe", + Self::Zyra => "Zyra", + } + } + + pub fn identifier(self) -> &'static str { + match self { + Self::Aatrox => "Aatrox", + Self::Ahri => "Ahri", + Self::Akali => "Akali", + Self::Alistar => "Alistar", + Self::Amumu => "Amumu", + Self::Anivia => "Anivia", + Self::Annie => "Annie", + Self::Ashe => "Ashe", + Self::AurelionSol => "AurelionSol", + Self::Azir => "Azir", + Self::Bard => "Bard", + Self::Blitzcrank => "Blitzcrank", + Self::Brand => "Brand", + Self::Braum => "Braum", + Self::Caitlyn => "Caitlyn", + Self::Camille => "Camille", + Self::Cassiopeia => "Cassiopeia", + Self::ChoGath => "Chogath", + Self::Corki => "Corki", + Self::Darius => "Darius", + Self::Diana => "Diana", + Self::DrMundo => "DrMundo", + Self::Draven => "Draven", + Self::Ekko => "Ekko", + Self::Elise => "Elise", + Self::Evelynn => "Evelynn", + Self::Ezreal => "Ezreal", + Self::Fiddlesticks => "FiddleSticks", + Self::Fiora => "Fiora", + Self::Fizz => "Fizz", + Self::Galio => "Galio", + Self::Gangplank => "Gangplank", + Self::Garen => "Garen", + Self::Gnar => "Gnar", + Self::Gragas => "Gragas", + Self::Graves => "Graves", + Self::Hecarim => "Hecarim", + Self::Heimerdinger => "Heimerdinger", + Self::Illaoi => "Illaoi", + Self::Irelia => "Irelia", + Self::Ivern => "Ivern", + Self::Janna => "Janna", + Self::JarvanIV => "JarvanIV", + Self::Jax => "Jax", + Self::Jayce => "Jayce", + Self::Jhin => "Jhin", + Self::Jinx => "Jinx", + Self::KaiSa => "Kaisa", + Self::Kalista => "Kalista", + Self::Karma => "Karma", + Self::Karthus => "Karthus", + Self::Kassadin => "Kassadin", + Self::Katarina => "Katarina", + Self::Kayle => "Kayle", + Self::Kayn => "Kayn", + Self::Kennen => "Kennen", + Self::KhaZix => "Khazix", + Self::Kindred => "Kindred", + Self::Kled => "Kled", + Self::KogMaw => "KogMaw", + Self::LeBlanc => "Leblanc", + Self::LeeSin => "LeeSin", + Self::Leona => "Leona", + Self::Lissandra => "Lissandra", + Self::Lucian => "Lucian", + Self::Lulu => "Lulu", + Self::Lux => "Lux", + Self::Malphite => "Malphite", + Self::Malzahar => "Malzahar", + Self::Maokai => "Maokai", + Self::MasterYi => "MasterYi", + Self::MissFortune => "MissFortune", + Self::Mordekaiser => "Mordekaiser", + Self::Morgana => "Morgana", + Self::Nami => "Nami", + Self::Nasus => "Nasus", + Self::Nautilus => "Nautilus", + Self::Neeko => "Neeko", + Self::Nidalee => "Nidalee", + Self::Nocturne => "Nocturne", + Self::NunuWillump => "Nunu", + Self::Olaf => "Olaf", + Self::Orianna => "Orianna", + Self::Ornn => "Ornn", + Self::Pantheon => "Pantheon", + Self::Poppy => "Poppy", + Self::Pyke => "Pyke", + Self::Qiyana => "Qiyana", + Self::Quinn => "Quinn", + Self::Rakan => "Rakan", + Self::Rammus => "Rammus", + Self::RekSai => "RekSai", + Self::Renekton => "Renekton", + Self::Rengar => "Rengar", + Self::Riven => "Riven", + Self::Rumble => "Rumble", + Self::Ryze => "Ryze", + Self::Sejuani => "Sejuani", + Self::Shaco => "Shaco", + Self::Shen => "Shen", + Self::Shyvana => "Shyvana", + Self::Singed => "Singed", + Self::Sion => "Sion", + Self::Sivir => "Sivir", + Self::Skarner => "Skarner", + Self::Sona => "Sona", + Self::Soraka => "Soraka", + Self::Swain => "Swain", + Self::Sylas => "Sylas", + Self::Syndra => "Syndra", + Self::TahmKench => "TahmKench", + Self::Taliyah => "Taliyah", + Self::Talon => "Talon", + Self::Taric => "Taric", + Self::Teemo => "Teemo", + Self::Thresh => "Thresh", + Self::Tristana => "Tristana", + Self::Trundle => "Trundle", + Self::Tryndamere => "Tryndamere", + Self::TwistedFate => "TwistedFate", + Self::Twitch => "Twitch", + Self::Udyr => "Udyr", + Self::Urgot => "Urgot", + Self::Varus => "Varus", + Self::Vayne => "Vayne", + Self::Veigar => "Veigar", + Self::VelKoz => "Velkoz", + Self::Vi => "Vi", + Self::Viktor => "Viktor", + Self::Vladimir => "Vladimir", + Self::Volibear => "Volibear", + Self::Warwick => "Warwick", + Self::Wukong => "MonkeyKing", + Self::Xayah => "Xayah", + Self::Xerath => "Xerath", + Self::XinZhao => "XinZhao", + Self::Yasuo => "Yasuo", + Self::Yorick => "Yorick", + Self::Yuumi => "Yuumi", + Self::Zac => "Zac", + Self::Zed => "Zed", + Self::Ziggs => "Ziggs", + Self::Zilean => "Zilean", + Self::Zoe => "Zoe", + Self::Zyra => "Zyra", + } + } +} + +impl std::str::FromStr for Champion { + type Err = (); + + fn from_str(val: &str) -> Result { + // 4 characters encoded as an int. + match val.chars() + .filter(|c| c.is_ascii_alphabetic()) + .take(4) + .map(|c| c.to_ascii_uppercase() as u32) + .fold(0u32, |hash, next| hash * 256 + next) + { + 1094800466 /* AATR */ => Ok(Self::Aatrox), + 1095258697 /* AHRI */ => Ok(Self::Ahri), + 1095450956 /* AKAL */ => Ok(Self::Akali), + 1095518547 /* ALIS */ => Ok(Self::Alistar), + 1095587149 /* AMUM */ => Ok(Self::Amumu), + 1095649622 /* ANIV */ => Ok(Self::Anivia), + 1095650889 /* ANNI */ => Ok(Self::Annie), + 1095977029 /* ASHE */ => Ok(Self::Ashe), + 1096110661 /* AURE */ => Ok(Self::AurelionSol), + 1096436050 /* AZIR */ => Ok(Self::Azir), + 1111577156 /* BARD */ => Ok(Self::Bard), + 1112295764 /* BLIT */ => Ok(Self::Blitzcrank), + 1112686926 /* BRAN */ => Ok(Self::Brand), + 1112686933 /* BRAU */ => Ok(Self::Braum), + 1128352084 /* CAIT */ => Ok(Self::Caitlyn), + 1128353097 /* CAMI */ => Ok(Self::Camille), + 1128354643 /* CASS */ => Ok(Self::Cassiopeia), + 1128812359 /* CHOG */ => Ok(Self::ChoGath), + 4409423 /* CHO */ => Ok(Self::ChoGath), + 1129271883 /* CORK */ => Ok(Self::Corki), + 1145131593 /* DARI */ => Ok(Self::Darius), + 1145651534 /* DIAN */ => Ok(Self::Diana), + 1146244437 /* DRMU */ => Ok(Self::DrMundo), + 17490 /* DR */ => Ok(Self::DrMundo), + 1146241366 /* DRAV */ => Ok(Self::Draven), + 1162562383 /* EKKO */ => Ok(Self::Ekko), + 1162627411 /* ELIS */ => Ok(Self::Elise), + 1163281740 /* EVEL */ => Ok(Self::Evelynn), + 1163547205 /* EZRE */ => Ok(Self::Ezreal), + 1179206724 /* FIDD */ => Ok(Self::Fiddlesticks), + 1179209554 /* FIOR */ => Ok(Self::Fiora), + 1179212378 /* FIZZ */ => Ok(Self::Fizz), + 1195461705 /* GALI */ => Ok(Self::Galio), + 1195462215 /* GANG */ => Ok(Self::Gangplank), + 1195463237 /* GARE */ => Ok(Self::Garen), + 1196310866 /* GNAR */ => Ok(Self::Gnar), + 1196572999 /* GRAG */ => Ok(Self::Gragas), + 1196573014 /* GRAV */ => Ok(Self::Graves), + 1212498753 /* HECA */ => Ok(Self::Hecarim), + 1212500301 /* HEIM */ => Ok(Self::Heimerdinger), + 1229737025 /* ILLA */ => Ok(Self::Illaoi), + 1230128460 /* IREL */ => Ok(Self::Irelia), + 1230390610 /* IVER */ => Ok(Self::Ivern), + 1245793870 /* JANN */ => Ok(Self::Janna), + 1245794902 /* JARV */ => Ok(Self::JarvanIV), + 4866392 /* JAX */ => Ok(Self::Jax), + 1245796675 /* JAYC */ => Ok(Self::Jayce), + 1246251342 /* JHIN */ => Ok(Self::Jhin), + 1246318168 /* JINX */ => Ok(Self::Jinx), + 1262569811 /* KAIS */ => Ok(Self::KaiSa), + 4931913 /* KAI */ => Ok(Self::KaiSa), + 1262570569 /* KALI */ => Ok(Self::Kalista), + 1262572109 /* KARM */ => Ok(Self::Karma), + 1262572116 /* KART */ => Ok(Self::Karthus), + 1262572371 /* KASS */ => Ok(Self::Kassadin), + 1262572609 /* KATA */ => Ok(Self::Katarina), + 1262573900 /* KAYL */ => Ok(Self::Kayle), + 1262573902 /* KAYN */ => Ok(Self::Kayn), + 1262833230 /* KENN */ => Ok(Self::Kennen), + 1263026522 /* KHAZ */ => Ok(Self::KhaZix), + 4933697 /* KHA */ => Ok(Self::KhaZix), + 1263095364 /* KIND */ => Ok(Self::Kindred), + 1263289668 /* KLED */ => Ok(Self::Kled), + 1263486797 /* KOGM */ => Ok(Self::KogMaw), + 4935495 /* KOG */ => Ok(Self::KogMaw), + 1279607372 /* LEBL */ => Ok(Self::LeBlanc), + 1279608147 /* LEES */ => Ok(Self::LeeSin), + 4998469 /* LEE */ => Ok(Self::LeeSin), + 1279610702 /* LEON */ => Ok(Self::Leona), + 1279873875 /* LISS */ => Ok(Self::Lissandra), + 1280656201 /* LUCI */ => Ok(Self::Lucian), + 1280658517 /* LULU */ => Ok(Self::Lulu), + 5002584 /* LUX */ => Ok(Self::Lux), + 1296125008 /* MALP */ => Ok(Self::Malphite), + 1296125018 /* MALZ */ => Ok(Self::Malzahar), + 1296125771 /* MAOK */ => Ok(Self::Maokai), + 1296126804 /* MAST */ => Ok(Self::MasterYi), + 1296651091 /* MISS */ => Ok(Self::MissFortune), + 1297044036 /* MORD */ => Ok(Self::Mordekaiser), + 1297044039 /* MORG */ => Ok(Self::Morgana), + 1312902473 /* NAMI */ => Ok(Self::Nami), + 1312904021 /* NASU */ => Ok(Self::Nasus), + 1312904532 /* NAUT */ => Ok(Self::Nautilus), + 1313162571 /* NEEK */ => Ok(Self::Neeko), + 1313424449 /* NIDA */ => Ok(Self::Nidalee), + 1313817428 /* NOCT */ => Ok(Self::Nocturne), + 1314213461 /* NUNU */ => Ok(Self::NunuWillump), + 1330397510 /* OLAF */ => Ok(Self::Olaf), + 1330792769 /* ORIA */ => Ok(Self::Orianna), + 1330794062 /* ORNN */ => Ok(Self::Ornn), + 1346457172 /* PANT */ => Ok(Self::Pantheon), + 1347375184 /* POPP */ => Ok(Self::Poppy), + 1348029253 /* PYKE */ => Ok(Self::Pyke), + 1363761473 /* QIYA */ => Ok(Self::Qiyana), + 1364543822 /* QUIN */ => Ok(Self::Quinn), + 1380010817 /* RAKA */ => Ok(Self::Rakan), + 1380011341 /* RAMM */ => Ok(Self::Rammus), + 1380272979 /* REKS */ => Ok(Self::RekSai), + 5391691 /* REK */ => Ok(Self::RekSai), + 1380273733 /* RENE */ => Ok(Self::Renekton), + 1380273735 /* RENG */ => Ok(Self::Rengar), + 1380537925 /* RIVE */ => Ok(Self::Riven), + 1381322050 /* RUMB */ => Ok(Self::Rumble), + 1381587525 /* RYZE */ => Ok(Self::Ryze), + 1397049941 /* SEJU */ => Ok(Self::Sejuani), + 1397244227 /* SHAC */ => Ok(Self::Shaco), + 1397245262 /* SHEN */ => Ok(Self::Shen), + 1397250390 /* SHYV */ => Ok(Self::Shyvana), + 1397313095 /* SING */ => Ok(Self::Singed), + 1397313358 /* SION */ => Ok(Self::Sion), + 1397315145 /* SIVI */ => Ok(Self::Sivir), + 1397440850 /* SKAR */ => Ok(Self::Skarner), + 1397706305 /* SONA */ => Ok(Self::Sona), + 1397707329 /* SORA */ => Ok(Self::Soraka), + 1398227273 /* SWAI */ => Ok(Self::Swain), + 1398361153 /* SYLA */ => Ok(Self::Sylas), + 1398361668 /* SYND */ => Ok(Self::Syndra), + 1413564493 /* TAHM */ => Ok(Self::TahmKench), + 1413565513 /* TALI */ => Ok(Self::Taliyah), + 1413565519 /* TALO */ => Ok(Self::Talon), + 1413567049 /* TARI */ => Ok(Self::Taric), + 1413825869 /* TEEM */ => Ok(Self::Teemo), + 1414025797 /* THRE */ => Ok(Self::Thresh), + 1414678867 /* TRIS */ => Ok(Self::Tristana), + 1414681934 /* TRUN */ => Ok(Self::Trundle), + 1414682958 /* TRYN */ => Ok(Self::Tryndamere), + 1415006547 /* TWIS */ => Ok(Self::TwistedFate), + 1415006548 /* TWIT */ => Ok(Self::Twitch), + 1430542674 /* UDYR */ => Ok(Self::Udyr), + 1431455567 /* URGO */ => Ok(Self::Urgot), + 1447121493 /* VARU */ => Ok(Self::Varus), + 1447123278 /* VAYN */ => Ok(Self::Vayne), + 1447381319 /* VEIG */ => Ok(Self::Veigar), + 1447382091 /* VELK */ => Ok(Self::VelKoz), + 5653836 /* VEL */ => Ok(Self::VelKoz), + 22089 /* VI */ => Ok(Self::Vi), + 1447643988 /* VIKT */ => Ok(Self::Viktor), + 1447838020 /* VLAD */ => Ok(Self::Vladimir), + 1448037449 /* VOLI */ => Ok(Self::Volibear), + 1463898711 /* WARW */ => Ok(Self::Warwick), + 1465207631 /* WUKO */ => Ok(Self::Wukong), + 1297043019 /* MONK */ => Ok(Self::Wukong), + 1480677697 /* XAYA */ => Ok(Self::Xayah), + 1480938049 /* XERA */ => Ok(Self::Xerath), + 1481199194 /* XINZ */ => Ok(Self::XinZhao), + 5785934 /* XIN */ => Ok(Self::XinZhao), + 1497453397 /* YASU */ => Ok(Self::Yasuo), + 1498370633 /* YORI */ => Ok(Self::Yorick), + 1498764621 /* YUUM */ => Ok(Self::Yuumi), + 5914947 /* ZAC */ => Ok(Self::Zac), + 5915972 /* ZED */ => Ok(Self::Zed), + 1514751815 /* ZIGG */ => Ok(Self::Ziggs), + 1514753093 /* ZILE */ => Ok(Self::Zilean), + 5918533 /* ZOE */ => Ok(Self::Zoe), + 1515803201 /* ZYRA */ => Ok(Self::Zyra), + _ => Err(()), + } + } +} + +impl fmt::Display for Champion { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "{:?}", self) + } +} diff --git a/srcgen/dotUtils.js b/srcgen/dotUtils.js index b56c993..d35de49 100644 --- a/srcgen/dotUtils.js +++ b/srcgen/dotUtils.js @@ -1,3 +1,5 @@ +const changeCase = require('change-case'); + // flatMap: https://gist.github.com/samgiles/762ee337dff48623e729 // [B](f: (A) ⇒ [B]): [B] ; Although the types in the arrays aren't strict (: Array.prototype.flatMap = function(lambda) { @@ -19,87 +21,104 @@ function decapitalize(input) { return input[0].toLowerCase() + input.slice(1); } -function normalizeEndpointName(name) { - return name.split('-') - .join('_'); -} - function normalizeSchemaName(name) { return name.replace(/DTO/ig, ''); } function normalizeArgName(name) { - var tokens = name.split('_'); - var argName = decapitalize(tokens.map(capitalize).join('')); + const tokens = name.split('_'); + const argName = decapitalize(tokens.map(capitalize).join('')); return 'base' === argName ? 'Base' : argName; } function normalizePropName(propName, schemaName, value) { - var tokens = propName.split('_'); - var name = tokens.map(capitalize).join(''); - if (name === schemaName) - name += stringifyType(value); - return name; + const out = changeCase.snakeCase(propName); + if ('type' === out) + return 'r#' + out; + return out; + // return propName; + // var tokens = propName.split('_'); + // var name = tokens.map(capitalize).join(''); + // if (name === schemaName) + // name += stringifyType(value); + // return name; } -function stringifyType(prop, endpoint = null, nullable = false) { +function stringifyType(prop, endpoint = null, optional = false, fullpath = true, owned = true) { if (prop.anyOf) { prop = prop.anyOf[0]; } let refType = prop['$ref']; if (refType) { - return (!endpoint ? '' : endpoint + '.') + + return (!endpoint ? '' : 'crate::' + changeCase.snakeCase(endpoint) + '::') + normalizeSchemaName(refType.slice(refType.indexOf('.') + 1)); } - var qm = nullable ? '?' : ''; + if (optional) { + return `Option<${stringifyType(prop, endpoint, false, fullpath)}>`; + } switch (prop.type) { - case 'boolean': return 'bool' + qm; - case 'integer': return ('int32' === prop.format ? 'int' : 'long') + qm; - case 'number': return prop.format + qm; - case 'array': return stringifyType(prop.items, endpoint) + '[]' + qm; + case 'boolean': return 'bool'; + case 'integer': return ('int32' === prop.format ? 'i32' : 'i64'); + case 'number': return ('float' === prop.format ? 'f32' : 'f64'); + case 'array': + const subprop = stringifyType(prop.items, endpoint, optional, fullpath, owned); + return (owned ? (fullpath ? 'std::vec::' : '') + `Vec<${subprop}>` : `&[${subprop}]`); + case 'string': return (owned ? 'String' : '&str'); case 'object': - return 'IDictionary<' + stringifyType(prop['x-key'], endpoint) + ', ' + - stringifyType(prop.additionalProperties, endpoint) + '>' + qm; - default: return prop.type + qm; + return 'std::collections::HashMap<' + stringifyType(prop['x-key'], endpoint, optional, fullpath, owned) + ', ' + + stringifyType(prop.additionalProperties, endpoint, optional, fullpath, owned) + '>'; + default: return prop.type; } } function formatJsonProperty(name) { - return `[JsonProperty(\"${name}\")]`; + return `#[serde(rename = "${name}")]`; } -function formatQueryParamStringify(prop) { +function formatQueryParamStringify(name, prop, ownedOk = false) { switch (prop.type) { - case 'boolean': return '.ToString().ToLowerInvariant()'; - case 'string': return ''; - default: return '.ToString()'; + case 'boolean': return `${name} ? "true" : "false"`; + case 'string': return name; + default: return (ownedOk ? '' : '&*') + `${name}.to_string()`; } } function formatAddQueryParam(param) { - let k = `nameof(${param.name})`; - let nc = param.required ? '' : `if (null != ${param.name}) `; + let k = `"${param.name}"`; + let name = changeCase.snakeCase(param.name); + let nc = param.required ? '' : `if let Some(${name}) = ${name} `; let prop = param.schema; switch (prop.type) { - case 'array': return `${nc}queryParams.AddRange(${param.name}.Select(` - + `w => new KeyValuePair(${k}, w${formatQueryParamStringify(prop.items)})))`; + case 'array': return `${nc}{ query_params.extend_pairs(${name}.iter()` + + `.map(|w| (${k}, ${formatQueryParamStringify("w", prop, true)}))); }`; case 'object': throw 'unsupported'; default: - let vnc = param.required ? '' : '.Value'; - return `${nc}queryParams.Add(new KeyValuePair(${k}, ` - + `${param.name}${vnc}${formatQueryParamStringify(prop.type)}))`; + return `${nc}{ query_params.append_pair(${k}, ${formatQueryParamStringify(name, prop)}); }`; } } +function formatRouteArgument(route, pathParams = []) { + if (!pathParams.length) + return `"${route}"`; + + route = route.replace(/\{\S+?\}/g, '{}'); + const args = pathParams + .map(({name}) => name) + .map(changeCase.snakeCase) + .join(', '); + return `format!("${route}", ${args})`; +} + module.exports = { + changeCase, capitalize, decapitalize, - normalizeEndpointName, normalizeSchemaName, normalizeArgName, normalizePropName, stringifyType, formatJsonProperty, - formatAddQueryParam + formatAddQueryParam, + formatRouteArgument, }; \ No newline at end of file diff --git a/srcgen/dto.rs b/srcgen/dto.rs new file mode 100644 index 0000000..f7ba64c --- /dev/null +++ b/srcgen/dto.rs @@ -0,0 +1,1366 @@ + +// This file is automatically generated. +// Do not directly edit. +// Generated on 2019-10-20T06:19:43.812Z + +// http://www.mingweisamuel.com/riotapi-schema/tool/ +// Version 0c74167e0eaaeb6de1c7e8219fecaabcf8386d1f + +// champion-mastery-v4 +#[allow(dead_code)] +pub mod champion_mastery_v4 { + /// ChampionMastery data object. This class is automatically generated. + /// # Description + /// This object contains single Champion Mastery information for player and champion combination. + #[derive(Debug)] + #[derive(serde::Serialize, serde::Deserialize)] + pub struct ChampionMastery { + /// Is chest granted for this champion or not in current season. + #[serde(rename = "chestGranted")] + pub chest_granted: bool, + /// Champion level for specified player and champion combination. + #[serde(rename = "championLevel")] + pub champion_level: i32, + /// Total number of champion points for this player and champion combination - they are used to determine championLevel. + #[serde(rename = "championPoints")] + pub champion_points: i32, + /// Champion ID for this entry. + #[serde(rename = "championId")] + pub champion_id: i64, + /// Number of points needed to achieve next level. Zero if player reached maximum champion level for this champion. + #[serde(rename = "championPointsUntilNextLevel")] + pub champion_points_until_next_level: i64, + /// Last time this champion was played by this player - in Unix milliseconds time format. + #[serde(rename = "lastPlayTime")] + pub last_play_time: i64, + /// The token earned for this champion to levelup. + #[serde(rename = "tokensEarned")] + pub tokens_earned: i32, + /// Number of points earned since current level has been achieved. + #[serde(rename = "championPointsSinceLastLevel")] + pub champion_points_since_last_level: i64, + /// Summoner ID for this entry. (Encrypted) + #[serde(rename = "summonerId")] + pub summoner_id: String, + } +} + +// champion-v3 +#[allow(dead_code)] +pub mod champion_v3 { + /// ChampionInfo data object. This class is automatically generated. + #[derive(Debug)] + #[derive(serde::Serialize, serde::Deserialize)] + pub struct ChampionInfo { + #[serde(rename = "freeChampionIdsForNewPlayers")] + pub free_champion_ids_for_new_players: std::vec::Vec, + #[serde(rename = "freeChampionIds")] + pub free_champion_ids: std::vec::Vec, + #[serde(rename = "maxNewPlayerLevel")] + pub max_new_player_level: i32, + } +} + +// league-exp-v4 +#[allow(dead_code)] +pub mod league_exp_v4 { + /// LeagueEntry data object. This class is automatically generated. + #[derive(Debug)] + #[derive(serde::Serialize, serde::Deserialize)] + pub struct LeagueEntry { + #[serde(rename = "queueType")] + pub queue_type: String, + #[serde(rename = "summonerName")] + pub summoner_name: String, + #[serde(rename = "hotStreak")] + pub hot_streak: bool, + #[serde(rename = "miniSeries")] + pub mini_series: MiniSeries, + /// Winning team on Summoners Rift. First placement in Teamfight Tactics. + #[serde(rename = "wins")] + pub wins: i32, + #[serde(rename = "veteran")] + pub veteran: bool, + /// Losing team on Summoners Rift. Second through eighth placement in Teamfight Tactics. + #[serde(rename = "losses")] + pub losses: i32, + #[serde(rename = "rank")] + pub rank: String, + #[serde(rename = "leagueId")] + pub league_id: String, + #[serde(rename = "inactive")] + pub inactive: bool, + #[serde(rename = "freshBlood")] + pub fresh_blood: bool, + #[serde(rename = "tier")] + pub tier: String, + /// Player's summonerId (Encrypted) + #[serde(rename = "summonerId")] + pub summoner_id: String, + #[serde(rename = "leaguePoints")] + pub league_points: i32, + } + /// MiniSeries data object. This class is automatically generated. + #[derive(Debug)] + #[derive(serde::Serialize, serde::Deserialize)] + pub struct MiniSeries { + #[serde(rename = "progress")] + pub progress: String, + #[serde(rename = "losses")] + pub losses: i32, + #[serde(rename = "target")] + pub target: i32, + #[serde(rename = "wins")] + pub wins: i32, + } +} + +// league-v4 +#[allow(dead_code)] +pub mod league_v4 { + /// LeagueList data object. This class is automatically generated. + #[derive(Debug)] + #[derive(serde::Serialize, serde::Deserialize)] + pub struct LeagueList { + #[serde(rename = "leagueId")] + pub league_id: String, + #[serde(rename = "tier")] + pub tier: String, + #[serde(rename = "entries")] + pub entries: std::vec::Vec, + #[serde(rename = "queue")] + pub queue: String, + #[serde(rename = "name")] + pub name: String, + } + /// LeagueItem data object. This class is automatically generated. + #[derive(Debug)] + #[derive(serde::Serialize, serde::Deserialize)] + pub struct LeagueItem { + #[serde(rename = "summonerName")] + pub summoner_name: String, + #[serde(rename = "hotStreak")] + pub hot_streak: bool, + #[serde(rename = "miniSeries")] + pub mini_series: MiniSeries, + /// Winning team on Summoners Rift. First placement in Teamfight Tactics. + #[serde(rename = "wins")] + pub wins: i32, + #[serde(rename = "veteran")] + pub veteran: bool, + /// Losing team on Summoners Rift. Second through eighth placement in Teamfight Tactics. + #[serde(rename = "losses")] + pub losses: i32, + #[serde(rename = "freshBlood")] + pub fresh_blood: bool, + #[serde(rename = "inactive")] + pub inactive: bool, + #[serde(rename = "rank")] + pub rank: String, + /// Player's summonerId (Encrypted) + #[serde(rename = "summonerId")] + pub summoner_id: String, + #[serde(rename = "leaguePoints")] + pub league_points: i32, + } + /// MiniSeries data object. This class is automatically generated. + #[derive(Debug)] + #[derive(serde::Serialize, serde::Deserialize)] + pub struct MiniSeries { + #[serde(rename = "progress")] + pub progress: String, + #[serde(rename = "losses")] + pub losses: i32, + #[serde(rename = "target")] + pub target: i32, + #[serde(rename = "wins")] + pub wins: i32, + } + /// LeagueEntry data object. This class is automatically generated. + #[derive(Debug)] + #[derive(serde::Serialize, serde::Deserialize)] + pub struct LeagueEntry { + #[serde(rename = "queueType")] + pub queue_type: String, + #[serde(rename = "summonerName")] + pub summoner_name: String, + #[serde(rename = "hotStreak")] + pub hot_streak: bool, + #[serde(rename = "miniSeries")] + pub mini_series: MiniSeries, + /// Winning team on Summoners Rift. First placement in Teamfight Tactics. + #[serde(rename = "wins")] + pub wins: i32, + #[serde(rename = "veteran")] + pub veteran: bool, + /// Losing team on Summoners Rift. Second through eighth placement in Teamfight Tactics. + #[serde(rename = "losses")] + pub losses: i32, + #[serde(rename = "rank")] + pub rank: String, + #[serde(rename = "leagueId")] + pub league_id: String, + #[serde(rename = "inactive")] + pub inactive: bool, + #[serde(rename = "freshBlood")] + pub fresh_blood: bool, + #[serde(rename = "tier")] + pub tier: String, + /// Player's summonerId (Encrypted) + #[serde(rename = "summonerId")] + pub summoner_id: String, + #[serde(rename = "leaguePoints")] + pub league_points: i32, + } +} + +// lol-status-v3 +#[allow(dead_code)] +pub mod lol_status_v3 { + /// ShardStatus data object. This class is automatically generated. + #[derive(Debug)] + #[derive(serde::Serialize, serde::Deserialize)] + pub struct ShardStatus { + #[serde(rename = "name")] + pub name: String, + #[serde(rename = "region_tag")] + pub region_tag: String, + #[serde(rename = "hostname")] + pub hostname: String, + #[serde(rename = "services")] + pub services: std::vec::Vec, + #[serde(rename = "slug")] + pub slug: String, + #[serde(rename = "locales")] + pub locales: std::vec::Vec, + } + /// Service data object. This class is automatically generated. + #[derive(Debug)] + #[derive(serde::Serialize, serde::Deserialize)] + pub struct Service { + #[serde(rename = "status")] + pub status: String, + #[serde(rename = "incidents")] + pub incidents: std::vec::Vec, + #[serde(rename = "name")] + pub name: String, + #[serde(rename = "slug")] + pub slug: String, + } + /// Incident data object. This class is automatically generated. + #[derive(Debug)] + #[derive(serde::Serialize, serde::Deserialize)] + pub struct Incident { + #[serde(rename = "active")] + pub active: bool, + #[serde(rename = "created_at")] + pub created_at: String, + #[serde(rename = "id")] + pub id: i64, + #[serde(rename = "updates")] + pub updates: std::vec::Vec, + } + /// Message data object. This class is automatically generated. + #[derive(Debug)] + #[derive(serde::Serialize, serde::Deserialize)] + pub struct Message { + #[serde(rename = "severity")] + pub severity: String, + #[serde(rename = "author")] + pub author: String, + #[serde(rename = "created_at")] + pub created_at: String, + #[serde(rename = "translations")] + pub translations: std::vec::Vec, + #[serde(rename = "updated_at")] + pub updated_at: String, + #[serde(rename = "content")] + pub content: String, + #[serde(rename = "id")] + pub id: String, + } + /// Translation data object. This class is automatically generated. + #[derive(Debug)] + #[derive(serde::Serialize, serde::Deserialize)] + pub struct Translation { + #[serde(rename = "locale")] + pub locale: String, + #[serde(rename = "content")] + pub content: String, + #[serde(rename = "heading")] + pub heading: String, + } +} + +// match-v4 +#[allow(dead_code)] +pub mod match_v4 { + /// Match data object. This class is automatically generated. + #[derive(Debug)] + #[derive(serde::Serialize, serde::Deserialize)] + pub struct Match { + /// Please refer to the Game Constants documentation. + #[serde(rename = "seasonId")] + pub season_id: i32, + /// Please refer to the Game Constants documentation. + #[serde(rename = "queueId")] + pub queue_id: i32, + #[serde(rename = "gameId")] + pub game_id: i64, + /// Participant identity information. + #[serde(rename = "participantIdentities")] + pub participant_identities: std::vec::Vec, + /// The major.minor version typically indicates the patch the match was played on. + #[serde(rename = "gameVersion")] + pub game_version: String, + /// Platform where the match was played. + #[serde(rename = "platformId")] + pub platform_id: String, + /// Please refer to the Game Constants documentation. + #[serde(rename = "gameMode")] + pub game_mode: String, + /// Please refer to the Game Constants documentation. + #[serde(rename = "mapId")] + pub map_id: i32, + /// Please refer to the Game Constants documentation. + #[serde(rename = "gameType")] + pub game_type: String, + /// Team information. + #[serde(rename = "teams")] + pub teams: std::vec::Vec, + /// Participant information. + #[serde(rename = "participants")] + pub participants: std::vec::Vec, + /// Match duration in seconds. + #[serde(rename = "gameDuration")] + pub game_duration: i64, + /// Designates the timestamp when champion select ended and the loading screen appeared, NOT when the game timer was at 0:00. + #[serde(rename = "gameCreation")] + pub game_creation: i64, + } + /// ParticipantIdentity data object. This class is automatically generated. + #[derive(Debug)] + #[derive(serde::Serialize, serde::Deserialize)] + pub struct ParticipantIdentity { + /// Player information. + #[serde(rename = "player")] + pub player: Player, + #[serde(rename = "participantId")] + pub participant_id: i32, + } + /// Player data object. This class is automatically generated. + #[derive(Debug)] + #[derive(serde::Serialize, serde::Deserialize)] + pub struct Player { + #[serde(rename = "currentPlatformId")] + pub current_platform_id: String, + #[serde(rename = "summonerName")] + pub summoner_name: String, + #[serde(rename = "matchHistoryUri")] + pub match_history_uri: String, + /// Original platformId. + #[serde(rename = "platformId")] + pub platform_id: String, + /// Player's current accountId (Encrypted) + #[serde(rename = "currentAccountId")] + pub current_account_id: String, + #[serde(rename = "profileIcon")] + pub profile_icon: i32, + /// Player's summonerId (Encrypted) + #[serde(rename = "summonerId")] + pub summoner_id: String, + /// Player's original accountId (Encrypted) + #[serde(rename = "accountId")] + pub account_id: String, + } + /// TeamStats data object. This class is automatically generated. + #[derive(Debug)] + #[derive(serde::Serialize, serde::Deserialize)] + pub struct TeamStats { + /// Flag indicating whether or not the team scored the first Dragon kill. + #[serde(rename = "firstDragon")] + pub first_dragon: bool, + /// Flag indicating whether or not the team destroyed the first inhibitor. + #[serde(rename = "firstInhibitor")] + pub first_inhibitor: bool, + /// If match queueId has a draft, contains banned champion data, otherwise empty. + #[serde(rename = "bans")] + pub bans: std::vec::Vec, + /// Number of times the team killed Baron. + #[serde(rename = "baronKills")] + pub baron_kills: i32, + /// Flag indicating whether or not the team scored the first Rift Herald kill. + #[serde(rename = "firstRiftHerald")] + pub first_rift_herald: bool, + /// Flag indicating whether or not the team scored the first Baron kill. + #[serde(rename = "firstBaron")] + pub first_baron: bool, + /// Number of times the team killed Rift Herald. + #[serde(rename = "riftHeraldKills")] + pub rift_herald_kills: i32, + /// Flag indicating whether or not the team scored the first blood. + #[serde(rename = "firstBlood")] + pub first_blood: bool, + /// 100 for blue side. 200 for red side. + #[serde(rename = "teamId")] + pub team_id: i32, + /// Flag indicating whether or not the team destroyed the first tower. + #[serde(rename = "firstTower")] + pub first_tower: bool, + /// Number of times the team killed Vilemaw. + #[serde(rename = "vilemawKills")] + pub vilemaw_kills: i32, + /// Number of inhibitors the team destroyed. + #[serde(rename = "inhibitorKills")] + pub inhibitor_kills: i32, + /// Number of towers the team destroyed. + #[serde(rename = "towerKills")] + pub tower_kills: i32, + /// For Dominion matches, specifies the points the team had at game end. + #[serde(rename = "dominionVictoryScore")] + pub dominion_victory_score: i32, + /// String indicating whether or not the team won. There are only two values visibile in public match history. + /// (Legal values: Fail, Win) + #[serde(rename = "win")] + pub win: String, + /// Number of times the team killed Dragon. + #[serde(rename = "dragonKills")] + pub dragon_kills: i32, + } + /// TeamBans data object. This class is automatically generated. + #[derive(Debug)] + #[derive(serde::Serialize, serde::Deserialize)] + pub struct TeamBans { + /// Turn during which the champion was banned. + #[serde(rename = "pickTurn")] + pub pick_turn: i32, + /// Banned championId. + #[serde(rename = "championId")] + pub champion_id: i32, + } + /// Participant data object. This class is automatically generated. + #[derive(Debug)] + #[derive(serde::Serialize, serde::Deserialize)] + pub struct Participant { + /// Participant statistics. + #[serde(rename = "stats")] + pub stats: ParticipantStats, + #[serde(rename = "participantId")] + pub participant_id: i32, + /// List of legacy Rune information. Not included for matches played with Runes Reforged. + #[serde(rename = "runes")] + pub runes: std::vec::Vec, + /// Participant timeline data. + #[serde(rename = "timeline")] + pub timeline: ParticipantTimeline, + /// 100 for blue side. 200 for red side. + #[serde(rename = "teamId")] + pub team_id: i32, + /// Second Summoner Spell id. + #[serde(rename = "spell2Id")] + pub spell2_id: i32, + /// List of legacy Mastery information. Not included for matches played with Runes Reforged. + #[serde(rename = "masteries")] + pub masteries: std::vec::Vec, + /// Highest ranked tier achieved for the previous season in a specific subset of queueIds, if any, otherwise null. Used to display border in game loading screen. Please refer to the Ranked Info documentation. + /// (Legal values: CHALLENGER, MASTER, DIAMOND, PLATINUM, GOLD, SILVER, BRONZE, UNRANKED) + #[serde(rename = "highestAchievedSeasonTier")] + pub highest_achieved_season_tier: String, + /// First Summoner Spell id. + #[serde(rename = "spell1Id")] + pub spell1_id: i32, + #[serde(rename = "championId")] + pub champion_id: i32, + } + /// ParticipantStats data object. This class is automatically generated. + #[derive(Debug)] + #[derive(serde::Serialize, serde::Deserialize)] + pub struct ParticipantStats { + #[serde(rename = "firstBloodAssist")] + pub first_blood_assist: bool, + #[serde(rename = "visionScore")] + pub vision_score: i64, + #[serde(rename = "magicDamageDealtToChampions")] + pub magic_damage_dealt_to_champions: i64, + #[serde(rename = "damageDealtToObjectives")] + pub damage_dealt_to_objectives: i64, + #[serde(rename = "totalTimeCrowdControlDealt")] + pub total_time_crowd_control_dealt: i32, + #[serde(rename = "longestTimeSpentLiving")] + pub longest_time_spent_living: i32, + /// Post game rune stats. + #[serde(rename = "perk1Var1")] + pub perk1_var1: i32, + /// Post game rune stats. + #[serde(rename = "perk1Var3")] + pub perk1_var3: i32, + /// Post game rune stats. + #[serde(rename = "perk1Var2")] + pub perk1_var2: i32, + #[serde(rename = "tripleKills")] + pub triple_kills: i32, + /// Post game rune stats. + #[serde(rename = "perk3Var3")] + pub perk3_var3: i32, + #[serde(rename = "nodeNeutralizeAssist")] + pub node_neutralize_assist: i32, + /// Post game rune stats. + #[serde(rename = "perk3Var2")] + pub perk3_var2: i32, + #[serde(rename = "playerScore9")] + pub player_score9: i32, + #[serde(rename = "playerScore8")] + pub player_score8: i32, + #[serde(rename = "kills")] + pub kills: i32, + #[serde(rename = "playerScore1")] + pub player_score1: i32, + #[serde(rename = "playerScore0")] + pub player_score0: i32, + #[serde(rename = "playerScore3")] + pub player_score3: i32, + #[serde(rename = "playerScore2")] + pub player_score2: i32, + #[serde(rename = "playerScore5")] + pub player_score5: i32, + #[serde(rename = "playerScore4")] + pub player_score4: i32, + #[serde(rename = "playerScore7")] + pub player_score7: i32, + #[serde(rename = "playerScore6")] + pub player_score6: i32, + /// Post game rune stats. + #[serde(rename = "perk5Var1")] + pub perk5_var1: i32, + /// Post game rune stats. + #[serde(rename = "perk5Var3")] + pub perk5_var3: i32, + /// Post game rune stats. + #[serde(rename = "perk5Var2")] + pub perk5_var2: i32, + #[serde(rename = "totalScoreRank")] + pub total_score_rank: i32, + #[serde(rename = "neutralMinionsKilled")] + pub neutral_minions_killed: i32, + #[serde(rename = "damageDealtToTurrets")] + pub damage_dealt_to_turrets: i64, + #[serde(rename = "physicalDamageDealtToChampions")] + pub physical_damage_dealt_to_champions: i64, + #[serde(rename = "nodeCapture")] + pub node_capture: i32, + #[serde(rename = "largestMultiKill")] + pub largest_multi_kill: i32, + /// Post game rune stats. + #[serde(rename = "perk2Var2")] + pub perk2_var2: i32, + /// Post game rune stats. + #[serde(rename = "perk2Var3")] + pub perk2_var3: i32, + #[serde(rename = "totalUnitsHealed")] + pub total_units_healed: i32, + /// Post game rune stats. + #[serde(rename = "perk2Var1")] + pub perk2_var1: i32, + /// Post game rune stats. + #[serde(rename = "perk4Var1")] + pub perk4_var1: i32, + /// Post game rune stats. + #[serde(rename = "perk4Var2")] + pub perk4_var2: i32, + /// Post game rune stats. + #[serde(rename = "perk4Var3")] + pub perk4_var3: i32, + #[serde(rename = "wardsKilled")] + pub wards_killed: i32, + #[serde(rename = "largestCriticalStrike")] + pub largest_critical_strike: i32, + #[serde(rename = "largestKillingSpree")] + pub largest_killing_spree: i32, + #[serde(rename = "quadraKills")] + pub quadra_kills: i32, + #[serde(rename = "teamObjective")] + pub team_objective: i32, + #[serde(rename = "magicDamageDealt")] + pub magic_damage_dealt: i64, + #[serde(rename = "item2")] + pub item2: i32, + #[serde(rename = "item3")] + pub item3: i32, + #[serde(rename = "item0")] + pub item0: i32, + #[serde(rename = "neutralMinionsKilledTeamJungle")] + pub neutral_minions_killed_team_jungle: i32, + #[serde(rename = "item6")] + pub item6: i32, + #[serde(rename = "item4")] + pub item4: i32, + #[serde(rename = "item5")] + pub item5: i32, + /// Primary path rune. + #[serde(rename = "perk1")] + pub perk1: i32, + /// Primary path keystone rune. + #[serde(rename = "perk0")] + pub perk0: i32, + /// Primary path rune. + #[serde(rename = "perk3")] + pub perk3: i32, + /// Primary path rune. + #[serde(rename = "perk2")] + pub perk2: i32, + /// Secondary path rune. + #[serde(rename = "perk5")] + pub perk5: i32, + /// Secondary path rune. + #[serde(rename = "perk4")] + pub perk4: i32, + /// Post game rune stats. + #[serde(rename = "perk3Var1")] + pub perk3_var1: i32, + #[serde(rename = "damageSelfMitigated")] + pub damage_self_mitigated: i64, + #[serde(rename = "magicalDamageTaken")] + pub magical_damage_taken: i64, + #[serde(rename = "firstInhibitorKill")] + pub first_inhibitor_kill: bool, + #[serde(rename = "trueDamageTaken")] + pub true_damage_taken: i64, + #[serde(rename = "nodeNeutralize")] + pub node_neutralize: i32, + #[serde(rename = "assists")] + pub assists: i32, + #[serde(rename = "combatPlayerScore")] + pub combat_player_score: i32, + /// Primary rune path + #[serde(rename = "perkPrimaryStyle")] + pub perk_primary_style: i32, + #[serde(rename = "goldSpent")] + pub gold_spent: i32, + #[serde(rename = "trueDamageDealt")] + pub true_damage_dealt: i64, + #[serde(rename = "participantId")] + pub participant_id: i32, + #[serde(rename = "totalDamageTaken")] + pub total_damage_taken: i64, + #[serde(rename = "physicalDamageDealt")] + pub physical_damage_dealt: i64, + #[serde(rename = "sightWardsBoughtInGame")] + pub sight_wards_bought_in_game: i32, + #[serde(rename = "totalDamageDealtToChampions")] + pub total_damage_dealt_to_champions: i64, + #[serde(rename = "physicalDamageTaken")] + pub physical_damage_taken: i64, + #[serde(rename = "totalPlayerScore")] + pub total_player_score: i32, + #[serde(rename = "win")] + pub win: bool, + #[serde(rename = "objectivePlayerScore")] + pub objective_player_score: i32, + #[serde(rename = "totalDamageDealt")] + pub total_damage_dealt: i64, + #[serde(rename = "item1")] + pub item1: i32, + #[serde(rename = "neutralMinionsKilledEnemyJungle")] + pub neutral_minions_killed_enemy_jungle: i32, + #[serde(rename = "deaths")] + pub deaths: i32, + #[serde(rename = "wardsPlaced")] + pub wards_placed: i32, + /// Secondary rune path + #[serde(rename = "perkSubStyle")] + pub perk_sub_style: i32, + #[serde(rename = "turretKills")] + pub turret_kills: i32, + #[serde(rename = "firstBloodKill")] + pub first_blood_kill: bool, + #[serde(rename = "trueDamageDealtToChampions")] + pub true_damage_dealt_to_champions: i64, + #[serde(rename = "goldEarned")] + pub gold_earned: i32, + #[serde(rename = "killingSprees")] + pub killing_sprees: i32, + #[serde(rename = "unrealKills")] + pub unreal_kills: i32, + #[serde(rename = "altarsCaptured")] + pub altars_captured: i32, + #[serde(rename = "firstTowerAssist")] + pub first_tower_assist: bool, + #[serde(rename = "firstTowerKill")] + pub first_tower_kill: bool, + #[serde(rename = "champLevel")] + pub champ_level: i32, + #[serde(rename = "doubleKills")] + pub double_kills: i32, + #[serde(rename = "nodeCaptureAssist")] + pub node_capture_assist: i32, + #[serde(rename = "inhibitorKills")] + pub inhibitor_kills: i32, + #[serde(rename = "firstInhibitorAssist")] + pub first_inhibitor_assist: bool, + /// Post game rune stats. + #[serde(rename = "perk0Var1")] + pub perk0_var1: i32, + /// Post game rune stats. + #[serde(rename = "perk0Var2")] + pub perk0_var2: i32, + /// Post game rune stats. + #[serde(rename = "perk0Var3")] + pub perk0_var3: i32, + #[serde(rename = "visionWardsBoughtInGame")] + pub vision_wards_bought_in_game: i32, + #[serde(rename = "altarsNeutralized")] + pub altars_neutralized: i32, + #[serde(rename = "pentaKills")] + pub penta_kills: i32, + #[serde(rename = "totalHeal")] + pub total_heal: i64, + #[serde(rename = "totalMinionsKilled")] + pub total_minions_killed: i32, + #[serde(rename = "timeCCingOthers")] + pub time_c_cing_others: i64, + } + /// Rune data object. This class is automatically generated. + #[derive(Debug)] + #[derive(serde::Serialize, serde::Deserialize)] + pub struct Rune { + #[serde(rename = "runeId")] + pub rune_id: i32, + #[serde(rename = "rank")] + pub rank: i32, + } + /// ParticipantTimeline data object. This class is automatically generated. + #[derive(Debug)] + #[derive(serde::Serialize, serde::Deserialize)] + pub struct ParticipantTimeline { + /// Participant's calculated lane. MID and BOT are legacy values. + /// (Legal values: MID, MIDDLE, TOP, JUNGLE, BOT, BOTTOM) + #[serde(rename = "lane")] + pub lane: String, + #[serde(rename = "participantId")] + pub participant_id: i32, + /// Creep score difference versus the calculated lane opponent(s) for a specified period. + #[serde(rename = "csDiffPerMinDeltas")] + pub cs_diff_per_min_deltas: std::collections::HashMap, + /// Gold for a specified period. + #[serde(rename = "goldPerMinDeltas")] + pub gold_per_min_deltas: std::collections::HashMap, + /// Experience difference versus the calculated lane opponent(s) for a specified period. + #[serde(rename = "xpDiffPerMinDeltas")] + pub xp_diff_per_min_deltas: std::collections::HashMap, + /// Creeps for a specified period. + #[serde(rename = "creepsPerMinDeltas")] + pub creeps_per_min_deltas: std::collections::HashMap, + /// Experience change for a specified period. + #[serde(rename = "xpPerMinDeltas")] + pub xp_per_min_deltas: std::collections::HashMap, + /// Participant's calculated role. + /// (Legal values: DUO, NONE, SOLO, DUO_CARRY, DUO_SUPPORT) + #[serde(rename = "role")] + pub role: String, + /// Damage taken difference versus the calculated lane opponent(s) for a specified period. + #[serde(rename = "damageTakenDiffPerMinDeltas")] + pub damage_taken_diff_per_min_deltas: std::collections::HashMap, + /// Damage taken for a specified period. + #[serde(rename = "damageTakenPerMinDeltas")] + pub damage_taken_per_min_deltas: std::collections::HashMap, + } + /// Mastery data object. This class is automatically generated. + #[derive(Debug)] + #[derive(serde::Serialize, serde::Deserialize)] + pub struct Mastery { + #[serde(rename = "masteryId")] + pub mastery_id: i32, + #[serde(rename = "rank")] + pub rank: i32, + } + /// Matchlist data object. This class is automatically generated. + #[derive(Debug)] + #[derive(serde::Serialize, serde::Deserialize)] + pub struct Matchlist { + #[serde(rename = "matches")] + pub matches: std::vec::Vec, + #[serde(rename = "totalGames")] + pub total_games: i32, + #[serde(rename = "startIndex")] + pub start_index: i32, + #[serde(rename = "endIndex")] + pub end_index: i32, + } + /// MatchReference data object. This class is automatically generated. + #[derive(Debug)] + #[derive(serde::Serialize, serde::Deserialize)] + pub struct MatchReference { + #[serde(rename = "lane")] + pub lane: String, + #[serde(rename = "gameId")] + pub game_id: i64, + #[serde(rename = "champion")] + pub champion: i32, + #[serde(rename = "platformId")] + pub platform_id: String, + #[serde(rename = "season")] + pub season: i32, + #[serde(rename = "queue")] + pub queue: i32, + #[serde(rename = "role")] + pub role: String, + #[serde(rename = "timestamp")] + pub timestamp: i64, + } + /// MatchTimeline data object. This class is automatically generated. + #[derive(Debug)] + #[derive(serde::Serialize, serde::Deserialize)] + pub struct MatchTimeline { + #[serde(rename = "frames")] + pub frames: std::vec::Vec, + #[serde(rename = "frameInterval")] + pub frame_interval: i64, + } + /// MatchFrame data object. This class is automatically generated. + #[derive(Debug)] + #[derive(serde::Serialize, serde::Deserialize)] + pub struct MatchFrame { + #[serde(rename = "timestamp")] + pub timestamp: i64, + #[serde(rename = "participantFrames")] + pub participant_frames: std::collections::HashMap, + #[serde(rename = "events")] + pub events: std::vec::Vec, + } + /// MatchParticipantFrame data object. This class is automatically generated. + #[derive(Debug)] + #[derive(serde::Serialize, serde::Deserialize)] + pub struct MatchParticipantFrame { + #[serde(rename = "totalGold")] + pub total_gold: i32, + #[serde(rename = "teamScore")] + pub team_score: i32, + #[serde(rename = "participantId")] + pub participant_id: i32, + #[serde(rename = "level")] + pub level: i32, + #[serde(rename = "currentGold")] + pub current_gold: i32, + #[serde(rename = "minionsKilled")] + pub minions_killed: i32, + #[serde(rename = "dominionScore")] + pub dominion_score: i32, + #[serde(rename = "position")] + pub position: MatchPosition, + #[serde(rename = "xp")] + pub xp: i32, + #[serde(rename = "jungleMinionsKilled")] + pub jungle_minions_killed: i32, + } + /// MatchPosition data object. This class is automatically generated. + #[derive(Debug)] + #[derive(serde::Serialize, serde::Deserialize)] + pub struct MatchPosition { + #[serde(rename = "y")] + pub y: i32, + #[serde(rename = "x")] + pub x: i32, + } + /// MatchEvent data object. This class is automatically generated. + #[derive(Debug)] + #[derive(serde::Serialize, serde::Deserialize)] + pub struct MatchEvent { + #[serde(rename = "eventType")] + pub event_type: String, + #[serde(rename = "towerType")] + pub tower_type: String, + #[serde(rename = "teamId")] + pub team_id: i32, + #[serde(rename = "ascendedType")] + pub ascended_type: String, + #[serde(rename = "killerId")] + pub killer_id: i32, + #[serde(rename = "levelUpType")] + pub level_up_type: String, + #[serde(rename = "pointCaptured")] + pub point_captured: String, + #[serde(rename = "assistingParticipantIds")] + pub assisting_participant_ids: std::vec::Vec, + #[serde(rename = "wardType")] + pub ward_type: String, + #[serde(rename = "monsterType")] + pub monster_type: String, + /// (Legal values: CHAMPION_KILL, WARD_PLACED, WARD_KILL, BUILDING_KILL, ELITE_MONSTER_KILL, ITEM_PURCHASED, ITEM_SOLD, ITEM_DESTROYED, ITEM_UNDO, SKILL_LEVEL_UP, ASCENDED_EVENT, CAPTURE_POINT, PORO_KING_SUMMON) + #[serde(rename = "type")] + pub r#type: String, + #[serde(rename = "skillSlot")] + pub skill_slot: i32, + #[serde(rename = "victimId")] + pub victim_id: i32, + #[serde(rename = "timestamp")] + pub timestamp: i64, + #[serde(rename = "afterId")] + pub after_id: i32, + #[serde(rename = "monsterSubType")] + pub monster_sub_type: String, + #[serde(rename = "laneType")] + pub lane_type: String, + #[serde(rename = "itemId")] + pub item_id: i32, + #[serde(rename = "participantId")] + pub participant_id: i32, + #[serde(rename = "buildingType")] + pub building_type: String, + #[serde(rename = "creatorId")] + pub creator_id: i32, + #[serde(rename = "position")] + pub position: MatchPosition, + #[serde(rename = "beforeId")] + pub before_id: i32, + } +} + +// spectator-v4 +#[allow(dead_code)] +pub mod spectator_v4 { + /// CurrentGameInfo data object. This class is automatically generated. + #[derive(Debug)] + #[derive(serde::Serialize, serde::Deserialize)] + pub struct CurrentGameInfo { + /// The ID of the game + #[serde(rename = "gameId")] + pub game_id: i64, + /// The game start time represented in epoch milliseconds + #[serde(rename = "gameStartTime")] + pub game_start_time: i64, + /// The ID of the platform on which the game is being played + #[serde(rename = "platformId")] + pub platform_id: String, + /// The game mode + #[serde(rename = "gameMode")] + pub game_mode: String, + /// The ID of the map + #[serde(rename = "mapId")] + pub map_id: i64, + /// The game type + #[serde(rename = "gameType")] + pub game_type: String, + /// Banned champion information + #[serde(rename = "bannedChampions")] + pub banned_champions: std::vec::Vec, + /// The observer information + #[serde(rename = "observers")] + pub observers: Observer, + /// The participant information + #[serde(rename = "participants")] + pub participants: std::vec::Vec, + /// The amount of time in seconds that has passed since the game started + #[serde(rename = "gameLength")] + pub game_length: i64, + /// The queue type (queue types are documented on the Game Constants page) + #[serde(rename = "gameQueueConfigId")] + pub game_queue_config_id: i64, + } + /// BannedChampion data object. This class is automatically generated. + #[derive(Debug)] + #[derive(serde::Serialize, serde::Deserialize)] + pub struct BannedChampion { + /// The turn during which the champion was banned + #[serde(rename = "pickTurn")] + pub pick_turn: i32, + /// The ID of the banned champion + #[serde(rename = "championId")] + pub champion_id: i64, + /// The ID of the team that banned the champion + #[serde(rename = "teamId")] + pub team_id: i64, + } + /// Observer data object. This class is automatically generated. + #[derive(Debug)] + #[derive(serde::Serialize, serde::Deserialize)] + pub struct Observer { + /// Key used to decrypt the spectator grid game data for playback + #[serde(rename = "encryptionKey")] + pub encryption_key: String, + } + /// CurrentGameParticipant data object. This class is automatically generated. + #[derive(Debug)] + #[derive(serde::Serialize, serde::Deserialize)] + pub struct CurrentGameParticipant { + /// The ID of the profile icon used by this participant + #[serde(rename = "profileIconId")] + pub profile_icon_id: i64, + /// The ID of the champion played by this participant + #[serde(rename = "championId")] + pub champion_id: i64, + /// The summoner name of this participant + #[serde(rename = "summonerName")] + pub summoner_name: String, + /// List of Game Customizations + #[serde(rename = "gameCustomizationObjects")] + pub game_customization_objects: std::vec::Vec, + /// Flag indicating whether or not this participant is a bot + #[serde(rename = "bot")] + pub bot: bool, + /// Perks/Runes Reforged Information + #[serde(rename = "perks")] + pub perks: Perks, + /// The ID of the second summoner spell used by this participant + #[serde(rename = "spell2Id")] + pub spell2_id: i64, + /// The team ID of this participant, indicating the participant's team + #[serde(rename = "teamId")] + pub team_id: i64, + /// The ID of the first summoner spell used by this participant + #[serde(rename = "spell1Id")] + pub spell1_id: i64, + /// The encrypted summoner ID of this participant + #[serde(rename = "summonerId")] + pub summoner_id: String, + } + /// GameCustomizationObject data object. This class is automatically generated. + #[derive(Debug)] + #[derive(serde::Serialize, serde::Deserialize)] + pub struct GameCustomizationObject { + /// Category identifier for Game Customization + #[serde(rename = "category")] + pub category: String, + /// Game Customization content + #[serde(rename = "content")] + pub content: String, + } + /// Perks data object. This class is automatically generated. + #[derive(Debug)] + #[derive(serde::Serialize, serde::Deserialize)] + pub struct Perks { + /// Primary runes path + #[serde(rename = "perkStyle")] + pub perk_style: i64, + /// IDs of the perks/runes assigned. + #[serde(rename = "perkIds")] + pub perk_ids: std::vec::Vec, + /// Secondary runes path + #[serde(rename = "perkSubStyle")] + pub perk_sub_style: i64, + } + /// FeaturedGames data object. This class is automatically generated. + #[derive(Debug)] + #[derive(serde::Serialize, serde::Deserialize)] + pub struct FeaturedGames { + /// The suggested interval to wait before requesting FeaturedGames again + #[serde(rename = "clientRefreshInterval")] + pub client_refresh_interval: i64, + /// The list of featured games + #[serde(rename = "gameList")] + pub game_list: std::vec::Vec, + } + /// FeaturedGameInfo data object. This class is automatically generated. + #[derive(Debug)] + #[derive(serde::Serialize, serde::Deserialize)] + pub struct FeaturedGameInfo { + /// The ID of the game + #[serde(rename = "gameId")] + pub game_id: i64, + /// The game start time represented in epoch milliseconds + #[serde(rename = "gameStartTime")] + pub game_start_time: i64, + /// The ID of the platform on which the game is being played + #[serde(rename = "platformId")] + pub platform_id: String, + /// The game mode + /// (Legal values: CLASSIC, ODIN, ARAM, TUTORIAL, ONEFORALL, ASCENSION, FIRSTBLOOD, KINGPORO) + #[serde(rename = "gameMode")] + pub game_mode: String, + /// The ID of the map + #[serde(rename = "mapId")] + pub map_id: i64, + /// The game type + /// (Legal values: CUSTOM_GAME, MATCHED_GAME, TUTORIAL_GAME) + #[serde(rename = "gameType")] + pub game_type: String, + /// Banned champion information + #[serde(rename = "bannedChampions")] + pub banned_champions: std::vec::Vec, + /// The observer information + #[serde(rename = "observers")] + pub observers: Observer, + /// The participant information + #[serde(rename = "participants")] + pub participants: std::vec::Vec, + /// The amount of time in seconds that has passed since the game started + #[serde(rename = "gameLength")] + pub game_length: i64, + /// The queue type (queue types are documented on the Game Constants page) + #[serde(rename = "gameQueueConfigId")] + pub game_queue_config_id: i64, + } + /// Participant data object. This class is automatically generated. + #[derive(Debug)] + #[derive(serde::Serialize, serde::Deserialize)] + pub struct Participant { + /// The ID of the profile icon used by this participant + #[serde(rename = "profileIconId")] + pub profile_icon_id: i64, + /// The ID of the champion played by this participant + #[serde(rename = "championId")] + pub champion_id: i64, + /// The summoner name of this participant + #[serde(rename = "summonerName")] + pub summoner_name: String, + /// Flag indicating whether or not this participant is a bot + #[serde(rename = "bot")] + pub bot: bool, + /// The ID of the second summoner spell used by this participant + #[serde(rename = "spell2Id")] + pub spell2_id: i64, + /// The team ID of this participant, indicating the participant's team + #[serde(rename = "teamId")] + pub team_id: i64, + /// The ID of the first summoner spell used by this participant + #[serde(rename = "spell1Id")] + pub spell1_id: i64, + } +} + +// summoner-v4 +#[allow(dead_code)] +pub mod summoner_v4 { + /// Summoner data object. This class is automatically generated. + /// # Description + /// represents a summoner + #[derive(Debug)] + #[derive(serde::Serialize, serde::Deserialize)] + pub struct Summoner { + /// ID of the summoner icon associated with the summoner. + #[serde(rename = "profileIconId")] + pub profile_icon_id: i32, + /// Summoner name. + #[serde(rename = "name")] + pub name: String, + /// Encrypted PUUID. Exact length of 78 characters. + #[serde(rename = "puuid")] + pub puuid: String, + /// Summoner level associated with the summoner. + #[serde(rename = "summonerLevel")] + pub summoner_level: i64, + /// Date summoner was last modified specified as epoch milliseconds. The following events will update this timestamp: profile icon change, playing the tutorial or advanced tutorial, finishing a game, summoner name change + #[serde(rename = "revisionDate")] + pub revision_date: i64, + /// Encrypted summoner ID. Max length 63 characters. + #[serde(rename = "id")] + pub id: String, + /// Encrypted account ID. Max length 56 characters. + #[serde(rename = "accountId")] + pub account_id: String, + } +} + +// tournament-stub-v4 +#[allow(dead_code)] +pub mod tournament_stub_v4 { + /// TournamentCodeParameters data object. This class is automatically generated. + #[derive(Debug)] + #[derive(serde::Serialize, serde::Deserialize)] + pub struct TournamentCodeParameters { + /// The spectator type of the game. + /// (Legal values: NONE, LOBBYONLY, ALL) + #[serde(rename = "spectatorType")] + pub spectator_type: String, + /// The team size of the game. Valid values are 1-5. + #[serde(rename = "teamSize")] + pub team_size: i32, + /// The pick type of the game. + /// (Legal values: BLIND_PICK, DRAFT_MODE, ALL_RANDOM, TOURNAMENT_DRAFT) + #[serde(rename = "pickType")] + pub pick_type: String, + /// Optional list of encrypted summonerIds in order to validate the players eligible to join the lobby. NOTE: We currently do not enforce participants at the team level, but rather the aggregate of teamOne and teamTwo. We may add the ability to enforce at the team level in the future. + #[serde(rename = "allowedSummonerIds")] + pub allowed_summoner_ids: std::vec::Vec, + /// The map type of the game. + /// (Legal values: SUMMONERS_RIFT, TWISTED_TREELINE, HOWLING_ABYSS) + #[serde(rename = "mapType")] + pub map_type: String, + /// Optional string that may contain any data in any format, if specified at all. Used to denote any custom information about the game. + #[serde(rename = "metadata")] + pub metadata: String, + } + /// LobbyEventWrapper data object. This class is automatically generated. + #[derive(Debug)] + #[derive(serde::Serialize, serde::Deserialize)] + pub struct LobbyEventWrapper { + #[serde(rename = "eventList")] + pub event_list: std::vec::Vec, + } + /// LobbyEvent data object. This class is automatically generated. + #[derive(Debug)] + #[derive(serde::Serialize, serde::Deserialize)] + pub struct LobbyEvent { + /// The type of event that was triggered + #[serde(rename = "eventType")] + pub event_type: String, + /// The summonerId that triggered the event (Encrypted) + #[serde(rename = "summonerId")] + pub summoner_id: String, + /// Timestamp from the event + #[serde(rename = "timestamp")] + pub timestamp: String, + } + /// ProviderRegistrationParameters data object. This class is automatically generated. + #[derive(Debug)] + #[derive(serde::Serialize, serde::Deserialize)] + pub struct ProviderRegistrationParameters { + /// The provider's callback URL to which tournament game results in this region should be posted. The URL must be well-formed, use the http or https protocol, and use the default port for the protocol (http URLs must use port 80, https URLs must use port 443). + #[serde(rename = "url")] + pub url: String, + /// The region in which the provider will be running tournaments. + /// (Legal values: BR, EUNE, EUW, JP, LAN, LAS, NA, OCE, PBE, RU, TR) + #[serde(rename = "region")] + pub region: String, + } + /// TournamentRegistrationParameters data object. This class is automatically generated. + #[derive(Debug)] + #[derive(serde::Serialize, serde::Deserialize)] + pub struct TournamentRegistrationParameters { + /// The provider ID to specify the regional registered provider data to associate this tournament. + #[serde(rename = "providerId")] + pub provider_id: i32, + /// The optional name of the tournament. + #[serde(rename = "name")] + pub name: String, + } +} + +// tournament-v4 +#[allow(dead_code)] +pub mod tournament_v4 { + /// TournamentCodeParameters data object. This class is automatically generated. + #[derive(Debug)] + #[derive(serde::Serialize, serde::Deserialize)] + pub struct TournamentCodeParameters { + /// The spectator type of the game. + /// (Legal values: NONE, LOBBYONLY, ALL) + #[serde(rename = "spectatorType")] + pub spectator_type: String, + /// The team size of the game. Valid values are 1-5. + #[serde(rename = "teamSize")] + pub team_size: i32, + /// The pick type of the game. + /// (Legal values: BLIND_PICK, DRAFT_MODE, ALL_RANDOM, TOURNAMENT_DRAFT) + #[serde(rename = "pickType")] + pub pick_type: String, + /// Optional list of encrypted summonerIds in order to validate the players eligible to join the lobby. NOTE: We currently do not enforce participants at the team level, but rather the aggregate of teamOne and teamTwo. We may add the ability to enforce at the team level in the future. + #[serde(rename = "allowedSummonerIds")] + pub allowed_summoner_ids: std::vec::Vec, + /// The map type of the game. + /// (Legal values: SUMMONERS_RIFT, TWISTED_TREELINE, HOWLING_ABYSS) + #[serde(rename = "mapType")] + pub map_type: String, + /// Optional string that may contain any data in any format, if specified at all. Used to denote any custom information about the game. + #[serde(rename = "metadata")] + pub metadata: String, + } + /// TournamentCode data object. This class is automatically generated. + #[derive(Debug)] + #[derive(serde::Serialize, serde::Deserialize)] + pub struct TournamentCode { + /// The game map for the tournament code game + #[serde(rename = "map")] + pub map: String, + /// The tournament code. + #[serde(rename = "code")] + pub code: String, + /// The spectator mode for the tournament code game. + #[serde(rename = "spectators")] + pub spectators: String, + /// The tournament code's region. + /// (Legal values: BR, EUNE, EUW, JP, LAN, LAS, NA, OCE, PBE, RU, TR) + #[serde(rename = "region")] + pub region: String, + /// The provider's ID. + #[serde(rename = "providerId")] + pub provider_id: i32, + /// The team size for the tournament code game. + #[serde(rename = "teamSize")] + pub team_size: i32, + /// The summonerIds of the participants (Encrypted) + #[serde(rename = "participants")] + pub participants: std::vec::Vec, + /// The pick mode for tournament code game. + #[serde(rename = "pickType")] + pub pick_type: String, + /// The tournament's ID. + #[serde(rename = "tournamentId")] + pub tournament_id: i32, + /// The lobby name for the tournament code game. + #[serde(rename = "lobbyName")] + pub lobby_name: String, + /// The password for the tournament code game. + #[serde(rename = "password")] + pub password: String, + /// The tournament code's ID. + #[serde(rename = "id")] + pub id: i32, + /// The metadata for tournament code. + #[serde(rename = "metaData")] + pub meta_data: String, + } + /// TournamentCodeUpdateParameters data object. This class is automatically generated. + #[derive(Debug)] + #[derive(serde::Serialize, serde::Deserialize)] + pub struct TournamentCodeUpdateParameters { + /// The spectator type + /// (Legal values: NONE, LOBBYONLY, ALL) + #[serde(rename = "spectatorType")] + pub spectator_type: String, + /// The pick type + /// (Legal values: BLIND_PICK, DRAFT_MODE, ALL_RANDOM, TOURNAMENT_DRAFT) + #[serde(rename = "pickType")] + pub pick_type: String, + /// Optional list of encrypted summonerIds in order to validate the players eligible to join the lobby. NOTE: We currently do not enforce participants at the team level, but rather the aggregate of teamOne and teamTwo. We may add the ability to enforce at the team level in the future. + #[serde(rename = "allowedSummonerIds")] + pub allowed_summoner_ids: std::vec::Vec, + /// The map type + /// (Legal values: SUMMONERS_RIFT, TWISTED_TREELINE, HOWLING_ABYSS) + #[serde(rename = "mapType")] + pub map_type: String, + } + /// LobbyEventWrapper data object. This class is automatically generated. + #[derive(Debug)] + #[derive(serde::Serialize, serde::Deserialize)] + pub struct LobbyEventWrapper { + #[serde(rename = "eventList")] + pub event_list: std::vec::Vec, + } + /// LobbyEvent data object. This class is automatically generated. + #[derive(Debug)] + #[derive(serde::Serialize, serde::Deserialize)] + pub struct LobbyEvent { + /// Timestamp from the event + #[serde(rename = "timestamp")] + pub timestamp: String, + /// The summonerId that triggered the event (Encrypted) + #[serde(rename = "summonerId")] + pub summoner_id: String, + /// The type of event that was triggered + #[serde(rename = "eventType")] + pub event_type: String, + } + /// ProviderRegistrationParameters data object. This class is automatically generated. + #[derive(Debug)] + #[derive(serde::Serialize, serde::Deserialize)] + pub struct ProviderRegistrationParameters { + /// The provider's callback URL to which tournament game results in this region should be posted. The URL must be well-formed, use the http or https protocol, and use the default port for the protocol (http URLs must use port 80, https URLs must use port 443). + #[serde(rename = "url")] + pub url: String, + /// The region in which the provider will be running tournaments. + /// (Legal values: BR, EUNE, EUW, JP, LAN, LAS, NA, OCE, PBE, RU, TR) + #[serde(rename = "region")] + pub region: String, + } + /// TournamentRegistrationParameters data object. This class is automatically generated. + #[derive(Debug)] + #[derive(serde::Serialize, serde::Deserialize)] + pub struct TournamentRegistrationParameters { + /// The provider ID to specify the regional registered provider data to associate this tournament. + #[serde(rename = "providerId")] + pub provider_id: i32, + /// The optional name of the tournament. + #[serde(rename = "name")] + pub name: String, + } +} diff --git a/srcgen/dto.rs.dt b/srcgen/dto.rs.dt index 3c3fab3..493ce37 100644 --- a/srcgen/dto.rs.dt +++ b/srcgen/dto.rs.dt @@ -19,7 +19,7 @@ }} // {{= endpoint }} #[allow(dead_code)] -pub mod {{= dotUtils.normalizeEndpointName(endpoint) }} { +pub mod {{= dotUtils.changeCase.snakeCase(endpoint) }} { {{ for (let schemaKey of schemaKeyGroup) { let [endpoint, rawSchemaName] = schemaKey.split('.'); @@ -32,8 +32,22 @@ pub mod {{= dotUtils.normalizeEndpointName(endpoint) }} { /// # Description /// {{= schema.description }} {{?}} + #[derive(Debug)] + #[derive(serde::Serialize, serde::Deserialize)] pub struct {{= schemaName }} { - // TODO. +{{ + for (let [ propKey, prop ] of Object.entries(props)) + { + let name = dotUtils.normalizePropName(propKey, schemaName, prop); +}} +{{? prop.description }} + /// {{= prop.description.split('\n').map(x => x.trim()).join(' \r\n /// ') }} +{{?}} + {{= dotUtils.formatJsonProperty(propKey) }} + pub {{= name }}: {{= dotUtils.stringifyType(prop) }}, +{{ + } +}} } {{ } diff --git a/srcgen/endpoints.rs b/srcgen/endpoints.rs new file mode 100644 index 0000000..e519200 --- /dev/null +++ b/srcgen/endpoints.rs @@ -0,0 +1,448 @@ + +// This file is automatically generated. +// Do not directly edit. +// Generated on 2019-10-20T06:19:43.832Z + +// http://www.mingweisamuel.com/riotapi-schema/tool/ +// Version 0c74167e0eaaeb6de1c7e8219fecaabcf8386d1f + +use std::vec::Vec; + +use reqwest; +use url::form_urlencoded::Serializer; + +use crate::consts::Region; +use crate::riot_api::RiotApi; + + +// ChampionMasteryV4 +impl<'a> RiotApi<'a> { + /// Get all champion mastery entries sorted by number of champion points descending, + /// # Official API Reference + /// https://developer.riotgames.com/api-methods/#champion-mastery-v4/GET_getAllChampionMasteries + /// # Parameters + /// * `region` - Region to query. + /// * `encryptedSummonerId` - Summoner ID associated with the player + pub async fn champion_mastery_v4_get_all_champion_masteries(&'a self, region: Region, encrypted_summoner_id: &str) -> Result>, reqwest::Error> { + let path_string = format!("/lol/champion-mastery/v4/champion-masteries/by-summoner/{}", encrypted_summoner_id); + return self.requester_manager.get::>( + "champion-mastery-v4.getAllChampionMasteries", region, &*path_string, + None).await; // false); + } + + /// Get a champion mastery by player ID and champion ID. + /// # Official API Reference + /// https://developer.riotgames.com/api-methods/#champion-mastery-v4/GET_getChampionMastery + /// # Parameters + /// * `region` - Region to query. + /// * `championId` - Champion ID to retrieve Champion Mastery for + /// * `encryptedSummonerId` - Summoner ID associated with the player + pub async fn champion_mastery_v4_get_champion_mastery(&'a self, region: Region, encrypted_summoner_id: &str, champion_id: i64) -> Result, reqwest::Error> { + let path_string = format!("/lol/champion-mastery/v4/champion-masteries/by-summoner/{}/by-champion/{}", encrypted_summoner_id, champion_id); + return self.requester_manager.get::( + "champion-mastery-v4.getChampionMastery", region, &*path_string, + None).await; // false); + } + + /// Get a player's total champion mastery score, which is the sum of individual champion mastery levels. + /// # Official API Reference + /// https://developer.riotgames.com/api-methods/#champion-mastery-v4/GET_getChampionMasteryScore + /// # Parameters + /// * `region` - Region to query. + /// * `encryptedSummonerId` - Summoner ID associated with the player + pub async fn champion_mastery_v4_get_champion_mastery_score(&'a self, region: Region, encrypted_summoner_id: &str) -> Result, reqwest::Error> { + let path_string = format!("/lol/champion-mastery/v4/scores/by-summoner/{}", encrypted_summoner_id); + return self.requester_manager.get::( + "champion-mastery-v4.getChampionMasteryScore", region, &*path_string, + None).await; // false); + } + +} + +// ChampionV3 +impl<'a> RiotApi<'a> { + /// Returns champion rotations, including free-to-play and low-level free-to-play rotations (REST) + /// # Official API Reference + /// https://developer.riotgames.com/api-methods/#champion-v3/GET_getChampionInfo + /// # Parameters + /// * `region` - Region to query. + pub async fn champion_v3_get_champion_info(&'a self, region: Region) -> Result, reqwest::Error> { + let path_string = "/lol/platform/v3/champion-rotations"; + return self.requester_manager.get::( + "champion-v3.getChampionInfo", region, &*path_string, + None).await; // false); + } + +} + +// LeagueExpV4 +impl<'a> RiotApi<'a> { + /// Get all the league entries. + /// # Official API Reference + /// https://developer.riotgames.com/api-methods/#league-exp-v4/GET_getLeagueEntries + /// # Parameters + /// * `region` - Region to query. + /// * `queue` - Note that the queue value must be a valid ranked queue. + /// * `tier` + /// * `division` + /// * `page` (optional) - Starts with page 1. + pub async fn league_exp_v4_get_league_entries(&'a self, region: Region, division: &str, tier: &str, queue: &str, page: Option) -> Result>, reqwest::Error> { + let mut query_params = Serializer::new(String::new()); + if let Some(page) = page { query_params.append_pair("page", &*page.to_string()); }; + let query_string = query_params.finish(); + let path_string = format!("/lol/league-exp/v4/entries/{}/{}/{}", division, tier, queue); + return self.requester_manager.get::>( + "league-exp-v4.getLeagueEntries", region, &*path_string, + Some(&*query_string)).await; // false); + } + +} + +// LeagueV4 +impl<'a> RiotApi<'a> { + /// Get the challenger league for given queue. + /// # Official API Reference + /// https://developer.riotgames.com/api-methods/#league-v4/GET_getChallengerLeague + /// # Parameters + /// * `region` - Region to query. + /// * `queue` + pub async fn league_v4_get_challenger_league(&'a self, region: Region, queue: &str) -> Result, reqwest::Error> { + let path_string = format!("/lol/league/v4/challengerleagues/by-queue/{}", queue); + return self.requester_manager.get::( + "league-v4.getChallengerLeague", region, &*path_string, + None).await; // false); + } + + /// Get league entries in all queues for a given summoner ID. + /// # Official API Reference + /// https://developer.riotgames.com/api-methods/#league-v4/GET_getLeagueEntriesForSummoner + /// # Parameters + /// * `region` - Region to query. + /// * `encryptedSummonerId` + pub async fn league_v4_get_league_entries_for_summoner(&'a self, region: Region, encrypted_summoner_id: &str) -> Result>, reqwest::Error> { + let path_string = format!("/lol/league/v4/entries/by-summoner/{}", encrypted_summoner_id); + return self.requester_manager.get::>( + "league-v4.getLeagueEntriesForSummoner", region, &*path_string, + None).await; // false); + } + + /// Get all the league entries. + /// # Official API Reference + /// https://developer.riotgames.com/api-methods/#league-v4/GET_getLeagueEntries + /// # Parameters + /// * `region` - Region to query. + /// * `division` + /// * `tier` + /// * `queue` - Note that the queue value must be a valid ranked queue. + /// * `page` (optional) - Starts with page 1. + pub async fn league_v4_get_league_entries(&'a self, region: Region, queue: &str, tier: &str, division: &str, page: Option) -> Result>, reqwest::Error> { + let mut query_params = Serializer::new(String::new()); + if let Some(page) = page { query_params.append_pair("page", &*page.to_string()); }; + let query_string = query_params.finish(); + let path_string = format!("/lol/league/v4/entries/{}/{}/{}", queue, tier, division); + return self.requester_manager.get::>( + "league-v4.getLeagueEntries", region, &*path_string, + Some(&*query_string)).await; // false); + } + + /// Get the grandmaster league of a specific queue. + /// # Official API Reference + /// https://developer.riotgames.com/api-methods/#league-v4/GET_getGrandmasterLeague + /// # Parameters + /// * `region` - Region to query. + /// * `queue` + pub async fn league_v4_get_grandmaster_league(&'a self, region: Region, queue: &str) -> Result, reqwest::Error> { + let path_string = format!("/lol/league/v4/grandmasterleagues/by-queue/{}", queue); + return self.requester_manager.get::( + "league-v4.getGrandmasterLeague", region, &*path_string, + None).await; // false); + } + + /// Get league with given ID, including inactive entries. + /// # Official API Reference + /// https://developer.riotgames.com/api-methods/#league-v4/GET_getLeagueById + /// # Parameters + /// * `region` - Region to query. + /// * `leagueId` - The UUID of the league. + pub async fn league_v4_get_league_by_id(&'a self, region: Region, league_id: &str) -> Result, reqwest::Error> { + let path_string = format!("/lol/league/v4/leagues/{}", league_id); + return self.requester_manager.get::( + "league-v4.getLeagueById", region, &*path_string, + None).await; // false); + } + + /// Get the master league for given queue. + /// # Official API Reference + /// https://developer.riotgames.com/api-methods/#league-v4/GET_getMasterLeague + /// # Parameters + /// * `region` - Region to query. + /// * `queue` + pub async fn league_v4_get_master_league(&'a self, region: Region, queue: &str) -> Result, reqwest::Error> { + let path_string = format!("/lol/league/v4/masterleagues/by-queue/{}", queue); + return self.requester_manager.get::( + "league-v4.getMasterLeague", region, &*path_string, + None).await; // false); + } + +} + +// LolStatusV3 +impl<'a> RiotApi<'a> { + /// Get League of Legends status for the given shard. + /// ## Rate Limit Notes + /// Requests to this API are not counted against the application Rate Limits. + /// # Official API Reference + /// https://developer.riotgames.com/api-methods/#lol-status-v3/GET_getShardData + /// # Parameters + /// * `region` - Region to query. + pub async fn lol_status_v3_get_shard_data(&'a self, region: Region) -> Result, reqwest::Error> { + let path_string = "/lol/status/v3/shard-data"; + return self.requester_manager.get::( + "lol-status-v3.getShardData", region, &*path_string, + None).await; // true); + } + +} + +// MatchV4 +impl<'a> RiotApi<'a> { + /// Get match IDs by tournament code. + /// # Official API Reference + /// https://developer.riotgames.com/api-methods/#match-v4/GET_getMatchIdsByTournamentCode + /// # Parameters + /// * `region` - Region to query. + /// * `tournamentCode` - The tournament code. + pub async fn match_v4_get_match_ids_by_tournament_code(&'a self, region: Region, tournament_code: &str) -> Result>, reqwest::Error> { + let path_string = format!("/lol/match/v4/matches/by-tournament-code/{}/ids", tournament_code); + return self.requester_manager.get::>( + "match-v4.getMatchIdsByTournamentCode", region, &*path_string, + None).await; // false); + } + + /// Get match by match ID. + /// # Official API Reference + /// https://developer.riotgames.com/api-methods/#match-v4/GET_getMatch + /// # Parameters + /// * `region` - Region to query. + /// * `matchId` - The match ID. + pub async fn match_v4_get_match(&'a self, region: Region, match_id: i64) -> Result, reqwest::Error> { + let path_string = format!("/lol/match/v4/matches/{}", match_id); + return self.requester_manager.get::( + "match-v4.getMatch", region, &*path_string, + None).await; // false); + } + + /// Get match by match ID and tournament code. + /// # Official API Reference + /// https://developer.riotgames.com/api-methods/#match-v4/GET_getMatchByTournamentCode + /// # Parameters + /// * `region` - Region to query. + /// * `tournamentCode` - The tournament code. + /// * `matchId` - The match ID. + pub async fn match_v4_get_match_by_tournament_code(&'a self, region: Region, match_id: i64, tournament_code: &str) -> Result, reqwest::Error> { + let path_string = format!("/lol/match/v4/matches/{}/by-tournament-code/{}", match_id, tournament_code); + return self.requester_manager.get::( + "match-v4.getMatchByTournamentCode", region, &*path_string, + None).await; // false); + } + + /// Get matchlist for games played on given account ID and platform ID and filtered using given filter parameters, if any. + /// ## Implementation Notes + /// A number of optional parameters are provided for filtering. It is up to the caller to ensure that the combination of filter parameters provided is valid for the requested account, otherwise, no matches may be returned. + /// + /// If beginIndex is specified, but not endIndex, then endIndex defaults to beginIndex+100. If endIndex is specified, but not beginIndex, then beginIndex defaults to 0. If both are specified, then endIndex must be greater than beginIndex. The maximum range allowed is 100, otherwise a 400 error code is returned. + /// + /// If beginTime is specified, but not endTime, then endTime defaults to the the current unix timestamp in milliseconds (the maximum time range limitation is not observed in this specific case). If endTime is specified, but not beginTime, then beginTime defaults to the start of the account's match history returning a 400 due to the maximum time range limitation. If both are specified, then endTime should be greater than beginTime. The maximum time range allowed is one week, otherwise a 400 error code is returned. + /// # Official API Reference + /// https://developer.riotgames.com/api-methods/#match-v4/GET_getMatchlist + /// # Parameters + /// * `region` - Region to query. + /// * `encryptedAccountId` - The account ID. + /// * `champion` (optional) - Set of champion IDs for filtering the matchlist. + /// * `queue` (optional) - Set of queue IDs for filtering the matchlist. + /// * `season` (optional) - Set of season IDs for filtering the matchlist. + /// * `endTime` (optional) - The end time to use for filtering matchlist specified as epoch milliseconds. If beginTime is specified, but not endTime, then endTime defaults to the the current unix timestamp in milliseconds (the maximum time range limitation is not observed in this specific case). If endTime is specified, but not beginTime, then beginTime defaults to the start of the account's match history returning a 400 due to the maximum time range limitation. If both are specified, then endTime should be greater than beginTime. The maximum time range allowed is one week, otherwise a 400 error code is returned. + /// * `beginTime` (optional) - The begin time to use for filtering matchlist specified as epoch milliseconds. If beginTime is specified, but not endTime, then endTime defaults to the the current unix timestamp in milliseconds (the maximum time range limitation is not observed in this specific case). If endTime is specified, but not beginTime, then beginTime defaults to the start of the account's match history returning a 400 due to the maximum time range limitation. If both are specified, then endTime should be greater than beginTime. The maximum time range allowed is one week, otherwise a 400 error code is returned. + /// * `endIndex` (optional) - The end index to use for filtering matchlist. If beginIndex is specified, but not endIndex, then endIndex defaults to beginIndex+100. If endIndex is specified, but not beginIndex, then beginIndex defaults to 0. If both are specified, then endIndex must be greater than beginIndex. The maximum range allowed is 100, otherwise a 400 error code is returned. + /// * `beginIndex` (optional) - The begin index to use for filtering matchlist. If beginIndex is specified, but not endIndex, then endIndex defaults to beginIndex+100. If endIndex is specified, but not beginIndex, then beginIndex defaults to 0. If both are specified, then endIndex must be greater than beginIndex. The maximum range allowed is 100, otherwise a 400 error code is returned. + pub async fn match_v4_get_matchlist(&'a self, region: Region, encrypted_account_id: &str, champion: Option>, queue: Option>, season: Option>, end_time: Option, begin_time: Option, end_index: Option, begin_index: Option) -> Result, reqwest::Error> { + let mut query_params = Serializer::new(String::new()); + if let Some(champion) = champion { query_params.extend_pairs(champion.iter().map(|w| ("champion", w.to_string()))); }; + if let Some(queue) = queue { query_params.extend_pairs(queue.iter().map(|w| ("queue", w.to_string()))); }; + if let Some(season) = season { query_params.extend_pairs(season.iter().map(|w| ("season", w.to_string()))); }; + if let Some(end_time) = end_time { query_params.append_pair("endTime", &*end_time.to_string()); }; + if let Some(begin_time) = begin_time { query_params.append_pair("beginTime", &*begin_time.to_string()); }; + if let Some(end_index) = end_index { query_params.append_pair("endIndex", &*end_index.to_string()); }; + if let Some(begin_index) = begin_index { query_params.append_pair("beginIndex", &*begin_index.to_string()); }; + let query_string = query_params.finish(); + let path_string = format!("/lol/match/v4/matchlists/by-account/{}", encrypted_account_id); + return self.requester_manager.get::( + "match-v4.getMatchlist", region, &*path_string, + Some(&*query_string)).await; // false); + } + + /// Get match timeline by match ID. + /// ## Implementation Notes + /// Not all matches have timeline data. + /// # Official API Reference + /// https://developer.riotgames.com/api-methods/#match-v4/GET_getMatchTimeline + /// # Parameters + /// * `region` - Region to query. + /// * `matchId` - The match ID. + pub async fn match_v4_get_match_timeline(&'a self, region: Region, match_id: i64) -> Result, reqwest::Error> { + let path_string = format!("/lol/match/v4/timelines/by-match/{}", match_id); + return self.requester_manager.get::( + "match-v4.getMatchTimeline", region, &*path_string, + None).await; // false); + } + +} + +// SpectatorV4 +impl<'a> RiotApi<'a> { + /// Get current game information for the given summoner ID. + /// # Official API Reference + /// https://developer.riotgames.com/api-methods/#spectator-v4/GET_getCurrentGameInfoBySummoner + /// # Parameters + /// * `region` - Region to query. + /// * `encryptedSummonerId` - The ID of the summoner. + pub async fn spectator_v4_get_current_game_info_by_summoner(&'a self, region: Region, encrypted_summoner_id: &str) -> Result, reqwest::Error> { + let path_string = format!("/lol/spectator/v4/active-games/by-summoner/{}", encrypted_summoner_id); + return self.requester_manager.get::( + "spectator-v4.getCurrentGameInfoBySummoner", region, &*path_string, + None).await; // false); + } + + /// Get list of featured games. + /// # Official API Reference + /// https://developer.riotgames.com/api-methods/#spectator-v4/GET_getFeaturedGames + /// # Parameters + /// * `region` - Region to query. + pub async fn spectator_v4_get_featured_games(&'a self, region: Region) -> Result, reqwest::Error> { + let path_string = "/lol/spectator/v4/featured-games"; + return self.requester_manager.get::( + "spectator-v4.getFeaturedGames", region, &*path_string, + None).await; // false); + } + +} + +// SummonerV4 +impl<'a> RiotApi<'a> { + /// Get a summoner by account ID. + /// # Official API Reference + /// https://developer.riotgames.com/api-methods/#summoner-v4/GET_getByAccountId + /// # Parameters + /// * `region` - Region to query. + /// * `encryptedAccountId` + pub async fn summoner_v4_get_by_account_id(&'a self, region: Region, encrypted_account_id: &str) -> Result, reqwest::Error> { + let path_string = format!("/lol/summoner/v4/summoners/by-account/{}", encrypted_account_id); + return self.requester_manager.get::( + "summoner-v4.getByAccountId", region, &*path_string, + None).await; // false); + } + + /// Get a summoner by summoner name. + /// # Official API Reference + /// https://developer.riotgames.com/api-methods/#summoner-v4/GET_getBySummonerName + /// # Parameters + /// * `region` - Region to query. + /// * `summonerName` - Summoner Name + pub async fn summoner_v4_get_by_summoner_name(&'a self, region: Region, summoner_name: &str) -> Result, reqwest::Error> { + let path_string = format!("/lol/summoner/v4/summoners/by-name/{}", summoner_name); + return self.requester_manager.get::( + "summoner-v4.getBySummonerName", region, &*path_string, + None).await; // false); + } + + /// Get a summoner by PUUID. + /// # Official API Reference + /// https://developer.riotgames.com/api-methods/#summoner-v4/GET_getByPUUID + /// # Parameters + /// * `region` - Region to query. + /// * `encryptedPUUID` - Summoner ID + pub async fn summoner_v4_get_by_puuid(&'a self, region: Region, encrypted_puuid: &str) -> Result, reqwest::Error> { + let path_string = format!("/lol/summoner/v4/summoners/by-puuid/{}", encrypted_puuid); + return self.requester_manager.get::( + "summoner-v4.getByPUUID", region, &*path_string, + None).await; // false); + } + + /// Get a summoner by summoner ID. + /// # Official API Reference + /// https://developer.riotgames.com/api-methods/#summoner-v4/GET_getBySummonerId + /// # Parameters + /// * `region` - Region to query. + /// * `encryptedSummonerId` - Summoner ID + pub async fn summoner_v4_get_by_summoner_id(&'a self, region: Region, encrypted_summoner_id: &str) -> Result, reqwest::Error> { + let path_string = format!("/lol/summoner/v4/summoners/{}", encrypted_summoner_id); + return self.requester_manager.get::( + "summoner-v4.getBySummonerId", region, &*path_string, + None).await; // false); + } + +} + +// ThirdPartyCodeV4 +impl<'a> RiotApi<'a> { + /// Get third party code for a given summoner ID. + /// # Official API Reference + /// https://developer.riotgames.com/api-methods/#third-party-code-v4/GET_getThirdPartyCodeBySummonerId + /// # Parameters + /// * `region` - Region to query. + /// * `encryptedSummonerId` + pub async fn third_party_code_v4_get_third_party_code_by_summoner_id(&'a self, region: Region, encrypted_summoner_id: &str) -> Result, reqwest::Error> { + let path_string = format!("/lol/platform/v4/third-party-code/by-summoner/{}", encrypted_summoner_id); + return self.requester_manager.get::( + "third-party-code-v4.getThirdPartyCodeBySummonerId", region, &*path_string, + None).await; // false); + } + +} + +// TournamentStubV4 +impl<'a> RiotApi<'a> { + /// Gets a mock list of lobby events by tournament code. + /// # Official API Reference + /// https://developer.riotgames.com/api-methods/#tournament-stub-v4/GET_getLobbyEventsByCode + /// # Parameters + /// * `region` - Region to query. + /// * `tournamentCode` - The short code to look up lobby events for + pub async fn tournament_stub_v4_get_lobby_events_by_code(&'a self, region: Region, tournament_code: &str) -> Result, reqwest::Error> { + let path_string = format!("/lol/tournament-stub/v4/lobby-events/by-code/{}", tournament_code); + return self.requester_manager.get::( + "tournament-stub-v4.getLobbyEventsByCode", region, &*path_string, + None).await; // false); + } + +} + +// TournamentV4 +impl<'a> RiotApi<'a> { + /// Returns the tournament code DTO associated with a tournament code string. + /// # Official API Reference + /// https://developer.riotgames.com/api-methods/#tournament-v4/GET_getTournamentCode + /// # Parameters + /// * `region` - Region to query. + /// * `tournamentCode` - The tournament code string. + pub async fn tournament_v4_get_tournament_code(&'a self, region: Region, tournament_code: &str) -> Result, reqwest::Error> { + let path_string = format!("/lol/tournament/v4/codes/{}", tournament_code); + return self.requester_manager.get::( + "tournament-v4.getTournamentCode", region, &*path_string, + None).await; // false); + } + + /// Gets a list of lobby events by tournament code. + /// # Official API Reference + /// https://developer.riotgames.com/api-methods/#tournament-v4/GET_getLobbyEventsByCode + /// # Parameters + /// * `region` - Region to query. + /// * `tournamentCode` - The short code to look up lobby events for + pub async fn tournament_v4_get_lobby_events_by_code(&'a self, region: Region, tournament_code: &str) -> Result, reqwest::Error> { + let path_string = format!("/lol/tournament/v4/lobby-events/by-code/{}", tournament_code); + return self.requester_manager.get::( + "tournament-v4.getLobbyEventsByCode", region, &*path_string, + None).await; // false); + } + +} diff --git a/srcgen/endpoints.rs.dt b/srcgen/endpoints.rs.dt new file mode 100644 index 0000000..689905c --- /dev/null +++ b/srcgen/endpoints.rs.dt @@ -0,0 +1,133 @@ +{{ + const spec = require('./.spec.json'); + const dotUtils = require('./dotUtils.js'); +}} +// This file is automatically generated. +// Do not directly edit. +// Generated on {{= (new Date).toISOString() }} + +// http://www.mingweisamuel.com/riotapi-schema/tool/ +// Version {{= spec.info.version }} + +use std::vec::Vec; + +use reqwest; +use url::form_urlencoded::Serializer; + +use crate::consts::Region; +use crate::riot_api::RiotApi; + +{{ + const endpointGroups = {}; + for (let path of Object.entries(spec.paths)) { + let ep = path[1]['x-endpoint']; + endpointGroups[ep] = endpointGroups[ep] || []; + endpointGroups[ep].push(path); + } + + for (let [ endpointName, endpointMethods ] of Object.entries(endpointGroups)) { + let endpoint = dotUtils.changeCase.pascalCase(endpointName); +}} + +// {{= endpoint }} +impl<'a> RiotApi<'a> { +{{ + for (let [ route, path ] of endpointMethods) + { + let get = path.get; + if (!get) + continue; + let operationId = get.operationId; + let method = dotUtils.changeCase.snakeCase(operationId.slice(operationId.indexOf('.') + 1)); + + let jsonInfo = get.responses['200'].content['application/json']; + let returnType = dotUtils.stringifyType(jsonInfo.schema, endpoint, false, false); + + /* Cases if not rate limited. */ + let rateLimitExcluded = get['x-app-rate-limit-excluded'] ? true : false; + + /* Description processing. */ + let desc = get.description; + let descArr = desc + .replace(/(#+)\s*([^\\]+)\\n(.*?)([\\n$])/g, + (m, g1, g2, g3, g4) => `${g2}\\n${g3}${g4}`) + .split('\n'); + + /* Build argument comment & string. */ + let argBuilder = []; + let makeParamCode = ''; + let allParams = get.parameters; + let queryParams = []; + let routeArgument = dotUtils.formatRouteArgument(route); + if (allParams && allParams.length) + { + let pathParams = allParams.filter(p => 'path' === p.in) + .sort(p => route.indexOf(p.name)); + let reqParams = allParams.filter(p => 'path' !== p.in && p.required); + let optParams = allParams.filter(p => 'path' !== p.in && !p.required) + .sort(p => { + let match = /(^[a-z]+|[A-Z]+(?![a-z])|[A-Z][a-z]+)/.exec(p.name); + return match.slice(1).reverse().join(''); + }); + queryParams = reqParams.concat(optParams); + + for (let paramList of [ pathParams, reqParams, optParams ]) + { + let required = paramList === pathParams; + for (let param of paramList) + { + argBuilder.push(', ', dotUtils.changeCase.snakeCase(param.name), ': ', + dotUtils.stringifyType(param.schema, endpoint, !required, true, false)); + } + } + + routeArgument = dotUtils.formatRouteArgument(route, pathParams); + } + for (var descLine of descArr) + { +}} + ///{{= descLine ? ' ' + descLine : '' }} +{{ + } +}} + /// # {{= get.externalDocs.description }} + /// {{= get.externalDocs.url }} + /// # Parameters + /// * `region` - Region to query. +{{ + if (allParams) + { + for (let param of allParams) + { +}} + /// * `{{= param.name }}`{{= param.required ? '' : ' (optional)' }}{{= param.description ? ' - ' + param.description : ''}} +{{ + } + } +}} + pub async fn {{= dotUtils.changeCase.snakeCase(endpoint) }}_{{= method }}(&'a self, region: Region{{= argBuilder.join('') }}) -> Result, reqwest::Error> { +{{? queryParams.length }} + let mut query_params = Serializer::new(String::new()); +{{ + for (let queryParam of queryParams) + { +}} + {{= dotUtils.formatAddQueryParam(queryParam) }}; +{{ + } +}} + let query_string = query_params.finish(); +{{?}} + let path_string = {{= routeArgument }}; + return self.requester_manager.get::<{{= returnType }}>( + "{{= operationId }}", region, &*path_string, + {{= queryParams.length ? 'Some(&*query_string)' : 'None' }}).await; // {{= rateLimitExcluded }}); + } + +{{ + } +}} +} +{{ + } +}} diff --git a/srcgen/mod.rs b/srcgen/mod.rs index 61a6519..60b1ab3 100644 --- a/srcgen/mod.rs +++ b/srcgen/mod.rs @@ -1,2 +1,7 @@ mod champion; + mod dto; +pub use dto::*; + +mod endpoints; +pub use endpoints::*; diff --git a/srcgen/package-lock.json b/srcgen/package-lock.json index ac18486..99e8c37 100644 --- a/srcgen/package-lock.json +++ b/srcgen/package-lock.json @@ -90,11 +90,45 @@ "concat-map": "0.0.1" } }, + "camel-case": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/camel-case/-/camel-case-3.0.0.tgz", + "integrity": "sha1-yjw2iKTpzzpM2nd9xNy8cTJJz3M=", + "requires": { + "no-case": "^2.2.0", + "upper-case": "^1.1.1" + } + }, "caseless": { "version": "0.12.0", "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", "integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=" }, + "change-case": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/change-case/-/change-case-3.1.0.tgz", + "integrity": "sha512-2AZp7uJZbYEzRPsFoa+ijKdvp9zsrnnt6+yFokfwEpeJm0xuJDVoxiRCAaTzyJND8GJkofo2IcKWaUZ/OECVzw==", + "requires": { + "camel-case": "^3.0.0", + "constant-case": "^2.0.0", + "dot-case": "^2.1.0", + "header-case": "^1.0.0", + "is-lower-case": "^1.1.0", + "is-upper-case": "^1.1.0", + "lower-case": "^1.1.1", + "lower-case-first": "^1.0.0", + "no-case": "^2.3.2", + "param-case": "^2.1.0", + "pascal-case": "^2.0.0", + "path-case": "^2.1.0", + "sentence-case": "^2.1.0", + "snake-case": "^2.1.0", + "swap-case": "^1.1.0", + "title-case": "^2.1.0", + "upper-case": "^1.1.1", + "upper-case-first": "^1.1.0" + } + }, "combined-stream": { "version": "1.0.8", "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", @@ -108,6 +142,15 @@ "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" }, + "constant-case": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/constant-case/-/constant-case-2.0.0.tgz", + "integrity": "sha1-QXV2TTidP6nI7NKRhu1gBSQ7akY=", + "requires": { + "snake-case": "^2.1.0", + "upper-case": "^1.1.1" + } + }, "core-util-is": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", @@ -131,6 +174,14 @@ "resolved": "https://registry.npmjs.org/dot/-/dot-1.1.2.tgz", "integrity": "sha1-xzdwGfxOVQeYkosrmv62ar+h8vk=" }, + "dot-case": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/dot-case/-/dot-case-2.1.1.tgz", + "integrity": "sha1-NNzzf1Co6TwrO8qLt/uRVcfaO+4=", + "requires": { + "no-case": "^2.2.0" + } + }, "ecc-jsbn": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz", @@ -223,6 +274,15 @@ "har-schema": "^2.0.0" } }, + "header-case": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/header-case/-/header-case-1.0.1.tgz", + "integrity": "sha1-lTWXMZfBRLCWE81l0xfvGZY70C0=", + "requires": { + "no-case": "^2.2.0", + "upper-case": "^1.1.3" + } + }, "http-signature": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz", @@ -247,11 +307,27 @@ "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" }, + "is-lower-case": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/is-lower-case/-/is-lower-case-1.1.3.tgz", + "integrity": "sha1-fhR75HaNxGbbO/shzGCzHmrWk5M=", + "requires": { + "lower-case": "^1.1.0" + } + }, "is-typedarray": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", "integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=" }, + "is-upper-case": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/is-upper-case/-/is-upper-case-1.1.2.tgz", + "integrity": "sha1-jQsfp+eTOh5YSDYA7H2WYcuvdW8=", + "requires": { + "upper-case": "^1.1.0" + } + }, "isstream": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", @@ -293,6 +369,19 @@ "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz", "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==" }, + "lower-case": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/lower-case/-/lower-case-1.1.4.tgz", + "integrity": "sha1-miyr0bno4K6ZOkv31YdcOcQujqw=" + }, + "lower-case-first": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/lower-case-first/-/lower-case-first-1.0.2.tgz", + "integrity": "sha1-5dp8JvKacHO+AtUrrJmA5ZIq36E=", + "requires": { + "lower-case": "^1.1.2" + } + }, "mime-db": { "version": "1.40.0", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.40.0.tgz", @@ -314,6 +403,14 @@ "brace-expansion": "^1.1.7" } }, + "no-case": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/no-case/-/no-case-2.3.2.tgz", + "integrity": "sha512-rmTZ9kz+f3rCvK2TD1Ue/oZlns7OGoIWP4fc3llxxRXlOkHKoWPPWJOfFYpITabSow43QJbRIoHQXtt10VldyQ==", + "requires": { + "lower-case": "^1.1.1" + } + }, "oauth-sign": { "version": "0.9.0", "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.9.0.tgz", @@ -327,6 +424,31 @@ "wrappy": "1" } }, + "param-case": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/param-case/-/param-case-2.1.1.tgz", + "integrity": "sha1-35T9jPZTHs915r75oIWPvHK+Ikc=", + "requires": { + "no-case": "^2.2.0" + } + }, + "pascal-case": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/pascal-case/-/pascal-case-2.0.1.tgz", + "integrity": "sha1-LVeNNFX2YNpl7KGO+VtODekSdh4=", + "requires": { + "camel-case": "^3.0.0", + "upper-case-first": "^1.1.0" + } + }, + "path-case": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/path-case/-/path-case-2.1.1.tgz", + "integrity": "sha1-lLgDfDctP+KQbkZbtF4l0ibo7qU=", + "requires": { + "no-case": "^2.2.0" + } + }, "path-is-absolute": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", @@ -407,6 +529,23 @@ "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" }, + "sentence-case": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/sentence-case/-/sentence-case-2.1.1.tgz", + "integrity": "sha1-H24t2jnBaL+S0T+G1KkYkz9mftQ=", + "requires": { + "no-case": "^2.2.0", + "upper-case-first": "^1.1.2" + } + }, + "snake-case": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/snake-case/-/snake-case-2.1.0.tgz", + "integrity": "sha1-Qb2xtz8w7GagTU4srRt2OH1NbZ8=", + "requires": { + "no-case": "^2.2.0" + } + }, "sshpk": { "version": "1.16.1", "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.16.1.tgz", @@ -428,6 +567,24 @@ "resolved": "https://registry.npmjs.org/stealthy-require/-/stealthy-require-1.1.1.tgz", "integrity": "sha1-NbCYdbT/SfJqd35QmzCQoyJr8ks=" }, + "swap-case": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/swap-case/-/swap-case-1.1.2.tgz", + "integrity": "sha1-w5IDpFhzhfrTyFCgvRvK+ggZdOM=", + "requires": { + "lower-case": "^1.1.1", + "upper-case": "^1.1.1" + } + }, + "title-case": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/title-case/-/title-case-2.1.1.tgz", + "integrity": "sha1-PhJyFtpY0rxb7PE3q5Ha46fNj6o=", + "requires": { + "no-case": "^2.2.0", + "upper-case": "^1.0.3" + } + }, "tough-cookie": { "version": "2.4.3", "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.4.3.tgz", @@ -457,6 +614,19 @@ "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz", "integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=" }, + "upper-case": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/upper-case/-/upper-case-1.1.3.tgz", + "integrity": "sha1-9rRQHC7EzdJrp4vnIilh3ndiFZg=" + }, + "upper-case-first": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/upper-case-first/-/upper-case-first-1.1.2.tgz", + "integrity": "sha1-XXm+3P8UQZUY/S7bCgUHybaFkRU=", + "requires": { + "upper-case": "^1.1.1" + } + }, "uri-js": { "version": "4.2.2", "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.2.2.tgz", diff --git a/srcgen/package.json b/srcgen/package.json index 9a0b180..70e5ad8 100644 --- a/srcgen/package.json +++ b/srcgen/package.json @@ -4,11 +4,12 @@ "description": "", "main": "index.js", "dependencies": { - "request": "^2.88.0", - "request-promise-native": "^1.0.7", + "change-case": "^3.1.0", "dot": "^1.1.2", "glob": "^7.1.2", - "glob-promise": "^3.3.0" + "glob-promise": "^3.3.0", + "request": "^2.88.0", + "request-promise-native": "^1.0.7" }, "devDependencies": {}, "scripts": {