diff --git a/riven/src/consts/game_mode.rs b/riven/src/consts/game_mode.rs index 98f2d19..122dc21 100644 --- a/riven/src/consts/game_mode.rs +++ b/riven/src/consts/game_mode.rs @@ -38,11 +38,11 @@ pub enum GameMode { DOOMBOTSTEEMO, /// Snowdown Showdown games FIRSTBLOOD, - /// Nexus Blitz games, deprecated in patch 9.2 in favor of gameMode NEXUSBLITZ. + /// Nexus Blitz games GAMEMODEX, /// Legend of the Poro King games KINGPORO, - /// Nexus Blitz games. + /// Nexus Blitz games NEXUSBLITZ, /// Dominion/Crystal Scar games ODIN, @@ -50,6 +50,8 @@ pub enum GameMode { ODYSSEY, /// One for All games ONEFORALL, + /// Practice tool training games. + PRACTICETOOL, /// PROJECT: Hunters games PROJECT, /// Nexus Siege games @@ -64,7 +66,7 @@ pub enum GameMode { TUTORIAL_MODULE_2, /// Tutorial: Shop for Gear. TUTORIAL_MODULE_3, - /// Ultimate Spellbook games. + /// Ultimate Spellbook games ULTBOOK, /// URF games URF, diff --git a/riven/src/consts/tier.rs b/riven/src/consts/tier.rs index 40a7984..703c12c 100644 --- a/riven/src/consts/tier.rs +++ b/riven/src/consts/tier.rs @@ -37,6 +37,8 @@ pub enum Tier { IRON = 40, /// Unranked, no tier. Repr: `0_u8`. + /// Also deserializes from "NONE" returned by `lol-challenges-v1.getChallengePercentiles`. + #[serde(alias = "NONE")] UNRANKED = 0, } diff --git a/riven/src/endpoints.rs b/riven/src/endpoints.rs index a53eec0..1fd6446 100644 --- a/riven/src/endpoints.rs +++ b/riven/src/endpoints.rs @@ -7,7 +7,7 @@ /////////////////////////////////////////////// // http://www.mingweisamuel.com/riotapi-schema/tool/ -// Version 616004110d2cf4f8bb0b1e0332e079399aea56cc +// Version d2e2d8db61e32b60f6722b887694538659c20436 //! Automatically generated endpoint handles. #![allow(clippy::let_and_return, clippy::too_many_arguments)] @@ -80,6 +80,15 @@ impl RiotApi { pub fn league_v4(&self) -> LeagueV4 { LeagueV4 { base: self } } + /// Returns a handle for accessing [LolChallengesV1](crate::endpoints::LolChallengesV1) endpoints. + /// # Riot Developer API Reference + /// `lol-challenges-v1` + /// + /// Note: this method is automatically generated. + #[inline] + pub fn lol_challenges_v1(&self) -> LolChallengesV1 { + LolChallengesV1 { base: self } + } /// Returns a handle for accessing [LolStatusV3](crate::endpoints::LolStatusV3) endpoints. /// # Riot Developer API Reference /// `lol-status-v3` @@ -197,15 +206,6 @@ impl RiotApi { pub fn tft_summoner_v1(&self) -> TftSummonerV1 { TftSummonerV1 { base: self } } - /// Returns a handle for accessing [ThirdPartyCodeV4](crate::endpoints::ThirdPartyCodeV4) endpoints. - /// # Riot Developer API Reference - /// `third-party-code-v4` - /// - /// Note: this method is automatically generated. - #[inline] - pub fn third_party_code_v4(&self) -> ThirdPartyCodeV4 { - ThirdPartyCodeV4 { base: self } - } /// Returns a handle for accessing [TournamentStubV4](crate::endpoints::TournamentStubV4) endpoints. /// # Riot Developer API Reference /// `tournament-stub-v4` @@ -726,6 +726,133 @@ impl<'a> LeagueV4<'a> { } +/// LolChallengesV1 endpoints handle, accessed by calling [`lol_challenges_v1()`](crate::RiotApi::lol_challenges_v1) on a [`RiotApi`](crate::RiotApi) instance. +/// # Riot Developer API Reference +/// `lol-challenges-v1` +/// +/// Note: this struct is automatically generated. +#[repr(transparent)] +pub struct LolChallengesV1<'a> { + base: &'a RiotApi, +} +impl<'a> LolChallengesV1<'a> { + /// List of all basic challenge configuration information (includes all translations for names and descriptions) + /// # Parameters + /// * `route` - Route to query. + /// # Riot Developer API Reference + /// `lol-challenges-v1.getAllChallengeConfigs` + /// + /// Note: this method is automatically generated. + pub fn get_all_challenge_configs(&self, route: PlatformRoute) + -> impl Future>> + 'a + { + let route_str = route.into(); + let request = self.base.request(Method::GET, route_str, "/lol/challenges/v1/challenges/config"); + let future = self.base.execute_val::>("lol-challenges-v1.getAllChallengeConfigs", route_str, request); + #[cfg(feature = "tracing")] + let future = future.instrument(tracing::info_span!("lol-challenges-v1.getAllChallengeConfigs")); + future + } + + /// Map of level to percentile of players who have achieved it - keys: ChallengeId -> Season -> Level -> percentile of players who achieved it + /// # Parameters + /// * `route` - Route to query. + /// # Riot Developer API Reference + /// `lol-challenges-v1.getAllChallengePercentiles` + /// + /// Note: this method is automatically generated. + pub fn get_all_challenge_percentiles(&self, route: PlatformRoute) + -> impl Future>>> + 'a + { + let route_str = route.into(); + let request = self.base.request(Method::GET, route_str, "/lol/challenges/v1/challenges/percentiles"); + let future = self.base.execute_val::>>("lol-challenges-v1.getAllChallengePercentiles", route_str, request); + #[cfg(feature = "tracing")] + let future = future.instrument(tracing::info_span!("lol-challenges-v1.getAllChallengePercentiles")); + future + } + + /// Get challenge configuration (REST) + /// # Parameters + /// * `route` - Route to query. + /// * `challenge_id` (required, in path) + /// # Riot Developer API Reference + /// `lol-challenges-v1.getChallengeConfigs` + /// + /// Note: this method is automatically generated. + pub fn get_challenge_configs(&self, route: PlatformRoute, challenge_id: i64) + -> impl Future>> + 'a + { + let route_str = route.into(); + let request = self.base.request(Method::GET, route_str, &format!("/lol/challenges/v1/challenges/{}/config", challenge_id)); + let future = self.base.execute_opt::("lol-challenges-v1.getChallengeConfigs", route_str, request); + #[cfg(feature = "tracing")] + let future = future.instrument(tracing::info_span!("lol-challenges-v1.getChallengeConfigs")); + future + } + + /// Return top players for each level. Level must be MASTER, GRANDMASTER or CHALLENGER. + /// # Parameters + /// * `route` - Route to query. + /// * `level` (required, in path) + /// * `challenge_id` (required, in path) + /// * `limit` (optional, in query) + /// # Riot Developer API Reference + /// `lol-challenges-v1.getChallengeLeaderboards` + /// + /// Note: this method is automatically generated. + pub fn get_challenge_leaderboards(&self, route: PlatformRoute, challenge_id: i64, level: &str, limit: Option) + -> impl Future>>> + 'a + { + let route_str = route.into(); + let request = self.base.request(Method::GET, route_str, &format!("/lol/challenges/v1/challenges/{}/leaderboards/by-level/{}", challenge_id, level)); + let mut request = request; if let Some(limit) = limit { request = request.query(&[ ("limit", limit) ]); } + let future = self.base.execute_opt::>("lol-challenges-v1.getChallengeLeaderboards", route_str, request); + #[cfg(feature = "tracing")] + let future = future.instrument(tracing::info_span!("lol-challenges-v1.getChallengeLeaderboards")); + future + } + + /// Map of level to percentile of players who have achieved it + /// # Parameters + /// * `route` - Route to query. + /// * `challenge_id` (required, in path) + /// # Riot Developer API Reference + /// `lol-challenges-v1.getChallengePercentiles` + /// + /// Note: this method is automatically generated. + pub fn get_challenge_percentiles(&self, route: PlatformRoute, challenge_id: i64) + -> impl Future>>> + 'a + { + let route_str = route.into(); + let request = self.base.request(Method::GET, route_str, &format!("/lol/challenges/v1/challenges/{}/percentiles", challenge_id)); + let future = self.base.execute_opt::>("lol-challenges-v1.getChallengePercentiles", route_str, request); + #[cfg(feature = "tracing")] + let future = future.instrument(tracing::info_span!("lol-challenges-v1.getChallengePercentiles")); + future + } + + /// Returns player information with list of all progressed challenges (REST) + /// # Parameters + /// * `route` - Route to query. + /// * `puuid` (required, in path) + /// # Riot Developer API Reference + /// `lol-challenges-v1.getPlayerData` + /// + /// Note: this method is automatically generated. + pub fn get_player_data(&self, route: PlatformRoute, puuid: &str) + -> impl Future> + 'a + { + let route_str = route.into(); + let request = self.base.request(Method::GET, route_str, &format!("/lol/challenges/v1/player-data/{}", puuid)); + let future = self.base.execute_val::("lol-challenges-v1.getPlayerData", route_str, request); + #[cfg(feature = "tracing")] + let future = future.instrument(tracing::info_span!("lol-challenges-v1.getPlayerData")); + future + } + +} + /// LolStatusV3 endpoints handle, accessed by calling [`lol_status_v3()`](crate::RiotApi::lol_status_v3) on a [`RiotApi`](crate::RiotApi) instance. /// # Riot Developer API Reference /// `lol-status-v3` @@ -1380,17 +1507,23 @@ impl<'a> TftMatchV1<'a> { /// # Parameters /// * `route` - Route to query. /// * `puuid` (required, in path) - /// * `count` (optional, in query) - Defaults to 20. + /// * `start` (optional, in query) - Defaults to 0. Start index. + /// * `end_time` (optional, in query) - Epoch timestamp in seconds. + /// * `start_time` (optional, in query) - Epoch timestamp in seconds. The matchlist started storing timestamps on June 16th, 2021. Any matches played before June 16th, 2021 won't be included in the results if the startTime filter is set. + /// * `count` (optional, in query) - Defaults to 20. Number of match ids to return. /// # Riot Developer API Reference /// `tft-match-v1.getMatchIdsByPUUID` /// /// Note: this method is automatically generated. - pub fn get_match_ids_by_puuid(&self, route: RegionalRoute, puuid: &str, count: Option) + pub fn get_match_ids_by_puuid(&self, route: RegionalRoute, puuid: &str, count: Option, end_time: Option, start: Option, start_time: Option) -> impl Future>> + 'a { let route_str = route.into(); let request = self.base.request(Method::GET, route_str, &format!("/tft/match/v1/matches/by-puuid/{}/ids", puuid)); let mut request = request; if let Some(count) = count { request = request.query(&[ ("count", count) ]); } + let mut request = request; if let Some(end_time) = end_time { request = request.query(&[ ("endTime", end_time) ]); } + let mut request = request; if let Some(start) = start { request = request.query(&[ ("start", start) ]); } + let mut request = request; if let Some(start_time) = start_time { request = request.query(&[ ("startTime", start_time) ]); } let future = self.base.execute_val::>("tft-match-v1.getMatchIdsByPUUID", route_str, request); #[cfg(feature = "tracing")] let future = future.instrument(tracing::info_span!("tft-match-v1.getMatchIdsByPUUID")); @@ -1526,37 +1659,6 @@ impl<'a> TftSummonerV1<'a> { } -/// ThirdPartyCodeV4 endpoints handle, accessed by calling [`third_party_code_v4()`](crate::RiotApi::third_party_code_v4) on a [`RiotApi`](crate::RiotApi) instance. -/// # Riot Developer API Reference -/// `third-party-code-v4` -/// -/// Note: this struct is automatically generated. -#[repr(transparent)] -pub struct ThirdPartyCodeV4<'a> { - base: &'a RiotApi, -} -impl<'a> ThirdPartyCodeV4<'a> { - /// Get third party code for a given summoner ID. - /// # Parameters - /// * `route` - Route to query. - /// * `encrypted_summoner_id` (required, in path) - /// # Riot Developer API Reference - /// `third-party-code-v4.getThirdPartyCodeBySummonerId` - /// - /// Note: this method is automatically generated. - pub fn get_third_party_code_by_summoner_id(&self, route: PlatformRoute, encrypted_summoner_id: &str) - -> impl Future> + 'a - { - let route_str = route.into(); - let request = self.base.request(Method::GET, route_str, &format!("/lol/platform/v4/third-party-code/by-summoner/{}", encrypted_summoner_id)); - let future = self.base.execute_val::("third-party-code-v4.getThirdPartyCodeBySummonerId", route_str, request); - #[cfg(feature = "tracing")] - let future = future.instrument(tracing::info_span!("third-party-code-v4.getThirdPartyCodeBySummonerId")); - future - } - -} - /// TournamentStubV4 endpoints handle, accessed by calling [`tournament_stub_v4()`](crate::RiotApi::tournament_stub_v4) on a [`RiotApi`](crate::RiotApi) instance. /// # Riot Developer API Reference /// `tournament-stub-v4` diff --git a/riven/src/meta.rs b/riven/src/meta.rs index 0c29006..3ab8731 100644 --- a/riven/src/meta.rs +++ b/riven/src/meta.rs @@ -7,7 +7,7 @@ /////////////////////////////////////////////// // http://www.mingweisamuel.com/riotapi-schema/tool/ -// Version 616004110d2cf4f8bb0b1e0332e079399aea56cc +// Version d2e2d8db61e32b60f6722b887694538659c20436 //! Metadata about the Riot API and Riven. //! @@ -15,7 +15,7 @@ /// Metadata for endpoints. Each tuple corresponds to one endpoint and contains /// the HTTP [`Method`](reqwest::Method), `str` path, and the method's `str` ID. -pub static ALL_ENDPOINTS: [(reqwest::Method, &str, &str); 70] = [ +pub static ALL_ENDPOINTS: [(reqwest::Method, &str, &str); 75] = [ (reqwest::Method::GET, "/riot/account/v1/accounts/by-puuid/{puuid}", "account-v1.getByPuuid"), (reqwest::Method::GET, "/riot/account/v1/accounts/by-riot-id/{gameName}/{tagLine}", "account-v1.getByRiotId"), (reqwest::Method::GET, "/riot/account/v1/accounts/me", "account-v1.getByAccessToken"), @@ -36,6 +36,12 @@ pub static ALL_ENDPOINTS: [(reqwest::Method, &str, &str); 70] = [ (reqwest::Method::GET, "/lol/league/v4/grandmasterleagues/by-queue/{queue}", "league-v4.getGrandmasterLeague"), (reqwest::Method::GET, "/lol/league/v4/leagues/{leagueId}", "league-v4.getLeagueById"), (reqwest::Method::GET, "/lol/league/v4/masterleagues/by-queue/{queue}", "league-v4.getMasterLeague"), + (reqwest::Method::GET, "/lol/challenges/v1/challenges/config", "lol-challenges-v1.getAllChallengeConfigs"), + (reqwest::Method::GET, "/lol/challenges/v1/challenges/percentiles", "lol-challenges-v1.getAllChallengePercentiles"), + (reqwest::Method::GET, "/lol/challenges/v1/challenges/{challengeId}/config", "lol-challenges-v1.getChallengeConfigs"), + (reqwest::Method::GET, "/lol/challenges/v1/challenges/{challengeId}/leaderboards/by-level/{level}", "lol-challenges-v1.getChallengeLeaderboards"), + (reqwest::Method::GET, "/lol/challenges/v1/challenges/{challengeId}/percentiles", "lol-challenges-v1.getChallengePercentiles"), + (reqwest::Method::GET, "/lol/challenges/v1/player-data/{puuid}", "lol-challenges-v1.getPlayerData"), (reqwest::Method::GET, "/lol/status/v3/shard-data", "lol-status-v3.getShardData"), (reqwest::Method::GET, "/lol/status/v4/platform-data", "lol-status-v4.getPlatformData"), (reqwest::Method::GET, "/lor/deck/v1/decks/me", "lor-deck-v1.getDecks"), @@ -69,7 +75,6 @@ pub static ALL_ENDPOINTS: [(reqwest::Method, &str, &str); 70] = [ (reqwest::Method::GET, "/tft/summoner/v1/summoners/by-puuid/{encryptedPUUID}", "tft-summoner-v1.getByPUUID"), (reqwest::Method::GET, "/tft/summoner/v1/summoners/me", "tft-summoner-v1.getByAccessToken"), (reqwest::Method::GET, "/tft/summoner/v1/summoners/{encryptedSummonerId}", "tft-summoner-v1.getBySummonerId"), - (reqwest::Method::GET, "/lol/platform/v4/third-party-code/by-summoner/{encryptedSummonerId}", "third-party-code-v4.getThirdPartyCodeBySummonerId"), (reqwest::Method::POST, "/lol/tournament-stub/v4/codes", "tournament-stub-v4.createTournamentCode"), (reqwest::Method::GET, "/lol/tournament-stub/v4/lobby-events/by-code/{tournamentCode}", "tournament-stub-v4.getLobbyEventsByCode"), (reqwest::Method::POST, "/lol/tournament-stub/v4/providers", "tournament-stub-v4.registerProviderData"), diff --git a/riven/src/models.rs b/riven/src/models.rs index 02b5e4a..c40287f 100644 --- a/riven/src/models.rs +++ b/riven/src/models.rs @@ -7,7 +7,7 @@ /////////////////////////////////////////////// // http://www.mingweisamuel.com/riotapi-schema/tool/ -// Version 616004110d2cf4f8bb0b1e0332e079399aea56cc +// Version d2e2d8db61e32b60f6722b887694538659c20436 #![allow(missing_docs)] @@ -366,6 +366,134 @@ pub mod league_v4 { } } +/// Data structs used by [`LolChallengesV1`](crate::endpoints::LolChallengesV1). +/// +/// Note: this module is automatically generated. +#[allow(dead_code)] +pub mod lol_challenges_v1 { + /// ChallengeConfigInfo data object. + #[derive(Clone, Debug)] + #[derive(serde::Serialize, serde::Deserialize)] + #[cfg_attr(feature = "deny-unknown-fields", serde(deny_unknown_fields))] + pub struct ChallengeConfigInfo { + #[serde(rename = "id")] + pub id: i64, + #[serde(rename = "localizedNames")] + pub localized_names: std::collections::HashMap>, + #[serde(rename = "state")] + pub state: State, + #[serde(rename = "tracking")] + pub tracking: Tracking, + #[serde(rename = "startTimestamp")] + pub start_timestamp: i64, + #[serde(rename = "endTimestamp")] + pub end_timestamp: i64, + #[serde(rename = "leaderboard")] + pub leaderboard: bool, + #[serde(rename = "thresholds")] + pub thresholds: std::collections::HashMap, + } + /// State data object. + /// # Description + /// DISABLED - not visible and not calculated,
+ /// HIDDEN - not visible, but calculated,
+ /// ENABLED - visible and calculated,
+ /// ARCHIVED - visible, but not calculated + /// + /// Note: This struct is automatically generated + #[derive(Clone, Debug)] + #[derive(serde::Serialize, serde::Deserialize)] + #[cfg_attr(feature = "deny-unknown-fields", serde(deny_unknown_fields))] + pub struct State { + } + /// Tracking data object. + /// # Description + /// LIFETIME - stats are incremented without reset,
+ /// SEASON - stats are accumulated by season and reset at the beginning of new season + /// + /// Note: This struct is automatically generated + #[derive(Clone, Debug)] + #[derive(serde::Serialize, serde::Deserialize)] + #[cfg_attr(feature = "deny-unknown-fields", serde(deny_unknown_fields))] + pub struct Tracking { + } + /// ApexPlayerInfo data object. + #[derive(Clone, Debug)] + #[derive(serde::Serialize, serde::Deserialize)] + #[cfg_attr(feature = "deny-unknown-fields", serde(deny_unknown_fields))] + pub struct ApexPlayerInfo { + #[serde(rename = "puuid")] + pub puuid: String, + #[serde(rename = "value")] + pub value: f64, + #[serde(rename = "position")] + pub position: i32, + } + /// Level data object. + /// # Description + /// 0 NONE,
+ /// 1 IRON,
+ /// 2 BRONZE,
+ /// 3 SILVER,
+ /// 4 GOLD,
+ /// 5 PLATINUM,
+ /// 6 DIAMOND,
+ /// 7 MASTER,
+ /// 8 GRANDMASTER,
+ /// 9 CHALLENGER + /// + /// Note: This struct is automatically generated + #[derive(Clone, Debug)] + #[derive(serde::Serialize, serde::Deserialize)] + #[cfg_attr(feature = "deny-unknown-fields", serde(deny_unknown_fields))] + pub struct Level { + } + /// PlayerInfo data object. + #[derive(Clone, Debug)] + #[derive(serde::Serialize, serde::Deserialize)] + #[cfg_attr(feature = "deny-unknown-fields", serde(deny_unknown_fields))] + pub struct PlayerInfo { + #[serde(rename = "challenges")] + pub challenges: std::vec::Vec, + #[serde(rename = "preferences")] + pub preferences: PlayerClientPreferences, + #[serde(rename = "totalPoints")] + pub total_points: ChallengePoints, + #[serde(rename = "categoryPoints")] + pub category_points: std::collections::HashMap, + } + /// ChallengeInfo data object. + /// # Description + /// UNKNOWN TYPE. + /// + /// Note: This struct is automatically generated + #[derive(Clone, Debug)] + #[derive(serde::Serialize, serde::Deserialize)] + #[cfg_attr(feature = "deny-unknown-fields", serde(deny_unknown_fields))] + pub struct ChallengeInfo { + } + /// PlayerClientPreferences data object. + /// # Description + /// UNKNOWN TYPE. + /// + /// Note: This struct is automatically generated + #[derive(Clone, Debug)] + #[derive(serde::Serialize, serde::Deserialize)] + #[cfg_attr(feature = "deny-unknown-fields", serde(deny_unknown_fields))] + pub struct PlayerClientPreferences { + } + /// ChallengePoints data object. + /// # Description + /// UNKNOWN TYPE. + /// + /// Note: This struct is automatically generated + #[derive(Clone, Debug)] + #[derive(serde::Serialize, serde::Deserialize)] + #[cfg_attr(feature = "deny-unknown-fields", serde(deny_unknown_fields))] + pub struct ChallengePoints { + } +} + /// Data structs used by [`LolStatusV3`](crate::endpoints::LolStatusV3). /// /// Note: this module is automatically generated. diff --git a/riven/srcgen/models.rs.dt b/riven/srcgen/models.rs.dt index 8692cc9..ee34606 100644 --- a/riven/srcgen/models.rs.dt +++ b/riven/srcgen/models.rs.dt @@ -40,7 +40,7 @@ pub mod {{= dotUtils.changeCase.snakeCase(endpoint) }} { /// {{= schemaName }} data object. {{? schema.description }} /// # Description - /// {{= schema.description }} + /// {{= schema.description.split('\n').map(x => x.trim()).join('
\r\n /// ') }} /// /// Note: This struct is automatically generated {{?}} diff --git a/riven/tests/tests_la1.rs b/riven/tests/tests_la1.rs new file mode 100644 index 0000000..4eb4b8c --- /dev/null +++ b/riven/tests/tests_la1.rs @@ -0,0 +1,32 @@ +#![cfg_attr(feature = "nightly", feature(custom_test_frameworks))] +#![cfg_attr(feature = "nightly", test_runner(my_runner))] + +mod async_tests; +mod testutils; +use testutils::RIOT_API; + +use colored::*; + +use riven::consts::*; + +const ROUTE: PlatformRoute = PlatformRoute::LA1; + +async_tests! { + my_runner { + lol_challenges_v1_check_percentiles: async { + // Check all percentiles. + let percentiles = RIOT_API.lol_challenges_v1().get_all_challenge_percentiles(ROUTE) + .await.map_err(|e| e.to_string())?; + rassert!(!percentiles.is_empty()); + + // Spot-check 10% of the challenge IDs. + for &challenge_id in percentiles.keys().step_by(10) { + RIOT_API.lol_challenges_v1().get_challenge_percentiles(ROUTE, challenge_id) + .await.map_err(|e| format!("Failed to get challenge with id {}\n{}", challenge_id, e))? + .ok_or_else(|| format!("Challenge with id {} returned 404", challenge_id))?; + } + + Ok(()) + }, + } +}