From 5be2884eb4ad730b69fd53ca32fb339aeb114e69 Mon Sep 17 00:00:00 2001 From: Mingwei Samuel Date: Thu, 1 Oct 2020 06:13:14 +0000 Subject: [PATCH] Regen, add tests for new optional fields https://github.com/MingweiSamuel/riotapi-schema/pull/22 --- src/endpoints.rs | 19 +++++++++++- src/meta.rs | 3 +- src/models.rs | 77 +++++++++++++++++++++++++++-------------------- test.bash | 0 tests/tests_na.rs | 37 +++++++++++++++++------ 5 files changed, 93 insertions(+), 43 deletions(-) mode change 100644 => 100755 test.bash diff --git a/src/endpoints.rs b/src/endpoints.rs index 5097605..c5becbf 100644 --- a/src/endpoints.rs +++ b/src/endpoints.rs @@ -7,7 +7,7 @@ /////////////////////////////////////////////// // http://www.mingweisamuel.com/riotapi-schema/tool/ -// Version e9fad555098e217edc088cc4b1ecc6fe095ba6cb +// Version c3b3f5733c36c6f30546aa9ed598c05d39c670be //! Automatically generated endpoint handles. @@ -1216,4 +1216,21 @@ impl<'a> ValMatchV1<'a> { self.base.get::("val-match-v1.getMatchlist", region.into(), path_string, None) } + /// Get recent matches + /// ## Implementation Notes + /// Returns a list of match ids that have completed in the last 10 minutes. NA/LATAM/BR share a match history deployment. As such, recent matches will return a combined list of matches from those three regions. Requests are load balanced so you may see some inconsistencies as matches are added/removed from the list. + /// # Parameters + /// * `region` - Region to query. + /// * `queue` + /// # Riot Developer API Reference + /// `val-match-v1.getRecent` + /// + /// Note: this method is automatically generated. + pub fn get_recent(&self, region: Region, queue: &str) + -> impl Future> + 'a + { + let path_string = format!("/val/match/v1/recent-matches/by-queue/{}", queue); + self.base.get::("val-match-v1.getRecent", region.into(), path_string, None) + } + } diff --git a/src/meta.rs b/src/meta.rs index a4698d4..b9bffb3 100644 --- a/src/meta.rs +++ b/src/meta.rs @@ -7,7 +7,7 @@ /////////////////////////////////////////////// // http://www.mingweisamuel.com/riotapi-schema/tool/ -// Version e9fad555098e217edc088cc4b1ecc6fe095ba6cb +// Version c3b3f5733c36c6f30546aa9ed598c05d39c670be //! Metadata about the Riot API and Riven. //! @@ -71,6 +71,7 @@ lazy_static! { map.insert("/val/content/v1/contents", "val-content-v1.getContent"); map.insert("/val/match/v1/matches/{matchId}", "val-match-v1.getMatch"); map.insert("/val/match/v1/matchlists/by-puuid/{puuid}", "val-match-v1.getMatchlist"); + map.insert("/val/match/v1/recent-matches/by-queue/{queue}", "val-match-v1.getRecent"); map }; } diff --git a/src/models.rs b/src/models.rs index 0ea0498..61334b0 100644 --- a/src/models.rs +++ b/src/models.rs @@ -7,7 +7,7 @@ /////////////////////////////////////////////// // http://www.mingweisamuel.com/riotapi-schema/tool/ -// Version e9fad555098e217edc088cc4b1ecc6fe095ba6cb +// Version c3b3f5733c36c6f30546aa9ed598c05d39c670be //! Data transfer structs. //! @@ -365,25 +365,25 @@ pub mod lol_status_v3 { #[derive(Debug)] #[derive(serde::Serialize, serde::Deserialize)] pub struct Service { - #[serde(rename = "incidents")] - pub incidents: std::vec::Vec, #[serde(rename = "name")] pub name: String, #[serde(rename = "slug")] pub slug: String, #[serde(rename = "status")] pub status: String, + #[serde(rename = "incidents")] + pub incidents: std::vec::Vec, } /// Incident data object. #[derive(Debug)] #[derive(serde::Serialize, serde::Deserialize)] pub struct Incident { + #[serde(rename = "id")] + pub id: i64, #[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, } @@ -391,31 +391,33 @@ pub mod lol_status_v3 { #[derive(Debug)] #[derive(serde::Serialize, serde::Deserialize)] pub struct Message { - #[serde(rename = "severity")] - pub severity: String, - #[serde(rename = "updated_at")] - pub updated_at: String, - #[serde(rename = "author")] - pub author: String, - #[serde(rename = "translations")] - pub translations: std::vec::Vec, - #[serde(rename = "created_at")] - pub created_at: String, #[serde(rename = "id")] pub id: String, + #[serde(rename = "author")] + pub author: String, + #[serde(rename = "heading")] + pub heading: String, #[serde(rename = "content")] pub content: String, + #[serde(rename = "severity")] + pub severity: String, + #[serde(rename = "created_at")] + pub created_at: String, + #[serde(rename = "updated_at")] + pub updated_at: String, + #[serde(rename = "translations")] + pub translations: std::vec::Vec, } /// Translation data object. #[derive(Debug)] #[derive(serde::Serialize, serde::Deserialize)] pub struct Translation { + #[serde(rename = "updated_at")] + pub updated_at: String, #[serde(rename = "locale")] pub locale: String, #[serde(rename = "content")] pub content: String, - #[serde(rename = "heading")] - pub heading: String, } } @@ -614,7 +616,7 @@ pub mod match_v4 { pub team_id: crate::consts::Team, /// Participant timeline data. #[serde(rename = "timeline")] - pub timeline: ParticipantTimeline, + pub timeline: Option, /// First Summoner Spell id. #[serde(rename = "spell1Id")] pub spell1_id: i32, @@ -677,7 +679,7 @@ pub mod match_v4 { #[serde(rename = "magicDamageDealtToChampions")] pub magic_damage_dealt_to_champions: i64, #[serde(rename = "wardsKilled")] - pub wards_killed: i32, + pub wards_killed: Option, #[serde(rename = "pentaKills")] pub penta_kills: i32, #[serde(rename = "damageSelfMitigated")] @@ -711,7 +713,7 @@ pub mod match_v4 { #[serde(rename = "physicalDamageDealtToChampions")] pub physical_damage_dealt_to_champions: i64, #[serde(rename = "neutralMinionsKilledTeamJungle")] - pub neutral_minions_killed_team_jungle: i32, + pub neutral_minions_killed_team_jungle: Option, #[serde(rename = "totalMinionsKilled")] pub total_minions_killed: i32, #[serde(rename = "firstInhibitorAssist")] @@ -771,7 +773,7 @@ pub mod match_v4 { #[serde(rename = "trueDamageDealtToChampions")] pub true_damage_dealt_to_champions: i64, #[serde(rename = "neutralMinionsKilledEnemyJungle")] - pub neutral_minions_killed_enemy_jungle: i32, + pub neutral_minions_killed_enemy_jungle: Option, #[serde(rename = "doubleKills")] pub double_kills: i32, #[serde(rename = "trueDamageDealt")] @@ -884,13 +886,13 @@ pub mod match_v4 { /// Secondary rune path #[serde(rename = "perkSubStyle")] pub perk_sub_style: Option, - /// First stat rune. + /// Stat rune #[serde(rename = "statPerk0")] pub stat_perk0: Option, - /// Second stat rune. + /// Stat rune #[serde(rename = "statPerk1")] pub stat_perk1: Option, - /// Third stat rune. + /// Stat rune #[serde(rename = "statPerk2")] pub stat_perk2: Option, } @@ -960,7 +962,7 @@ pub mod match_v4 { #[serde(rename = "gameId")] pub game_id: i64, #[serde(rename = "role")] - pub role: String, + pub role: Option, #[serde(rename = "season")] pub season: i32, #[serde(rename = "platformId")] @@ -970,7 +972,7 @@ pub mod match_v4 { #[serde(rename = "queue")] pub queue: crate::consts::Queue, #[serde(rename = "lane")] - pub lane: String, + pub lane: Option, #[serde(rename = "timestamp")] pub timestamp: i64, } @@ -1874,8 +1876,13 @@ pub mod val_content_v1 { /// This field is excluded from the response when a locale is set #[serde(rename = "localizedNames")] pub localized_names: Option, + #[serde(rename = "id")] + pub id: String, #[serde(rename = "assetName")] pub asset_name: String, + /// This field is only included for maps and game modes. These values are used in the match response. + #[serde(rename = "assetPath")] + pub asset_path: String, } /// LocalizedNames data object. #[derive(Debug)] @@ -2115,14 +2122,10 @@ pub mod val_match_v1 { #[derive(Debug)] #[derive(serde::Serialize, serde::Deserialize)] pub struct Kill { - #[serde(rename = "gameTime")] - pub game_time: Option, - #[serde(rename = "roundTime")] - pub round_time: Option, #[serde(rename = "timeSinceGameStartMillis")] - pub time_since_game_start_millis: Option, + pub time_since_game_start_millis: i32, #[serde(rename = "timeSinceRoundStartMillis")] - pub time_since_round_start_millis: Option, + pub time_since_round_start_millis: i32, /// PUUID #[serde(rename = "killer")] pub killer: String, @@ -2214,4 +2217,14 @@ pub mod val_match_v1 { #[serde(rename = "teamId")] pub team_id: String, } + /// RecentMatches data object. + #[derive(Debug)] + #[derive(serde::Serialize, serde::Deserialize)] + pub struct RecentMatches { + #[serde(rename = "currentTime")] + pub current_time: i64, + /// A list of recent match ids. + #[serde(rename = "matchIds")] + pub match_ids: std::vec::Vec, + } } diff --git a/test.bash b/test.bash old mode 100644 new mode 100755 diff --git a/tests/tests_na.rs b/tests/tests_na.rs index 5093abb..eee3375 100644 --- a/tests/tests_na.rs +++ b/tests/tests_na.rs @@ -45,6 +45,17 @@ async_tests!{ rassert!(!d.is_empty(), "Challenger shouldn't be empty."); Ok(()) }, + + matchlist_get: async { + + let sp = RIOT_API.summoner_v4().get_by_summoner_name(Region::NA, "haha yes"); + let s = sp.await.map_err(|e| e.to_string())?.ok_or("Failed to get \"haha yes\"".to_owned())?; + let mp = RIOT_API.match_v4().get_matchlist(Region::NA, &s.account_id, None, Some(2500), None, None, Some(2600), None, None); + let m = mp.await.map_err(|e| e.to_string())?.ok_or("Failed to get matchlist".to_owned())?; + rassert!(m.matches.len() > 0, "Matchlist should not be empty"); + Ok(()) + }, + match_get: async { let p = RIOT_API.match_v4().get_match(Region::NA, 3190191338); let m = p.await.map_err(|e| e.to_string())?.ok_or("Match not found.".to_owned())?; @@ -57,23 +68,24 @@ async_tests!{ 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())?; - rassert!(!m.frames.is_empty(), "Match timeline should have frames."); + match_get_odyssey: async { + let p = RIOT_API.match_v4().get_match(Region::NA, 2881976826); + 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_get_old: async { - // let p = RIOT_API.match_v4().get_match(Region::NA, 2632789562); - // let m = p.await.map_err(|e| e.to_string())?.ok_or("Failed to get match.".to_owned())?; - // Ok(()) - // }, match_get_aram: async { let p = RIOT_API.match_v4().get_match(Region::NA, 2961635718); let m = p.await.map_err(|e| e.to_string())?.ok_or("Failed to get match.".to_owned())?; rassert!(!m.participants.is_empty(), "Match should have participants."); Ok(()) }, + match_get_aram2: async { + let p = RIOT_API.match_v4().get_match(Region::NA, 3596184782); + 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_get_urf900: async { let p = RIOT_API.match_v4().get_match(Region::NA, 2963663381); let m = p.await.map_err(|e| e.to_string())?.ok_or("Failed to get match.".to_owned())?; @@ -98,6 +110,13 @@ async_tests!{ 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())?; + rassert!(!m.frames.is_empty(), "Match timeline should have frames."); + Ok(()) + }, // Commented out, requires special API key. // // LOR // lor_ranked_get_leaderboards: async {