forked from mirror/Riven
1
0
Fork 0

reorganizing a bunch of stuff

users/mingwei/surf
Mingwei Samuel 2019-10-21 22:43:06 -07:00
parent 22103fea05
commit 0029b08d9a
7 changed files with 197 additions and 95 deletions

View File

@ -1,7 +1,7 @@
 
// This file is automatically generated. // This file is automatically generated.
// Do not directly edit. // Do not directly edit.
// Generated on 2019-10-22T04:47:08.742Z // Generated on 2019-10-22T05:40:37.599Z
use std::fmt; use std::fmt;
use num_derive; use num_derive;

View File

@ -1,7 +1,7 @@
// This file is automatically generated. // This file is automatically generated.
// Do not directly edit. // Do not directly edit.
// Generated on 2019-10-22T04:47:08.827Z // Generated on 2019-10-22T05:40:37.680Z
// http://www.mingweisamuel.com/riotapi-schema/tool/ // http://www.mingweisamuel.com/riotapi-schema/tool/
// Version 0c74167e0eaaeb6de1c7e8219fecaabcf8386d1f // Version 0c74167e0eaaeb6de1c7e8219fecaabcf8386d1f

View File

@ -1,7 +1,7 @@
// This file is automatically generated. // This file is automatically generated.
// Do not directly edit. // Do not directly edit.
// Generated on 2019-10-22T04:47:08.813Z // Generated on 2019-10-22T05:40:37.693Z
// http://www.mingweisamuel.com/riotapi-schema/tool/ // http://www.mingweisamuel.com/riotapi-schema/tool/
// Version 0c74167e0eaaeb6de1c7e8219fecaabcf8386d1f // Version 0c74167e0eaaeb6de1c7e8219fecaabcf8386d1f
@ -15,20 +15,60 @@ use url::form_urlencoded::Serializer;
use crate::consts::Region; use crate::consts::Region;
use crate::riot_api::RiotApi; use crate::riot_api::RiotApi;
// ChampionMasteryV4
impl RiotApi { impl RiotApi {
pub fn champion_mastery_v4(&self) -> ChampionMasteryV4 {
ChampionMasteryV4 { base: self }
}
pub fn champion_v3(&self) -> ChampionV3 {
ChampionV3 { base: self }
}
pub fn league_exp_v4(&self) -> LeagueExpV4 {
LeagueExpV4 { base: self }
}
pub fn league_v4(&self) -> LeagueV4 {
LeagueV4 { base: self }
}
pub fn lol_status_v3(&self) -> LolStatusV3 {
LolStatusV3 { base: self }
}
pub fn match_v4(&self) -> MatchV4 {
MatchV4 { base: self }
}
pub fn spectator_v4(&self) -> SpectatorV4 {
SpectatorV4 { base: self }
}
pub fn summoner_v4(&self) -> SummonerV4 {
SummonerV4 { base: self }
}
pub fn third_party_code_v4(&self) -> ThirdPartyCodeV4 {
ThirdPartyCodeV4 { base: self }
}
pub fn tournament_stub_v4(&self) -> TournamentStubV4 {
TournamentStubV4 { base: self }
}
pub fn tournament_v4(&self) -> TournamentV4 {
TournamentV4 { base: self }
}
}
/// ChampionMasteryV4 endpoints. This class is automatically generated.<para />
/// # Official API Reference
/// a href="https://developer.riotgames.com/api-methods/#champion-mastery-v4">https://developer.riotgames.com/api-methods/#champion-mastery-v4</a>
pub struct ChampionMasteryV4<'a> {
base: &'a RiotApi,
}
impl<'a> ChampionMasteryV4<'a> {
/// Get all champion mastery entries sorted by number of champion points descending, /// Get all champion mastery entries sorted by number of champion points descending,
/// # Official API Reference /// # Official API Reference
/// <a href="https://developer.riotgames.com/api-methods/#champion-mastery-v4/GET_getAllChampionMasteries">https://developer.riotgames.com/api-methods/#champion-mastery-v4/GET_getAllChampionMasteries</a> /// <a href="https://developer.riotgames.com/api-methods/#champion-mastery-v4/GET_getAllChampionMasteries">https://developer.riotgames.com/api-methods/#champion-mastery-v4/GET_getAllChampionMasteries</a>
/// # Parameters /// # Parameters
/// * `region` - Region to query. /// * `region` - Region to query.
/// * `encryptedSummonerId` - Summoner ID associated with the player /// * `encryptedSummonerId` - Summoner ID associated with the player
pub fn champion_mastery_v4_get_all_champion_masteries<'a>(&'a self, region: Region, encrypted_summoner_id: &str) pub fn get_all_champion_masteries(&self, region: Region, encrypted_summoner_id: &str)
-> impl Future<Output = Result<Option<Vec<crate::champion_mastery_v4::ChampionMastery>>, reqwest::Error>> + 'a -> impl Future<Output = Result<Option<Vec<crate::champion_mastery_v4::ChampionMastery>>, reqwest::Error>> + 'a
{ {
let path_string = format!("/lol/champion-mastery/v4/champion-masteries/by-summoner/{}", encrypted_summoner_id); let path_string = format!("/lol/champion-mastery/v4/champion-masteries/by-summoner/{}", encrypted_summoner_id);
self.get::<Vec<crate::champion_mastery_v4::ChampionMastery>>("champion-mastery-v4.getAllChampionMasteries", region, path_string, None) self.base.get::<Vec<crate::champion_mastery_v4::ChampionMastery>>("champion-mastery-v4.getAllChampionMasteries", region, path_string, None)
} }
/// Get a champion mastery by player ID and champion ID. /// Get a champion mastery by player ID and champion ID.
@ -38,11 +78,11 @@ impl RiotApi {
/// * `region` - Region to query. /// * `region` - Region to query.
/// * `championId` - Champion ID to retrieve Champion Mastery for /// * `championId` - Champion ID to retrieve Champion Mastery for
/// * `encryptedSummonerId` - Summoner ID associated with the player /// * `encryptedSummonerId` - Summoner ID associated with the player
pub fn champion_mastery_v4_get_champion_mastery<'a>(&'a self, region: Region, encrypted_summoner_id: &str, champion_id: i64) pub fn get_champion_mastery(&self, region: Region, encrypted_summoner_id: &str, champion_id: i64)
-> impl Future<Output = Result<Option<crate::champion_mastery_v4::ChampionMastery>, reqwest::Error>> + 'a -> impl Future<Output = Result<Option<crate::champion_mastery_v4::ChampionMastery>, reqwest::Error>> + 'a
{ {
let path_string = format!("/lol/champion-mastery/v4/champion-masteries/by-summoner/{}/by-champion/{}", encrypted_summoner_id, champion_id); let path_string = format!("/lol/champion-mastery/v4/champion-masteries/by-summoner/{}/by-champion/{}", encrypted_summoner_id, champion_id);
self.get::<crate::champion_mastery_v4::ChampionMastery>("champion-mastery-v4.getChampionMastery", region, path_string, None) self.base.get::<crate::champion_mastery_v4::ChampionMastery>("champion-mastery-v4.getChampionMastery", region, path_string, None)
} }
/// Get a player's total champion mastery score, which is the sum of individual champion mastery levels. /// Get a player's total champion mastery score, which is the sum of individual champion mastery levels.
@ -51,33 +91,43 @@ impl RiotApi {
/// # Parameters /// # Parameters
/// * `region` - Region to query. /// * `region` - Region to query.
/// * `encryptedSummonerId` - Summoner ID associated with the player /// * `encryptedSummonerId` - Summoner ID associated with the player
pub fn champion_mastery_v4_get_champion_mastery_score<'a>(&'a self, region: Region, encrypted_summoner_id: &str) pub fn get_champion_mastery_score(&self, region: Region, encrypted_summoner_id: &str)
-> impl Future<Output = Result<Option<i32>, reqwest::Error>> + 'a -> impl Future<Output = Result<Option<i32>, reqwest::Error>> + 'a
{ {
let path_string = format!("/lol/champion-mastery/v4/scores/by-summoner/{}", encrypted_summoner_id); let path_string = format!("/lol/champion-mastery/v4/scores/by-summoner/{}", encrypted_summoner_id);
self.get::<i32>("champion-mastery-v4.getChampionMasteryScore", region, path_string, None) self.base.get::<i32>("champion-mastery-v4.getChampionMasteryScore", region, path_string, None)
} }
} }
// ChampionV3 /// ChampionV3 endpoints. This class is automatically generated.<para />
impl RiotApi { /// # Official API Reference
/// a href="https://developer.riotgames.com/api-methods/#champion-v3">https://developer.riotgames.com/api-methods/#champion-v3</a>
pub struct ChampionV3<'a> {
base: &'a RiotApi,
}
impl<'a> ChampionV3<'a> {
/// Returns champion rotations, including free-to-play and low-level free-to-play rotations (REST) /// Returns champion rotations, including free-to-play and low-level free-to-play rotations (REST)
/// # Official API Reference /// # Official API Reference
/// <a href="https://developer.riotgames.com/api-methods/#champion-v3/GET_getChampionInfo">https://developer.riotgames.com/api-methods/#champion-v3/GET_getChampionInfo</a> /// <a href="https://developer.riotgames.com/api-methods/#champion-v3/GET_getChampionInfo">https://developer.riotgames.com/api-methods/#champion-v3/GET_getChampionInfo</a>
/// # Parameters /// # Parameters
/// * `region` - Region to query. /// * `region` - Region to query.
pub fn champion_v3_get_champion_info<'a>(&'a self, region: Region) pub fn get_champion_info(&self, region: Region)
-> impl Future<Output = Result<Option<crate::champion_v3::ChampionInfo>, reqwest::Error>> + 'a -> impl Future<Output = Result<Option<crate::champion_v3::ChampionInfo>, reqwest::Error>> + 'a
{ {
let path_string = "/lol/platform/v3/champion-rotations".to_owned(); let path_string = "/lol/platform/v3/champion-rotations".to_owned();
self.get::<crate::champion_v3::ChampionInfo>("champion-v3.getChampionInfo", region, path_string, None) self.base.get::<crate::champion_v3::ChampionInfo>("champion-v3.getChampionInfo", region, path_string, None)
} }
} }
// LeagueExpV4 /// LeagueExpV4 endpoints. This class is automatically generated.<para />
impl RiotApi { /// # Official API Reference
/// a href="https://developer.riotgames.com/api-methods/#league-exp-v4">https://developer.riotgames.com/api-methods/#league-exp-v4</a>
pub struct LeagueExpV4<'a> {
base: &'a RiotApi,
}
impl<'a> LeagueExpV4<'a> {
/// Get all the league entries. /// Get all the league entries.
/// # Official API Reference /// # Official API Reference
/// <a href="https://developer.riotgames.com/api-methods/#league-exp-v4/GET_getLeagueEntries">https://developer.riotgames.com/api-methods/#league-exp-v4/GET_getLeagueEntries</a> /// <a href="https://developer.riotgames.com/api-methods/#league-exp-v4/GET_getLeagueEntries">https://developer.riotgames.com/api-methods/#league-exp-v4/GET_getLeagueEntries</a>
@ -87,31 +137,36 @@ impl RiotApi {
/// * `tier` /// * `tier`
/// * `division` /// * `division`
/// * `page` (optional) - Starts with page 1. /// * `page` (optional) - Starts with page 1.
pub fn league_exp_v4_get_league_entries<'a>(&'a self, region: Region, division: &str, tier: &str, queue: &str, page: Option<i32>) pub fn get_league_entries(&self, region: Region, division: &str, tier: &str, queue: &str, page: Option<i32>)
-> impl Future<Output = Result<Option<Vec<crate::league_exp_v4::LeagueEntry>>, reqwest::Error>> + 'a -> impl Future<Output = Result<Option<Vec<crate::league_exp_v4::LeagueEntry>>, reqwest::Error>> + 'a
{ {
let mut query_params = Serializer::new(String::new()); let mut query_params = Serializer::new(String::new());
if let Some(page) = page { query_params.append_pair("page", &*page.to_string()); }; if let Some(page) = page { query_params.append_pair("page", &*page.to_string()); };
let query_string = query_params.finish(); let query_string = query_params.finish();
let path_string = format!("/lol/league-exp/v4/entries/{}/{}/{}", division, tier, queue); let path_string = format!("/lol/league-exp/v4/entries/{}/{}/{}", division, tier, queue);
self.get::<Vec<crate::league_exp_v4::LeagueEntry>>("league-exp-v4.getLeagueEntries", region, path_string, Some(query_string)) self.base.get::<Vec<crate::league_exp_v4::LeagueEntry>>("league-exp-v4.getLeagueEntries", region, path_string, Some(query_string))
} }
} }
// LeagueV4 /// LeagueV4 endpoints. This class is automatically generated.<para />
impl RiotApi { /// # Official API Reference
/// a href="https://developer.riotgames.com/api-methods/#league-v4">https://developer.riotgames.com/api-methods/#league-v4</a>
pub struct LeagueV4<'a> {
base: &'a RiotApi,
}
impl<'a> LeagueV4<'a> {
/// Get the challenger league for given queue. /// Get the challenger league for given queue.
/// # Official API Reference /// # Official API Reference
/// <a href="https://developer.riotgames.com/api-methods/#league-v4/GET_getChallengerLeague">https://developer.riotgames.com/api-methods/#league-v4/GET_getChallengerLeague</a> /// <a href="https://developer.riotgames.com/api-methods/#league-v4/GET_getChallengerLeague">https://developer.riotgames.com/api-methods/#league-v4/GET_getChallengerLeague</a>
/// # Parameters /// # Parameters
/// * `region` - Region to query. /// * `region` - Region to query.
/// * `queue` /// * `queue`
pub fn league_v4_get_challenger_league<'a>(&'a self, region: Region, queue: &str) pub fn get_challenger_league(&self, region: Region, queue: &str)
-> impl Future<Output = Result<Option<crate::league_v4::LeagueList>, reqwest::Error>> + 'a -> impl Future<Output = Result<Option<crate::league_v4::LeagueList>, reqwest::Error>> + 'a
{ {
let path_string = format!("/lol/league/v4/challengerleagues/by-queue/{}", queue); let path_string = format!("/lol/league/v4/challengerleagues/by-queue/{}", queue);
self.get::<crate::league_v4::LeagueList>("league-v4.getChallengerLeague", region, path_string, None) self.base.get::<crate::league_v4::LeagueList>("league-v4.getChallengerLeague", region, path_string, None)
} }
/// Get league entries in all queues for a given summoner ID. /// Get league entries in all queues for a given summoner ID.
@ -120,11 +175,11 @@ impl RiotApi {
/// # Parameters /// # Parameters
/// * `region` - Region to query. /// * `region` - Region to query.
/// * `encryptedSummonerId` /// * `encryptedSummonerId`
pub fn league_v4_get_league_entries_for_summoner<'a>(&'a self, region: Region, encrypted_summoner_id: &str) pub fn get_league_entries_for_summoner(&self, region: Region, encrypted_summoner_id: &str)
-> impl Future<Output = Result<Option<Vec<crate::league_v4::LeagueEntry>>, reqwest::Error>> + 'a -> impl Future<Output = Result<Option<Vec<crate::league_v4::LeagueEntry>>, reqwest::Error>> + 'a
{ {
let path_string = format!("/lol/league/v4/entries/by-summoner/{}", encrypted_summoner_id); let path_string = format!("/lol/league/v4/entries/by-summoner/{}", encrypted_summoner_id);
self.get::<Vec<crate::league_v4::LeagueEntry>>("league-v4.getLeagueEntriesForSummoner", region, path_string, None) self.base.get::<Vec<crate::league_v4::LeagueEntry>>("league-v4.getLeagueEntriesForSummoner", region, path_string, None)
} }
/// Get all the league entries. /// Get all the league entries.
@ -136,14 +191,14 @@ impl RiotApi {
/// * `tier` /// * `tier`
/// * `queue` - Note that the queue value must be a valid ranked queue. /// * `queue` - Note that the queue value must be a valid ranked queue.
/// * `page` (optional) - Starts with page 1. /// * `page` (optional) - Starts with page 1.
pub fn league_v4_get_league_entries<'a>(&'a self, region: Region, queue: &str, tier: &str, division: &str, page: Option<i32>) pub fn get_league_entries(&self, region: Region, queue: &str, tier: &str, division: &str, page: Option<i32>)
-> impl Future<Output = Result<Option<Vec<crate::league_v4::LeagueEntry>>, reqwest::Error>> + 'a -> impl Future<Output = Result<Option<Vec<crate::league_v4::LeagueEntry>>, reqwest::Error>> + 'a
{ {
let mut query_params = Serializer::new(String::new()); let mut query_params = Serializer::new(String::new());
if let Some(page) = page { query_params.append_pair("page", &*page.to_string()); }; if let Some(page) = page { query_params.append_pair("page", &*page.to_string()); };
let query_string = query_params.finish(); let query_string = query_params.finish();
let path_string = format!("/lol/league/v4/entries/{}/{}/{}", queue, tier, division); let path_string = format!("/lol/league/v4/entries/{}/{}/{}", queue, tier, division);
self.get::<Vec<crate::league_v4::LeagueEntry>>("league-v4.getLeagueEntries", region, path_string, Some(query_string)) self.base.get::<Vec<crate::league_v4::LeagueEntry>>("league-v4.getLeagueEntries", region, path_string, Some(query_string))
} }
/// Get the grandmaster league of a specific queue. /// Get the grandmaster league of a specific queue.
@ -152,11 +207,11 @@ impl RiotApi {
/// # Parameters /// # Parameters
/// * `region` - Region to query. /// * `region` - Region to query.
/// * `queue` /// * `queue`
pub fn league_v4_get_grandmaster_league<'a>(&'a self, region: Region, queue: &str) pub fn get_grandmaster_league(&self, region: Region, queue: &str)
-> impl Future<Output = Result<Option<crate::league_v4::LeagueList>, reqwest::Error>> + 'a -> impl Future<Output = Result<Option<crate::league_v4::LeagueList>, reqwest::Error>> + 'a
{ {
let path_string = format!("/lol/league/v4/grandmasterleagues/by-queue/{}", queue); let path_string = format!("/lol/league/v4/grandmasterleagues/by-queue/{}", queue);
self.get::<crate::league_v4::LeagueList>("league-v4.getGrandmasterLeague", region, path_string, None) self.base.get::<crate::league_v4::LeagueList>("league-v4.getGrandmasterLeague", region, path_string, None)
} }
/// Get league with given ID, including inactive entries. /// Get league with given ID, including inactive entries.
@ -165,11 +220,11 @@ impl RiotApi {
/// # Parameters /// # Parameters
/// * `region` - Region to query. /// * `region` - Region to query.
/// * `leagueId` - The UUID of the league. /// * `leagueId` - The UUID of the league.
pub fn league_v4_get_league_by_id<'a>(&'a self, region: Region, league_id: &str) pub fn get_league_by_id(&self, region: Region, league_id: &str)
-> impl Future<Output = Result<Option<crate::league_v4::LeagueList>, reqwest::Error>> + 'a -> impl Future<Output = Result<Option<crate::league_v4::LeagueList>, reqwest::Error>> + 'a
{ {
let path_string = format!("/lol/league/v4/leagues/{}", league_id); let path_string = format!("/lol/league/v4/leagues/{}", league_id);
self.get::<crate::league_v4::LeagueList>("league-v4.getLeagueById", region, path_string, None) self.base.get::<crate::league_v4::LeagueList>("league-v4.getLeagueById", region, path_string, None)
} }
/// Get the master league for given queue. /// Get the master league for given queue.
@ -178,17 +233,22 @@ impl RiotApi {
/// # Parameters /// # Parameters
/// * `region` - Region to query. /// * `region` - Region to query.
/// * `queue` /// * `queue`
pub fn league_v4_get_master_league<'a>(&'a self, region: Region, queue: &str) pub fn get_master_league(&self, region: Region, queue: &str)
-> impl Future<Output = Result<Option<crate::league_v4::LeagueList>, reqwest::Error>> + 'a -> impl Future<Output = Result<Option<crate::league_v4::LeagueList>, reqwest::Error>> + 'a
{ {
let path_string = format!("/lol/league/v4/masterleagues/by-queue/{}", queue); let path_string = format!("/lol/league/v4/masterleagues/by-queue/{}", queue);
self.get::<crate::league_v4::LeagueList>("league-v4.getMasterLeague", region, path_string, None) self.base.get::<crate::league_v4::LeagueList>("league-v4.getMasterLeague", region, path_string, None)
} }
} }
// LolStatusV3 /// LolStatusV3 endpoints. This class is automatically generated.<para />
impl RiotApi { /// # Official API Reference
/// a href="https://developer.riotgames.com/api-methods/#lol-status-v3">https://developer.riotgames.com/api-methods/#lol-status-v3</a>
pub struct LolStatusV3<'a> {
base: &'a RiotApi,
}
impl<'a> LolStatusV3<'a> {
/// Get League of Legends status for the given shard. /// Get League of Legends status for the given shard.
/// ## Rate Limit Notes /// ## Rate Limit Notes
/// Requests to this API are not counted against the application Rate Limits. /// Requests to this API are not counted against the application Rate Limits.
@ -196,28 +256,33 @@ impl RiotApi {
/// <a href="https://developer.riotgames.com/api-methods/#lol-status-v3/GET_getShardData">https://developer.riotgames.com/api-methods/#lol-status-v3/GET_getShardData</a> /// <a href="https://developer.riotgames.com/api-methods/#lol-status-v3/GET_getShardData">https://developer.riotgames.com/api-methods/#lol-status-v3/GET_getShardData</a>
/// # Parameters /// # Parameters
/// * `region` - Region to query. /// * `region` - Region to query.
pub fn lol_status_v3_get_shard_data<'a>(&'a self, region: Region) pub fn get_shard_data(&self, region: Region)
-> impl Future<Output = Result<Option<crate::lol_status_v3::ShardStatus>, reqwest::Error>> + 'a -> impl Future<Output = Result<Option<crate::lol_status_v3::ShardStatus>, reqwest::Error>> + 'a
{ {
let path_string = "/lol/status/v3/shard-data".to_owned(); let path_string = "/lol/status/v3/shard-data".to_owned();
self.get::<crate::lol_status_v3::ShardStatus>("lol-status-v3.getShardData", region, path_string, None) self.base.get::<crate::lol_status_v3::ShardStatus>("lol-status-v3.getShardData", region, path_string, None)
} }
} }
// MatchV4 /// MatchV4 endpoints. This class is automatically generated.<para />
impl RiotApi { /// # Official API Reference
/// a href="https://developer.riotgames.com/api-methods/#match-v4">https://developer.riotgames.com/api-methods/#match-v4</a>
pub struct MatchV4<'a> {
base: &'a RiotApi,
}
impl<'a> MatchV4<'a> {
/// Get match IDs by tournament code. /// Get match IDs by tournament code.
/// # Official API Reference /// # Official API Reference
/// <a href="https://developer.riotgames.com/api-methods/#match-v4/GET_getMatchIdsByTournamentCode">https://developer.riotgames.com/api-methods/#match-v4/GET_getMatchIdsByTournamentCode</a> /// <a href="https://developer.riotgames.com/api-methods/#match-v4/GET_getMatchIdsByTournamentCode">https://developer.riotgames.com/api-methods/#match-v4/GET_getMatchIdsByTournamentCode</a>
/// # Parameters /// # Parameters
/// * `region` - Region to query. /// * `region` - Region to query.
/// * `tournamentCode` - The tournament code. /// * `tournamentCode` - The tournament code.
pub fn match_v4_get_match_ids_by_tournament_code<'a>(&'a self, region: Region, tournament_code: &str) pub fn get_match_ids_by_tournament_code(&self, region: Region, tournament_code: &str)
-> impl Future<Output = Result<Option<Vec<i64>>, reqwest::Error>> + 'a -> impl Future<Output = Result<Option<Vec<i64>>, reqwest::Error>> + 'a
{ {
let path_string = format!("/lol/match/v4/matches/by-tournament-code/{}/ids", tournament_code); let path_string = format!("/lol/match/v4/matches/by-tournament-code/{}/ids", tournament_code);
self.get::<Vec<i64>>("match-v4.getMatchIdsByTournamentCode", region, path_string, None) self.base.get::<Vec<i64>>("match-v4.getMatchIdsByTournamentCode", region, path_string, None)
} }
/// Get match by match ID. /// Get match by match ID.
@ -226,11 +291,11 @@ impl RiotApi {
/// # Parameters /// # Parameters
/// * `region` - Region to query. /// * `region` - Region to query.
/// * `matchId` - The match ID. /// * `matchId` - The match ID.
pub fn match_v4_get_match<'a>(&'a self, region: Region, match_id: i64) pub fn get_match(&self, region: Region, match_id: i64)
-> impl Future<Output = Result<Option<crate::match_v4::Match>, reqwest::Error>> + 'a -> impl Future<Output = Result<Option<crate::match_v4::Match>, reqwest::Error>> + 'a
{ {
let path_string = format!("/lol/match/v4/matches/{}", match_id); let path_string = format!("/lol/match/v4/matches/{}", match_id);
self.get::<crate::match_v4::Match>("match-v4.getMatch", region, path_string, None) self.base.get::<crate::match_v4::Match>("match-v4.getMatch", region, path_string, None)
} }
/// Get match by match ID and tournament code. /// Get match by match ID and tournament code.
@ -240,11 +305,11 @@ impl RiotApi {
/// * `region` - Region to query. /// * `region` - Region to query.
/// * `tournamentCode` - The tournament code. /// * `tournamentCode` - The tournament code.
/// * `matchId` - The match ID. /// * `matchId` - The match ID.
pub fn match_v4_get_match_by_tournament_code<'a>(&'a self, region: Region, match_id: i64, tournament_code: &str) pub fn get_match_by_tournament_code(&self, region: Region, match_id: i64, tournament_code: &str)
-> impl Future<Output = Result<Option<crate::match_v4::Match>, reqwest::Error>> + 'a -> impl Future<Output = Result<Option<crate::match_v4::Match>, reqwest::Error>> + 'a
{ {
let path_string = format!("/lol/match/v4/matches/{}/by-tournament-code/{}", match_id, tournament_code); let path_string = format!("/lol/match/v4/matches/{}/by-tournament-code/{}", match_id, tournament_code);
self.get::<crate::match_v4::Match>("match-v4.getMatchByTournamentCode", region, path_string, None) self.base.get::<crate::match_v4::Match>("match-v4.getMatchByTournamentCode", region, path_string, None)
} }
/// Get matchlist for games played on given account ID and platform ID and filtered using given filter parameters, if any. /// Get matchlist for games played on given account ID and platform ID and filtered using given filter parameters, if any.
@ -266,7 +331,7 @@ impl RiotApi {
/// * `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. /// * `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. /// * `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. /// * `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 fn match_v4_get_matchlist<'a>(&'a self, region: Region, encrypted_account_id: &str, champion: Option<std::vec::Vec<i32>>, queue: Option<std::vec::Vec<i32>>, season: Option<std::vec::Vec<i32>>, end_time: Option<i64>, begin_time: Option<i64>, end_index: Option<i32>, begin_index: Option<i32>) pub fn get_matchlist(&self, region: Region, encrypted_account_id: &str, champion: Option<std::vec::Vec<i32>>, queue: Option<std::vec::Vec<i32>>, season: Option<std::vec::Vec<i32>>, end_time: Option<i64>, begin_time: Option<i64>, end_index: Option<i32>, begin_index: Option<i32>)
-> impl Future<Output = Result<Option<crate::match_v4::Matchlist>, reqwest::Error>> + 'a -> impl Future<Output = Result<Option<crate::match_v4::Matchlist>, reqwest::Error>> + 'a
{ {
let mut query_params = Serializer::new(String::new()); let mut query_params = Serializer::new(String::new());
@ -279,7 +344,7 @@ impl RiotApi {
if let Some(begin_index) = begin_index { query_params.append_pair("beginIndex", &*begin_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 query_string = query_params.finish();
let path_string = format!("/lol/match/v4/matchlists/by-account/{}", encrypted_account_id); let path_string = format!("/lol/match/v4/matchlists/by-account/{}", encrypted_account_id);
self.get::<crate::match_v4::Matchlist>("match-v4.getMatchlist", region, path_string, Some(query_string)) self.base.get::<crate::match_v4::Matchlist>("match-v4.getMatchlist", region, path_string, Some(query_string))
} }
/// Get match timeline by match ID. /// Get match timeline by match ID.
@ -290,28 +355,33 @@ impl RiotApi {
/// # Parameters /// # Parameters
/// * `region` - Region to query. /// * `region` - Region to query.
/// * `matchId` - The match ID. /// * `matchId` - The match ID.
pub fn match_v4_get_match_timeline<'a>(&'a self, region: Region, match_id: i64) pub fn get_match_timeline(&self, region: Region, match_id: i64)
-> impl Future<Output = Result<Option<crate::match_v4::MatchTimeline>, reqwest::Error>> + 'a -> impl Future<Output = Result<Option<crate::match_v4::MatchTimeline>, reqwest::Error>> + 'a
{ {
let path_string = format!("/lol/match/v4/timelines/by-match/{}", match_id); let path_string = format!("/lol/match/v4/timelines/by-match/{}", match_id);
self.get::<crate::match_v4::MatchTimeline>("match-v4.getMatchTimeline", region, path_string, None) self.base.get::<crate::match_v4::MatchTimeline>("match-v4.getMatchTimeline", region, path_string, None)
} }
} }
// SpectatorV4 /// SpectatorV4 endpoints. This class is automatically generated.<para />
impl RiotApi { /// # Official API Reference
/// a href="https://developer.riotgames.com/api-methods/#spectator-v4">https://developer.riotgames.com/api-methods/#spectator-v4</a>
pub struct SpectatorV4<'a> {
base: &'a RiotApi,
}
impl<'a> SpectatorV4<'a> {
/// Get current game information for the given summoner ID. /// Get current game information for the given summoner ID.
/// # Official API Reference /// # Official API Reference
/// <a href="https://developer.riotgames.com/api-methods/#spectator-v4/GET_getCurrentGameInfoBySummoner">https://developer.riotgames.com/api-methods/#spectator-v4/GET_getCurrentGameInfoBySummoner</a> /// <a href="https://developer.riotgames.com/api-methods/#spectator-v4/GET_getCurrentGameInfoBySummoner">https://developer.riotgames.com/api-methods/#spectator-v4/GET_getCurrentGameInfoBySummoner</a>
/// # Parameters /// # Parameters
/// * `region` - Region to query. /// * `region` - Region to query.
/// * `encryptedSummonerId` - The ID of the summoner. /// * `encryptedSummonerId` - The ID of the summoner.
pub fn spectator_v4_get_current_game_info_by_summoner<'a>(&'a self, region: Region, encrypted_summoner_id: &str) pub fn get_current_game_info_by_summoner(&self, region: Region, encrypted_summoner_id: &str)
-> impl Future<Output = Result<Option<crate::spectator_v4::CurrentGameInfo>, reqwest::Error>> + 'a -> impl Future<Output = Result<Option<crate::spectator_v4::CurrentGameInfo>, reqwest::Error>> + 'a
{ {
let path_string = format!("/lol/spectator/v4/active-games/by-summoner/{}", encrypted_summoner_id); let path_string = format!("/lol/spectator/v4/active-games/by-summoner/{}", encrypted_summoner_id);
self.get::<crate::spectator_v4::CurrentGameInfo>("spectator-v4.getCurrentGameInfoBySummoner", region, path_string, None) self.base.get::<crate::spectator_v4::CurrentGameInfo>("spectator-v4.getCurrentGameInfoBySummoner", region, path_string, None)
} }
/// Get list of featured games. /// Get list of featured games.
@ -319,28 +389,33 @@ impl RiotApi {
/// <a href="https://developer.riotgames.com/api-methods/#spectator-v4/GET_getFeaturedGames">https://developer.riotgames.com/api-methods/#spectator-v4/GET_getFeaturedGames</a> /// <a href="https://developer.riotgames.com/api-methods/#spectator-v4/GET_getFeaturedGames">https://developer.riotgames.com/api-methods/#spectator-v4/GET_getFeaturedGames</a>
/// # Parameters /// # Parameters
/// * `region` - Region to query. /// * `region` - Region to query.
pub fn spectator_v4_get_featured_games<'a>(&'a self, region: Region) pub fn get_featured_games(&self, region: Region)
-> impl Future<Output = Result<Option<crate::spectator_v4::FeaturedGames>, reqwest::Error>> + 'a -> impl Future<Output = Result<Option<crate::spectator_v4::FeaturedGames>, reqwest::Error>> + 'a
{ {
let path_string = "/lol/spectator/v4/featured-games".to_owned(); let path_string = "/lol/spectator/v4/featured-games".to_owned();
self.get::<crate::spectator_v4::FeaturedGames>("spectator-v4.getFeaturedGames", region, path_string, None) self.base.get::<crate::spectator_v4::FeaturedGames>("spectator-v4.getFeaturedGames", region, path_string, None)
} }
} }
// SummonerV4 /// SummonerV4 endpoints. This class is automatically generated.<para />
impl RiotApi { /// # Official API Reference
/// a href="https://developer.riotgames.com/api-methods/#summoner-v4">https://developer.riotgames.com/api-methods/#summoner-v4</a>
pub struct SummonerV4<'a> {
base: &'a RiotApi,
}
impl<'a> SummonerV4<'a> {
/// Get a summoner by account ID. /// Get a summoner by account ID.
/// # Official API Reference /// # Official API Reference
/// <a href="https://developer.riotgames.com/api-methods/#summoner-v4/GET_getByAccountId">https://developer.riotgames.com/api-methods/#summoner-v4/GET_getByAccountId</a> /// <a href="https://developer.riotgames.com/api-methods/#summoner-v4/GET_getByAccountId">https://developer.riotgames.com/api-methods/#summoner-v4/GET_getByAccountId</a>
/// # Parameters /// # Parameters
/// * `region` - Region to query. /// * `region` - Region to query.
/// * `encryptedAccountId` /// * `encryptedAccountId`
pub fn summoner_v4_get_by_account_id<'a>(&'a self, region: Region, encrypted_account_id: &str) pub fn get_by_account_id(&self, region: Region, encrypted_account_id: &str)
-> impl Future<Output = Result<Option<crate::summoner_v4::Summoner>, reqwest::Error>> + 'a -> impl Future<Output = Result<Option<crate::summoner_v4::Summoner>, reqwest::Error>> + 'a
{ {
let path_string = format!("/lol/summoner/v4/summoners/by-account/{}", encrypted_account_id); let path_string = format!("/lol/summoner/v4/summoners/by-account/{}", encrypted_account_id);
self.get::<crate::summoner_v4::Summoner>("summoner-v4.getByAccountId", region, path_string, None) self.base.get::<crate::summoner_v4::Summoner>("summoner-v4.getByAccountId", region, path_string, None)
} }
/// Get a summoner by summoner name. /// Get a summoner by summoner name.
@ -349,11 +424,11 @@ impl RiotApi {
/// # Parameters /// # Parameters
/// * `region` - Region to query. /// * `region` - Region to query.
/// * `summonerName` - Summoner Name /// * `summonerName` - Summoner Name
pub fn summoner_v4_get_by_summoner_name<'a>(&'a self, region: Region, summoner_name: &str) pub fn get_by_summoner_name(&self, region: Region, summoner_name: &str)
-> impl Future<Output = Result<Option<crate::summoner_v4::Summoner>, reqwest::Error>> + 'a -> impl Future<Output = Result<Option<crate::summoner_v4::Summoner>, reqwest::Error>> + 'a
{ {
let path_string = format!("/lol/summoner/v4/summoners/by-name/{}", summoner_name); let path_string = format!("/lol/summoner/v4/summoners/by-name/{}", summoner_name);
self.get::<crate::summoner_v4::Summoner>("summoner-v4.getBySummonerName", region, path_string, None) self.base.get::<crate::summoner_v4::Summoner>("summoner-v4.getBySummonerName", region, path_string, None)
} }
/// Get a summoner by PUUID. /// Get a summoner by PUUID.
@ -362,11 +437,11 @@ impl RiotApi {
/// # Parameters /// # Parameters
/// * `region` - Region to query. /// * `region` - Region to query.
/// * `encryptedPUUID` - Summoner ID /// * `encryptedPUUID` - Summoner ID
pub fn summoner_v4_get_by_puuid<'a>(&'a self, region: Region, encrypted_puuid: &str) pub fn get_by_puuid(&self, region: Region, encrypted_puuid: &str)
-> impl Future<Output = Result<Option<crate::summoner_v4::Summoner>, reqwest::Error>> + 'a -> impl Future<Output = Result<Option<crate::summoner_v4::Summoner>, reqwest::Error>> + 'a
{ {
let path_string = format!("/lol/summoner/v4/summoners/by-puuid/{}", encrypted_puuid); let path_string = format!("/lol/summoner/v4/summoners/by-puuid/{}", encrypted_puuid);
self.get::<crate::summoner_v4::Summoner>("summoner-v4.getByPUUID", region, path_string, None) self.base.get::<crate::summoner_v4::Summoner>("summoner-v4.getByPUUID", region, path_string, None)
} }
/// Get a summoner by summoner ID. /// Get a summoner by summoner ID.
@ -375,62 +450,77 @@ impl RiotApi {
/// # Parameters /// # Parameters
/// * `region` - Region to query. /// * `region` - Region to query.
/// * `encryptedSummonerId` - Summoner ID /// * `encryptedSummonerId` - Summoner ID
pub fn summoner_v4_get_by_summoner_id<'a>(&'a self, region: Region, encrypted_summoner_id: &str) pub fn get_by_summoner_id(&self, region: Region, encrypted_summoner_id: &str)
-> impl Future<Output = Result<Option<crate::summoner_v4::Summoner>, reqwest::Error>> + 'a -> impl Future<Output = Result<Option<crate::summoner_v4::Summoner>, reqwest::Error>> + 'a
{ {
let path_string = format!("/lol/summoner/v4/summoners/{}", encrypted_summoner_id); let path_string = format!("/lol/summoner/v4/summoners/{}", encrypted_summoner_id);
self.get::<crate::summoner_v4::Summoner>("summoner-v4.getBySummonerId", region, path_string, None) self.base.get::<crate::summoner_v4::Summoner>("summoner-v4.getBySummonerId", region, path_string, None)
} }
} }
// ThirdPartyCodeV4 /// ThirdPartyCodeV4 endpoints. This class is automatically generated.<para />
impl RiotApi { /// # Official API Reference
/// a href="https://developer.riotgames.com/api-methods/#third-party-code-v4">https://developer.riotgames.com/api-methods/#third-party-code-v4</a>
pub struct ThirdPartyCodeV4<'a> {
base: &'a RiotApi,
}
impl<'a> ThirdPartyCodeV4<'a> {
/// Get third party code for a given summoner ID. /// Get third party code for a given summoner ID.
/// # Official API Reference /// # Official API Reference
/// <a href="https://developer.riotgames.com/api-methods/#third-party-code-v4/GET_getThirdPartyCodeBySummonerId">https://developer.riotgames.com/api-methods/#third-party-code-v4/GET_getThirdPartyCodeBySummonerId</a> /// <a href="https://developer.riotgames.com/api-methods/#third-party-code-v4/GET_getThirdPartyCodeBySummonerId">https://developer.riotgames.com/api-methods/#third-party-code-v4/GET_getThirdPartyCodeBySummonerId</a>
/// # Parameters /// # Parameters
/// * `region` - Region to query. /// * `region` - Region to query.
/// * `encryptedSummonerId` /// * `encryptedSummonerId`
pub fn third_party_code_v4_get_third_party_code_by_summoner_id<'a>(&'a self, region: Region, encrypted_summoner_id: &str) pub fn get_third_party_code_by_summoner_id(&self, region: Region, encrypted_summoner_id: &str)
-> impl Future<Output = Result<Option<String>, reqwest::Error>> + 'a -> impl Future<Output = Result<Option<String>, reqwest::Error>> + 'a
{ {
let path_string = format!("/lol/platform/v4/third-party-code/by-summoner/{}", encrypted_summoner_id); let path_string = format!("/lol/platform/v4/third-party-code/by-summoner/{}", encrypted_summoner_id);
self.get::<String>("third-party-code-v4.getThirdPartyCodeBySummonerId", region, path_string, None) self.base.get::<String>("third-party-code-v4.getThirdPartyCodeBySummonerId", region, path_string, None)
} }
} }
// TournamentStubV4 /// TournamentStubV4 endpoints. This class is automatically generated.<para />
impl RiotApi { /// # Official API Reference
/// a href="https://developer.riotgames.com/api-methods/#tournament-stub-v4">https://developer.riotgames.com/api-methods/#tournament-stub-v4</a>
pub struct TournamentStubV4<'a> {
base: &'a RiotApi,
}
impl<'a> TournamentStubV4<'a> {
/// Gets a mock list of lobby events by tournament code. /// Gets a mock list of lobby events by tournament code.
/// # Official API Reference /// # Official API Reference
/// <a href="https://developer.riotgames.com/api-methods/#tournament-stub-v4/GET_getLobbyEventsByCode">https://developer.riotgames.com/api-methods/#tournament-stub-v4/GET_getLobbyEventsByCode</a> /// <a href="https://developer.riotgames.com/api-methods/#tournament-stub-v4/GET_getLobbyEventsByCode">https://developer.riotgames.com/api-methods/#tournament-stub-v4/GET_getLobbyEventsByCode</a>
/// # Parameters /// # Parameters
/// * `region` - Region to query. /// * `region` - Region to query.
/// * `tournamentCode` - The short code to look up lobby events for /// * `tournamentCode` - The short code to look up lobby events for
pub fn tournament_stub_v4_get_lobby_events_by_code<'a>(&'a self, region: Region, tournament_code: &str) pub fn get_lobby_events_by_code(&self, region: Region, tournament_code: &str)
-> impl Future<Output = Result<Option<crate::tournament_stub_v4::LobbyEventWrapper>, reqwest::Error>> + 'a -> impl Future<Output = Result<Option<crate::tournament_stub_v4::LobbyEventWrapper>, reqwest::Error>> + 'a
{ {
let path_string = format!("/lol/tournament-stub/v4/lobby-events/by-code/{}", tournament_code); let path_string = format!("/lol/tournament-stub/v4/lobby-events/by-code/{}", tournament_code);
self.get::<crate::tournament_stub_v4::LobbyEventWrapper>("tournament-stub-v4.getLobbyEventsByCode", region, path_string, None) self.base.get::<crate::tournament_stub_v4::LobbyEventWrapper>("tournament-stub-v4.getLobbyEventsByCode", region, path_string, None)
} }
} }
// TournamentV4 /// TournamentV4 endpoints. This class is automatically generated.<para />
impl RiotApi { /// # Official API Reference
/// a href="https://developer.riotgames.com/api-methods/#tournament-v4">https://developer.riotgames.com/api-methods/#tournament-v4</a>
pub struct TournamentV4<'a> {
base: &'a RiotApi,
}
impl<'a> TournamentV4<'a> {
/// Returns the tournament code DTO associated with a tournament code string. /// Returns the tournament code DTO associated with a tournament code string.
/// # Official API Reference /// # Official API Reference
/// <a href="https://developer.riotgames.com/api-methods/#tournament-v4/GET_getTournamentCode">https://developer.riotgames.com/api-methods/#tournament-v4/GET_getTournamentCode</a> /// <a href="https://developer.riotgames.com/api-methods/#tournament-v4/GET_getTournamentCode">https://developer.riotgames.com/api-methods/#tournament-v4/GET_getTournamentCode</a>
/// # Parameters /// # Parameters
/// * `region` - Region to query. /// * `region` - Region to query.
/// * `tournamentCode` - The tournament code string. /// * `tournamentCode` - The tournament code string.
pub fn tournament_v4_get_tournament_code<'a>(&'a self, region: Region, tournament_code: &str) pub fn get_tournament_code(&self, region: Region, tournament_code: &str)
-> impl Future<Output = Result<Option<crate::tournament_v4::TournamentCode>, reqwest::Error>> + 'a -> impl Future<Output = Result<Option<crate::tournament_v4::TournamentCode>, reqwest::Error>> + 'a
{ {
let path_string = format!("/lol/tournament/v4/codes/{}", tournament_code); let path_string = format!("/lol/tournament/v4/codes/{}", tournament_code);
self.get::<crate::tournament_v4::TournamentCode>("tournament-v4.getTournamentCode", region, path_string, None) self.base.get::<crate::tournament_v4::TournamentCode>("tournament-v4.getTournamentCode", region, path_string, None)
} }
/// Gets a list of lobby events by tournament code. /// Gets a list of lobby events by tournament code.
@ -439,11 +529,11 @@ impl RiotApi {
/// # Parameters /// # Parameters
/// * `region` - Region to query. /// * `region` - Region to query.
/// * `tournamentCode` - The short code to look up lobby events for /// * `tournamentCode` - The short code to look up lobby events for
pub fn tournament_v4_get_lobby_events_by_code<'a>(&'a self, region: Region, tournament_code: &str) pub fn get_lobby_events_by_code(&self, region: Region, tournament_code: &str)
-> impl Future<Output = Result<Option<crate::tournament_v4::LobbyEventWrapper>, reqwest::Error>> + 'a -> impl Future<Output = Result<Option<crate::tournament_v4::LobbyEventWrapper>, reqwest::Error>> + 'a
{ {
let path_string = format!("/lol/tournament/v4/lobby-events/by-code/{}", tournament_code); let path_string = format!("/lol/tournament/v4/lobby-events/by-code/{}", tournament_code);
self.get::<crate::tournament_v4::LobbyEventWrapper>("tournament-v4.getLobbyEventsByCode", region, path_string, None) self.base.get::<crate::tournament_v4::LobbyEventWrapper>("tournament-v4.getLobbyEventsByCode", region, path_string, None)
} }
} }

