From 1a88ae6365971e68057e9a929295ab083b5b6e52 Mon Sep 17 00:00:00 2001 From: Mingwei Samuel Date: Sun, 26 Jul 2020 16:33:03 -0700 Subject: [PATCH] Update for account-v1 endpoint, fix for missing match-v4.PlayerDto.summonerId on bot games Also adds test with bot game. --- src/consts/champion.rs | 3 ++ src/endpoints.rs | 69 +++++++++++++++++++++++++++++++++++++++++- src/meta.rs | 5 ++- src/models.rs | 33 ++++++++++++++++++-- tests/tests_na.rs | 6 ++++ 5 files changed, 112 insertions(+), 4 deletions(-) diff --git a/src/consts/champion.rs b/src/consts/champion.rs index 31da2ba..7cd5d6a 100644 --- a/src/consts/champion.rs +++ b/src/consts/champion.rs @@ -310,6 +310,8 @@ pub enum Champion { #[strum(to_string="Xin Zhao", serialize="XinZhao")] XinZhao = 5, /// Yasuo (`Yasuo`, 157). #[strum(to_string="Yasuo", serialize="Yasuo")] Yasuo = 157, + /// Yone (`Yone`, 777). + #[strum(to_string="Yone", serialize="Yone")] Yone = 777, /// Yorick (`Yorick`, 83). #[strum(to_string="Yorick", serialize="Yorick")] Yorick = 83, /// Yuumi (`Yuumi`, 350). @@ -495,6 +497,7 @@ impl Champion { Self::Xerath => "Xerath", Self::XinZhao => "XinZhao", Self::Yasuo => "Yasuo", + Self::Yone => "Yone", Self::Yorick => "Yorick", Self::Yuumi => "Yuumi", Self::Zac => "Zac", diff --git a/src/endpoints.rs b/src/endpoints.rs index f891aed..601a1fc 100644 --- a/src/endpoints.rs +++ b/src/endpoints.rs @@ -7,7 +7,7 @@ /////////////////////////////////////////////// // http://www.mingweisamuel.com/riotapi-schema/tool/ -// Version af29e140a03aabbd77664b926746eecaae877d2b +// Version d1d3a7a4176fd7b1ca98b43811dbe6ac3951b9b6 //! Automatically generated endpoint handles. @@ -23,6 +23,15 @@ use crate::consts::Region; use crate::riot_api::RiotApi; impl RiotApi { + /// Returns a handle for accessing [AccountV1](crate::endpoints::AccountV1) endpoints. + /// # Riot Developer API Reference + /// `account-v1` + /// + /// Note: this method is automatically generated. + #[inline] + pub fn account_v1(&self) -> AccountV1 { + AccountV1 { base: self } + } /// Returns a handle for accessing [ChampionMasteryV4](crate::endpoints::ChampionMasteryV4) endpoints. /// # Riot Developer API Reference /// `champion-mastery-v4` @@ -187,6 +196,64 @@ impl RiotApi { } } +/// AccountV1 endpoints handle, accessed by calling [`account_v1()`](crate::RiotApi::account_v1) on a [`RiotApi`](crate::RiotApi) instance. +/// # Riot Developer API Reference +/// `account-v1` +/// +/// Note: this struct is automatically generated. +pub struct AccountV1<'a> { + base: &'a RiotApi, +} +impl<'a> AccountV1<'a> { + /// Get account by puuid + /// # Parameters + /// * `region` - Region to query. + /// * `puuid` + /// # Riot Developer API Reference + /// `account-v1.getByPuuid` + /// + /// Note: this method is automatically generated. + pub fn get_by_puuid(&self, region: Region, puuid: &str) + -> impl Future> + 'a + { + let path_string = format!("/riot/account/v1/accounts/by-puuid/{}", puuid); + self.base.get::("account-v1.getByPuuid", region.into(), path_string, None) + } + + /// Get account by riot id + /// # Parameters + /// * `region` - Region to query. + /// * `tagLine` + /// * `gameName` + /// # Riot Developer API Reference + /// `account-v1.getByRiotId` + /// + /// Note: this method is automatically generated. + pub fn get_by_riot_id(&self, region: Region, game_name: &str, tag_line: &str) + -> impl Future>> + 'a + { + let path_string = format!("/riot/account/v1/accounts/by-riot-id/{}/{}", game_name, tag_line); + self.base.get_optional::("account-v1.getByRiotId", region.into(), path_string, None) + } + + /// Get active shard for a player + /// # Parameters + /// * `region` - Region to query. + /// * `puuid` + /// * `game` + /// # Riot Developer API Reference + /// `account-v1.getActiveShard` + /// + /// Note: this method is automatically generated. + pub fn get_active_shard(&self, region: Region, game: &str, puuid: &str) + -> impl Future>> + 'a + { + let path_string = format!("/riot/account/v1/active-shards/by-game/{}/by-puuid/{}", game, puuid); + self.base.get_optional::("account-v1.getActiveShard", region.into(), path_string, None) + } + +} + /// ChampionMasteryV4 endpoints handle, accessed by calling [`champion_mastery_v4()`](crate::RiotApi::champion_mastery_v4) on a [`RiotApi`](crate::RiotApi) instance. /// # Riot Developer API Reference /// `champion-mastery-v4` diff --git a/src/meta.rs b/src/meta.rs index 92422e0..e40d83c 100644 --- a/src/meta.rs +++ b/src/meta.rs @@ -7,7 +7,7 @@ /////////////////////////////////////////////// // http://www.mingweisamuel.com/riotapi-schema/tool/ -// Version af29e140a03aabbd77664b926746eecaae877d2b +// Version d1d3a7a4176fd7b1ca98b43811dbe6ac3951b9b6 //! Metadata about the Riot API and Riven. //! @@ -20,6 +20,9 @@ use lazy_static::lazy_static; lazy_static! { pub static ref ENDPOINT_PATH_METHODID: HashMap<&'static str, &'static str> = { let mut map = HashMap::new(); + map.insert("/riot/account/v1/accounts/by-puuid/{puuid}", "account-v1.getByPuuid"); + map.insert("/riot/account/v1/accounts/by-riot-id/{gameName}/{tagLine}", "account-v1.getByRiotId"); + map.insert("/riot/account/v1/active-shards/by-game/{game}/by-puuid/{puuid}", "account-v1.getActiveShard"); map.insert("/lol/champion-mastery/v4/champion-masteries/by-summoner/{encryptedSummonerId}", "champion-mastery-v4.getAllChampionMasteries"); map.insert("/lol/champion-mastery/v4/champion-masteries/by-summoner/{encryptedSummonerId}/by-champion/{championId}", "champion-mastery-v4.getChampionMastery"); map.insert("/lol/champion-mastery/v4/scores/by-summoner/{encryptedSummonerId}", "champion-mastery-v4.getChampionMasteryScore"); diff --git a/src/models.rs b/src/models.rs index c1c8104..e0f1680 100644 --- a/src/models.rs +++ b/src/models.rs @@ -7,7 +7,7 @@ /////////////////////////////////////////////// // http://www.mingweisamuel.com/riotapi-schema/tool/ -// Version af29e140a03aabbd77664b926746eecaae877d2b +// Version d1d3a7a4176fd7b1ca98b43811dbe6ac3951b9b6 //! Data transfer structs. //! @@ -16,6 +16,35 @@ //! //! Note: these modules are automatically generated. +/// Data structs used by [`AccountV1`](crate::endpoints::AccountV1). +/// +/// Note: this module is automatically generated. +#[allow(dead_code)] +pub mod account_v1 { + /// Account data object. + #[derive(Debug)] + #[derive(serde::Serialize, serde::Deserialize)] + pub struct Account { + #[serde(rename = "puuid")] + pub puuid: String, + #[serde(rename = "gameName")] + pub game_name: String, + #[serde(rename = "tagLine")] + pub tag_line: String, + } + /// ActiveShard data object. + #[derive(Debug)] + #[derive(serde::Serialize, serde::Deserialize)] + pub struct ActiveShard { + #[serde(rename = "puuid")] + pub puuid: String, + #[serde(rename = "game")] + pub game: String, + #[serde(rename = "activeShard")] + pub active_shard: String, + } +} + /// Data structs used by [`ChampionMasteryV4`](crate::endpoints::ChampionMasteryV4). /// /// Note: this module is automatically generated. @@ -494,7 +523,7 @@ pub mod match_v4 { pub summoner_name: String, /// Player's summonerId (Encrypted) #[serde(rename = "summonerId")] - pub summoner_id: String, + pub summoner_id: Option, /// Player's original platformId. #[serde(rename = "platformId")] pub platform_id: String, diff --git a/tests/tests_na.rs b/tests/tests_na.rs index 9b3fcad..1e1ef61 100644 --- a/tests/tests_na.rs +++ b/tests/tests_na.rs @@ -51,6 +51,12 @@ async_tests!{ rassert!(!m.participants.is_empty(), "Match should have participants."); Ok(()) }, + match_get_bots: async { + let p = RIOT_API.match_v4().get_match(Region::NA, 3251803350); + let m = p.await.map_err(|e| e.to_string())?.ok_or("Match not found.".to_owned())?; + rassert!(!m.participants.is_empty(), "Match should have participants."); + Ok(()) + }, match_gettimeline: async { let p = RIOT_API.match_v4().get_match_timeline(Region::NA, 3190191338); let m = p.await.map_err(|e| e.to_string())?.ok_or("Match timeline not found.".to_owned())?;