View File

@ -3,6 +3,7 @@ pub use dto::*;
pub mod consts; pub mod consts;
mod endpoints;
mod riot_api_config; mod riot_api_config;
pub use riot_api_config::*; pub use riot_api_config::*;
@ -18,7 +19,6 @@ mod tests {
use tokio::runtime::Runtime; use tokio::runtime::Runtime;
use super::*; use super::*;
use url::form_urlencoded::Serializer; use url::form_urlencoded::Serializer;
#[test] #[test]
fn checkme() { fn checkme() {
@ -29,7 +29,6 @@ mod tests {
println!("{}", result); println!("{}", result);
} }
#[test] #[test]
#[ignore] #[ignore]
fn it_works() { fn it_works() {
@ -44,7 +43,7 @@ mod tests {
let riot_api = RiotApi::with_key(api_key.trim()); let riot_api = RiotApi::with_key(api_key.trim());
for i in 0..2 { for i in 0..2 {
let my_future = riot_api.champion_mastery_v4_get_all_champion_masteries( let my_future = riot_api.champion_mastery_v4().get_all_champion_masteries(
consts::Region::NA, "SBM8Ubipo4ge2yj7bhEzL7yvV0C9Oc1XA2l6v5okGMA_nCw"); consts::Region::NA, "SBM8Ubipo4ge2yj7bhEzL7yvV0C9Oc1XA2l6v5okGMA_nCw");
let val = rt.block_on(my_future).unwrap(); let val = rt.block_on(my_future).unwrap();
println!("VAL {}: {:#?}", i, val.unwrap()); println!("VAL {}: {:#?}", i, val.unwrap());

View File

@ -1,6 +1,3 @@
mod endpoints;
pub use endpoints::*;
use std::future::Future; use std::future::Future;
use log::*; use log::*;

View File

@ -25,13 +25,32 @@ use crate::riot_api::RiotApi;
endpointGroups[ep] = endpointGroups[ep] || []; endpointGroups[ep] = endpointGroups[ep] || [];
endpointGroups[ep].push(path); endpointGroups[ep].push(path);
} }
}}
impl RiotApi {
{{
for (const endpointName of Object.keys(endpointGroups)) {
const method = dotUtils.changeCase.snakeCase(endpointName);
const type = dotUtils.changeCase.pascalCase(endpointName);
}}
pub fn {{= method }}(&self) -> {{= type }} {
{{= type }} { base: self }
}
{{
}
}}
}
{{
for (let [ endpointName, endpointMethods ] of Object.entries(endpointGroups)) { for (let [ endpointName, endpointMethods ] of Object.entries(endpointGroups)) {
let endpoint = dotUtils.changeCase.pascalCase(endpointName); let endpoint = dotUtils.changeCase.pascalCase(endpointName);
}} }}
// {{= endpoint }} /// {{= endpoint }} endpoints. This class is automatically generated.<para />
impl RiotApi { /// # Official API Reference
/// a href="https://developer.riotgames.com/api-methods/#{{= endpointName }}">https://developer.riotgames.com/api-methods/#{{= endpointName }}</a>
pub struct {{= endpoint }}<'a> {
base: &'a RiotApi,
}
impl<'a> {{= endpoint }}<'a> {
{{ {{
for (let [ route, path ] of endpointMethods) for (let [ route, path ] of endpointMethods)
{ {
@ -106,7 +125,7 @@ impl RiotApi {
} }
} }
}} }}
pub fn {{= dotUtils.changeCase.snakeCase(endpoint) }}_{{= method }}<'a>(&'a self, region: Region{{= argBuilder.join('') }}) pub fn {{= method }}(&self, region: Region{{= argBuilder.join('') }})
-> impl Future<Output = Result<Option<{{= returnType }}>, reqwest::Error>> + 'a -> impl Future<Output = Result<Option<{{= returnType }}>, reqwest::Error>> + 'a
{ {
{{? queryParams.length }} {{? queryParams.length }}
@ -122,7 +141,7 @@ impl RiotApi {
let query_string = query_params.finish(); let query_string = query_params.finish();
{{?}} {{?}}
let path_string = {{= routeArgument }}; let path_string = {{= routeArgument }};
self.get::<{{= returnType }}>("{{= operationId }}", region, path_string, {{= queryParams.length ? 'Some(query_string)' : 'None' }}) self.base.get::<{{= returnType }}>("{{= operationId }}", region, path_string, {{= queryParams.length ? 'Some(query_string)' : 'None' }})
} }
{{ {{

View File

@ -9,12 +9,9 @@ use riven::RiotApi;
use tokio::runtime::current_thread::Runtime; use tokio::runtime::current_thread::Runtime;
lazy_static! { lazy_static! {
static ref API_KEY: String = { static ref RIOT_API: RiotApi = {
let api_key = std::fs::read_to_string("apikey.txt").unwrap(); // TODO don't use unwrap. let api_key = std::fs::read_to_string("apikey.txt").unwrap(); // TODO don't use unwrap.
api_key.trim().to_owned() RiotApi::with_key(api_key.trim())
};
static ref RIOT_API: RiotApi<'static> = {
RiotApi::with_key(&API_KEY)
}; };
} }