forked from mirror/Riven
1
0
Fork 0

Upgrade srcgen to use requests

users/mingwei/unknown-variant-messy
Mingwei Samuel 2021-05-21 17:31:52 -07:00
parent 7f046e99f7
commit 8934790c1c
12 changed files with 298 additions and 221 deletions

View File

@ -34,7 +34,6 @@ serde_repr = "0.1"
strum = "0.20" strum = "0.20"
strum_macros = "0.20" strum_macros = "0.20"
tokio = { version = "1", default-features = false, features = [ "time" ] } tokio = { version = "1", default-features = false, features = [ "time" ] }
url = "2"
[dev-dependencies] [dev-dependencies]
colored = "2" colored = "2"

View File

@ -2,13 +2,14 @@
use std::time::Duration; use std::time::Duration;
use reqwest::ClientBuilder; use reqwest::ClientBuilder;
use reqwest::header::{HeaderMap, HeaderValue}; use reqwest::header::{ HeaderMap, HeaderValue };
/// Configuration for instantiating RiotApi. /// Configuration for instantiating RiotApi.
/// ///
/// ///
#[derive(Debug)] #[derive(Debug)]
pub struct RiotApiConfig { pub struct RiotApiConfig {
pub(crate) base_url: String,
pub(crate) retries: u8, pub(crate) retries: u8,
pub(crate) burst_pct: f32, pub(crate) burst_pct: f32,
pub(crate) duration_overhead: Duration, pub(crate) duration_overhead: Duration,
@ -22,10 +23,15 @@ impl RiotApiConfig {
/// this default header with the Riot API key as the value. /// this default header with the Riot API key as the value.
const RIOT_KEY_HEADER: &'static str = "X-Riot-Token"; const RIOT_KEY_HEADER: &'static str = "X-Riot-Token";
/// `"https://{}.api.riotgames.com"`
///
/// Default base URL, including `{}` placeholder for region platform.
pub const DEFAULT_BASE_URL: &'static str = "https://{}.api.riotgames.com";
/// `3` /// `3`
/// ///
/// Default number of retries. /// Default number of retries.
pub const PRECONFIG_RETRIES: u8 = 3; pub const DEFAULT_RETRIES: u8 = 3;
/// `0.99` /// `0.99`
/// ///
@ -48,14 +54,14 @@ impl RiotApiConfig {
/// Creates a new `RiotApiConfig` with the given `api_key` with the following /// Creates a new `RiotApiConfig` with the given `api_key` with the following
/// configuration: /// configuration:
/// ///
/// * `retries = 3` (`RiotApiConfig::PRECONFIG_RETRIES`). /// * `retries = 3` (`RiotApiConfig::DEFAULT_RETRIES`).
/// * `purst_pct = 0.99` (`preconfig_burst`). /// * `purst_pct = 0.99` (`preconfig_burst`).
/// * `duration_overhead = 989 ms` (`preconfig_burst`). /// * `duration_overhead = 989 ms` (`preconfig_burst`).
/// ///
/// `api_key` should be a Riot Games API key from /// `api_key` should be a Riot Games API key from
/// [https://developer.riotgames.com/](https://developer.riotgames.com/), /// [https://developer.riotgames.com/](https://developer.riotgames.com/),
/// and should look like `"RGAPI-01234567-89ab-cdef-0123-456789abcdef"`. /// and should look like `"RGAPI-01234567-89ab-cdef-0123-456789abcdef"`.
pub fn with_key<T: AsRef<[u8]>>(api_key: T) -> Self { pub fn with_key(api_key: impl AsRef<[u8]>) -> Self {
let mut default_headers = HeaderMap::new(); let mut default_headers = HeaderMap::new();
default_headers.insert( default_headers.insert(
Self::RIOT_KEY_HEADER, Self::RIOT_KEY_HEADER,
@ -63,7 +69,8 @@ impl RiotApiConfig {
); );
Self { Self {
retries: Self::PRECONFIG_RETRIES, base_url: Self::DEFAULT_BASE_URL.into(),
retries: Self::DEFAULT_RETRIES,
burst_pct: Self::PRECONFIG_BURST_BURST_PCT, burst_pct: Self::PRECONFIG_BURST_BURST_PCT,
duration_overhead: Self::PRECONFIG_BURST_DURATION_OVERHEAD, duration_overhead: Self::PRECONFIG_BURST_DURATION_OVERHEAD,
client_builder: Some( client_builder: Some(
@ -78,12 +85,13 @@ impl RiotApiConfig {
/// The client builder default headers should include a value for /// The client builder default headers should include a value for
/// `RiotApiConfig::RIOT_KEY_HEADER`, otherwise authentication will fail. /// `RiotApiConfig::RIOT_KEY_HEADER`, otherwise authentication will fail.
/// ///
/// * `retries = 3` (`RiotApiConfig::PRECONFIG_RETRIES`). /// * `retries = 3` (`RiotApiConfig::DEFAULT_RETRIES`).
/// * `purst_pct = 0.99` (`preconfig_burst`). /// * `purst_pct = 0.99` (`preconfig_burst`).
/// * `duration_overhead = 989 ms` (`preconfig_burst`). /// * `duration_overhead = 989 ms` (`preconfig_burst`).
pub fn with_client_builder(client_builder: ClientBuilder) -> Self { pub fn with_client_builder(client_builder: ClientBuilder) -> Self {
Self { Self {
retries: Self::PRECONFIG_RETRIES, base_url: Self::DEFAULT_BASE_URL.to_owned(),
retries: Self::DEFAULT_RETRIES,
burst_pct: Self::PRECONFIG_BURST_BURST_PCT, burst_pct: Self::PRECONFIG_BURST_BURST_PCT,
duration_overhead: Self::PRECONFIG_BURST_DURATION_OVERHEAD, duration_overhead: Self::PRECONFIG_BURST_DURATION_OVERHEAD,
client_builder: Some(client_builder), client_builder: Some(client_builder),
@ -118,6 +126,17 @@ impl RiotApiConfig {
self self
} }
/// Set the base url for requests. The string should contain a `"{}"`
/// literal which will be replaced with the region platform name. (However
/// multiple or zero `"{}"`s may be included if needed).
///
/// # Returns
/// `self`, for chaining.
pub fn set_base_url(mut self, base_url: impl Into<String>) -> Self {
self.base_url = base_url.into();
self
}
/// Set number of times to retry requests. Naturally, only retryable requests /// Set number of times to retry requests. Naturally, only retryable requests
/// will be retried: responses with status codes 5xx or 429 (after waiting /// will be retried: responses with status codes 5xx or 429 (after waiting
/// for retry-after headers). A value of `0` means one request will be sent /// for retry-after headers). A value of `0` means one request will be sent

View File

@ -16,7 +16,7 @@ use strum_macros::{ EnumString, EnumIter, Display, AsRefStr, IntoStaticStr };
/// NAME (`IDENTIFIER`, ID). /// NAME (`IDENTIFIER`, ID).
/// ///
/// Implements [IntoEnumIterator](super::IntoEnumIterator). /// Implements [IntoEnumIterator](super::IntoEnumIterator).
#[cfg_attr(feature = "nightly", non_exhaustive)] #[non_exhaustive]
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone)]
#[derive(IntoPrimitive, TryFromPrimitive)] #[derive(IntoPrimitive, TryFromPrimitive)]
#[derive(Serialize_repr, Deserialize_repr)] #[derive(Serialize_repr, Deserialize_repr)]

View File

@ -10,7 +10,7 @@ use strum_macros::{ EnumString, Display, AsRefStr, IntoStaticStr };
/// League of Legends game mode, such as Classic, /// League of Legends game mode, such as Classic,
/// ARAM, URF, One For All, Ascension, etc. /// ARAM, URF, One For All, Ascension, etc.
#[cfg_attr(feature = "nightly", non_exhaustive)] #[non_exhaustive]
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone)]
#[derive(Eq, PartialEq, Hash)] #[derive(Eq, PartialEq, Hash)]
#[derive(EnumString, Display, AsRefStr, IntoStaticStr)] #[derive(EnumString, Display, AsRefStr, IntoStaticStr)]

View File

@ -10,7 +10,7 @@ use serde_repr::{ Serialize_repr, Deserialize_repr };
use num_enum::{ IntoPrimitive, TryFromPrimitive }; use num_enum::{ IntoPrimitive, TryFromPrimitive };
/// League of Legends maps. /// League of Legends maps.
#[cfg_attr(feature = "nightly", non_exhaustive)] #[non_exhaustive]
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone)]
#[derive(Eq, PartialEq, Hash, PartialOrd, Ord)] #[derive(Eq, PartialEq, Hash, PartialOrd, Ord)]
#[derive(Serialize_repr, Deserialize_repr)] #[derive(Serialize_repr, Deserialize_repr)]

View File

@ -10,7 +10,7 @@ use serde_repr::{ Serialize_repr, Deserialize_repr };
use num_enum::{ IntoPrimitive, TryFromPrimitive }; use num_enum::{ IntoPrimitive, TryFromPrimitive };
/// League of Legends matchmaking queue. /// League of Legends matchmaking queue.
#[cfg_attr(feature = "nightly", non_exhaustive)] #[non_exhaustive]
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone)]
#[derive(Eq, PartialEq)] #[derive(Eq, PartialEq)]
#[derive(Serialize_repr, Deserialize_repr)] #[derive(Serialize_repr, Deserialize_repr)]

View File

@ -10,7 +10,7 @@ use serde_repr::{ Serialize_repr, Deserialize_repr };
use num_enum::{ IntoPrimitive, TryFromPrimitive }; use num_enum::{ IntoPrimitive, TryFromPrimitive };
/// League of Legends matchmaking seasons. /// League of Legends matchmaking seasons.
#[cfg_attr(feature = "nightly", non_exhaustive)] #[non_exhaustive]
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone)]
#[derive(Eq, PartialEq, Hash, PartialOrd, Ord)] #[derive(Eq, PartialEq, Hash, PartialOrd, Ord)]
#[derive(Serialize_repr, Deserialize_repr)] #[derive(Serialize_repr, Deserialize_repr)]

View File

@ -16,7 +16,7 @@ use crate::models::*;
use std::future::Future; use std::future::Future;
use std::vec::Vec; use std::vec::Vec;
use url::form_urlencoded::Serializer; use reqwest::Method;
use crate::Result; use crate::Result;
use crate::consts::Region; use crate::consts::Region;
@ -273,6 +273,7 @@ impl RiotApi {
/// <a href="https://developer.riotgames.com/apis#account-v1" target="_blank">`account-v1`</a> /// <a href="https://developer.riotgames.com/apis#account-v1" target="_blank">`account-v1`</a>
/// ///
/// Note: this struct is automatically generated. /// Note: this struct is automatically generated.
#[repr(transparent)]
pub struct AccountV1<'a> { pub struct AccountV1<'a> {
base: &'a RiotApi, base: &'a RiotApi,
} }
@ -288,8 +289,9 @@ impl<'a> AccountV1<'a> {
pub fn get_by_puuid(&self, region: Region, puuid: &str) pub fn get_by_puuid(&self, region: Region, puuid: &str)
-> impl Future<Output = Result<account_v1::Account>> + 'a -> impl Future<Output = Result<account_v1::Account>> + 'a
{ {
let path_string = format!("/riot/account/v1/accounts/by-puuid/{}", puuid); #[allow(unused_mut)]
self.base.get::<account_v1::Account>("account-v1.getByPuuid", region.into(), path_string, None) let mut request = self.base.request(Method::GET, region.into(), &format!("/riot/account/v1/accounts/by-puuid/{}", puuid));
self.base.execute::<account_v1::Account>("account-v1.getByPuuid", region.into(), request)
} }
/// Get account by riot id /// Get account by riot id
@ -304,8 +306,9 @@ impl<'a> AccountV1<'a> {
pub fn get_by_riot_id(&self, region: Region, game_name: &str, tag_line: &str) pub fn get_by_riot_id(&self, region: Region, game_name: &str, tag_line: &str)
-> impl Future<Output = Result<Option<account_v1::Account>>> + 'a -> impl Future<Output = Result<Option<account_v1::Account>>> + 'a
{ {
let path_string = format!("/riot/account/v1/accounts/by-riot-id/{}/{}", game_name, tag_line); #[allow(unused_mut)]
self.base.get_optional::<account_v1::Account>("account-v1.getByRiotId", region.into(), path_string, None) let mut request = self.base.request(Method::GET, region.into(), &format!("/riot/account/v1/accounts/by-riot-id/{}/{}", game_name, tag_line));
self.base.execute_optional::<account_v1::Account>("account-v1.getByRiotId", region.into(), request)
} }
/// Get active shard for a player /// Get active shard for a player
@ -320,8 +323,9 @@ impl<'a> AccountV1<'a> {
pub fn get_active_shard(&self, region: Region, game: &str, puuid: &str) pub fn get_active_shard(&self, region: Region, game: &str, puuid: &str)
-> impl Future<Output = Result<Option<account_v1::ActiveShard>>> + 'a -> impl Future<Output = Result<Option<account_v1::ActiveShard>>> + 'a
{ {
let path_string = format!("/riot/account/v1/active-shards/by-game/{}/by-puuid/{}", game, puuid); #[allow(unused_mut)]
self.base.get_optional::<account_v1::ActiveShard>("account-v1.getActiveShard", region.into(), path_string, None) let mut request = self.base.request(Method::GET, region.into(), &format!("/riot/account/v1/active-shards/by-game/{}/by-puuid/{}", game, puuid));
self.base.execute_optional::<account_v1::ActiveShard>("account-v1.getActiveShard", region.into(), request)
} }
} }
@ -331,6 +335,7 @@ impl<'a> AccountV1<'a> {
/// <a href="https://developer.riotgames.com/apis#champion-mastery-v4" target="_blank">`champion-mastery-v4`</a> /// <a href="https://developer.riotgames.com/apis#champion-mastery-v4" target="_blank">`champion-mastery-v4`</a>
/// ///
/// Note: this struct is automatically generated. /// Note: this struct is automatically generated.
#[repr(transparent)]
pub struct ChampionMasteryV4<'a> { pub struct ChampionMasteryV4<'a> {
base: &'a RiotApi, base: &'a RiotApi,
} }
@ -346,8 +351,9 @@ impl<'a> ChampionMasteryV4<'a> {
pub fn get_all_champion_masteries(&self, region: Region, encrypted_summoner_id: &str) pub fn get_all_champion_masteries(&self, region: Region, encrypted_summoner_id: &str)
-> impl Future<Output = Result<Vec<champion_mastery_v4::ChampionMastery>>> + 'a -> impl Future<Output = Result<Vec<champion_mastery_v4::ChampionMastery>>> + 'a
{ {
let path_string = format!("/lol/champion-mastery/v4/champion-masteries/by-summoner/{}", encrypted_summoner_id); #[allow(unused_mut)]
self.base.get::<Vec<champion_mastery_v4::ChampionMastery>>("champion-mastery-v4.getAllChampionMasteries", region.into(), path_string, None) let mut request = self.base.request(Method::GET, region.into(), &format!("/lol/champion-mastery/v4/champion-masteries/by-summoner/{}", encrypted_summoner_id));
self.base.execute::<Vec<champion_mastery_v4::ChampionMastery>>("champion-mastery-v4.getAllChampionMasteries", region.into(), request)
} }
/// Get a champion mastery by player ID and champion ID. /// Get a champion mastery by player ID and champion ID.
@ -362,8 +368,9 @@ impl<'a> ChampionMasteryV4<'a> {
pub fn get_champion_mastery(&self, region: Region, encrypted_summoner_id: &str, champion_id: crate::consts::Champion) pub fn get_champion_mastery(&self, region: Region, encrypted_summoner_id: &str, champion_id: crate::consts::Champion)
-> impl Future<Output = Result<Option<champion_mastery_v4::ChampionMastery>>> + 'a -> impl Future<Output = Result<Option<champion_mastery_v4::ChampionMastery>>> + 'a
{ {
let path_string = format!("/lol/champion-mastery/v4/champion-masteries/by-summoner/{}/by-champion/{}", encrypted_summoner_id, champion_id); #[allow(unused_mut)]
self.base.get_optional::<champion_mastery_v4::ChampionMastery>("champion-mastery-v4.getChampionMastery", region.into(), path_string, None) let mut request = self.base.request(Method::GET, region.into(), &format!("/lol/champion-mastery/v4/champion-masteries/by-summoner/{}/by-champion/{}", encrypted_summoner_id, champion_id));
self.base.execute_optional::<champion_mastery_v4::ChampionMastery>("champion-mastery-v4.getChampionMastery", region.into(), request)
} }
/// 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.
@ -377,8 +384,9 @@ impl<'a> ChampionMasteryV4<'a> {
pub fn get_champion_mastery_score(&self, region: Region, encrypted_summoner_id: &str) pub fn get_champion_mastery_score(&self, region: Region, encrypted_summoner_id: &str)
-> impl Future<Output = Result<i32>> + 'a -> impl Future<Output = Result<i32>> + 'a
{ {
let path_string = format!("/lol/champion-mastery/v4/scores/by-summoner/{}", encrypted_summoner_id); #[allow(unused_mut)]
self.base.get::<i32>("champion-mastery-v4.getChampionMasteryScore", region.into(), path_string, None) let mut request = self.base.request(Method::GET, region.into(), &format!("/lol/champion-mastery/v4/scores/by-summoner/{}", encrypted_summoner_id));
self.base.execute::<i32>("champion-mastery-v4.getChampionMasteryScore", region.into(), request)
} }
} }
@ -388,6 +396,7 @@ impl<'a> ChampionMasteryV4<'a> {
/// <a href="https://developer.riotgames.com/apis#champion-v3" target="_blank">`champion-v3`</a> /// <a href="https://developer.riotgames.com/apis#champion-v3" target="_blank">`champion-v3`</a>
/// ///
/// Note: this struct is automatically generated. /// Note: this struct is automatically generated.
#[repr(transparent)]
pub struct ChampionV3<'a> { pub struct ChampionV3<'a> {
base: &'a RiotApi, base: &'a RiotApi,
} }
@ -402,8 +411,9 @@ impl<'a> ChampionV3<'a> {
pub fn get_champion_info(&self, region: Region) pub fn get_champion_info(&self, region: Region)
-> impl Future<Output = Result<champion_v3::ChampionInfo>> + 'a -> impl Future<Output = Result<champion_v3::ChampionInfo>> + 'a
{ {
let path_string = "/lol/platform/v3/champion-rotations".to_owned(); #[allow(unused_mut)]
self.base.get::<champion_v3::ChampionInfo>("champion-v3.getChampionInfo", region.into(), path_string, None) let mut request = self.base.request(Method::GET, region.into(), "/lol/platform/v3/champion-rotations");
self.base.execute::<champion_v3::ChampionInfo>("champion-v3.getChampionInfo", region.into(), request)
} }
} }
@ -413,6 +423,7 @@ impl<'a> ChampionV3<'a> {
/// <a href="https://developer.riotgames.com/apis#clash-v1" target="_blank">`clash-v1`</a> /// <a href="https://developer.riotgames.com/apis#clash-v1" target="_blank">`clash-v1`</a>
/// ///
/// Note: this struct is automatically generated. /// Note: this struct is automatically generated.
#[repr(transparent)]
pub struct ClashV1<'a> { pub struct ClashV1<'a> {
base: &'a RiotApi, base: &'a RiotApi,
} }
@ -430,8 +441,9 @@ impl<'a> ClashV1<'a> {
pub fn get_players_by_summoner(&self, region: Region, summoner_id: &str) pub fn get_players_by_summoner(&self, region: Region, summoner_id: &str)
-> impl Future<Output = Result<Vec<clash_v1::Player>>> + 'a -> impl Future<Output = Result<Vec<clash_v1::Player>>> + 'a
{ {
let path_string = format!("/lol/clash/v1/players/by-summoner/{}", summoner_id); #[allow(unused_mut)]
self.base.get::<Vec<clash_v1::Player>>("clash-v1.getPlayersBySummoner", region.into(), path_string, None) let mut request = self.base.request(Method::GET, region.into(), &format!("/lol/clash/v1/players/by-summoner/{}", summoner_id));
self.base.execute::<Vec<clash_v1::Player>>("clash-v1.getPlayersBySummoner", region.into(), request)
} }
/// Get team by ID. /// Get team by ID.
@ -445,8 +457,9 @@ impl<'a> ClashV1<'a> {
pub fn get_team_by_id(&self, region: Region, team_id: &str) pub fn get_team_by_id(&self, region: Region, team_id: &str)
-> impl Future<Output = Result<Option<clash_v1::Team>>> + 'a -> impl Future<Output = Result<Option<clash_v1::Team>>> + 'a
{ {
let path_string = format!("/lol/clash/v1/teams/{}", team_id); #[allow(unused_mut)]
self.base.get_optional::<clash_v1::Team>("clash-v1.getTeamById", region.into(), path_string, None) let mut request = self.base.request(Method::GET, region.into(), &format!("/lol/clash/v1/teams/{}", team_id));
self.base.execute_optional::<clash_v1::Team>("clash-v1.getTeamById", region.into(), request)
} }
/// Get all active or upcoming tournaments. /// Get all active or upcoming tournaments.
@ -459,8 +472,9 @@ impl<'a> ClashV1<'a> {
pub fn get_tournaments(&self, region: Region) pub fn get_tournaments(&self, region: Region)
-> impl Future<Output = Result<Vec<clash_v1::Tournament>>> + 'a -> impl Future<Output = Result<Vec<clash_v1::Tournament>>> + 'a
{ {
let path_string = "/lol/clash/v1/tournaments".to_owned(); #[allow(unused_mut)]
self.base.get::<Vec<clash_v1::Tournament>>("clash-v1.getTournaments", region.into(), path_string, None) let mut request = self.base.request(Method::GET, region.into(), "/lol/clash/v1/tournaments");
self.base.execute::<Vec<clash_v1::Tournament>>("clash-v1.getTournaments", region.into(), request)
} }
/// Get tournament by team ID. /// Get tournament by team ID.
@ -474,8 +488,9 @@ impl<'a> ClashV1<'a> {
pub fn get_tournament_by_team(&self, region: Region, team_id: &str) pub fn get_tournament_by_team(&self, region: Region, team_id: &str)
-> impl Future<Output = Result<Option<clash_v1::Tournament>>> + 'a -> impl Future<Output = Result<Option<clash_v1::Tournament>>> + 'a
{ {
let path_string = format!("/lol/clash/v1/tournaments/by-team/{}", team_id); #[allow(unused_mut)]
self.base.get_optional::<clash_v1::Tournament>("clash-v1.getTournamentByTeam", region.into(), path_string, None) let mut request = self.base.request(Method::GET, region.into(), &format!("/lol/clash/v1/tournaments/by-team/{}", team_id));
self.base.execute_optional::<clash_v1::Tournament>("clash-v1.getTournamentByTeam", region.into(), request)
} }
/// Get tournament by ID. /// Get tournament by ID.
@ -489,8 +504,9 @@ impl<'a> ClashV1<'a> {
pub fn get_tournament_by_id(&self, region: Region, tournament_id: i32) pub fn get_tournament_by_id(&self, region: Region, tournament_id: i32)
-> impl Future<Output = Result<Option<clash_v1::Tournament>>> + 'a -> impl Future<Output = Result<Option<clash_v1::Tournament>>> + 'a
{ {
let path_string = format!("/lol/clash/v1/tournaments/{}", tournament_id); #[allow(unused_mut)]
self.base.get_optional::<clash_v1::Tournament>("clash-v1.getTournamentById", region.into(), path_string, None) let mut request = self.base.request(Method::GET, region.into(), &format!("/lol/clash/v1/tournaments/{}", tournament_id));
self.base.execute_optional::<clash_v1::Tournament>("clash-v1.getTournamentById", region.into(), request)
} }
} }
@ -500,6 +516,7 @@ impl<'a> ClashV1<'a> {
/// <a href="https://developer.riotgames.com/apis#league-exp-v4" target="_blank">`league-exp-v4`</a> /// <a href="https://developer.riotgames.com/apis#league-exp-v4" target="_blank">`league-exp-v4`</a>
/// ///
/// Note: this struct is automatically generated. /// Note: this struct is automatically generated.
#[repr(transparent)]
pub struct LeagueExpV4<'a> { pub struct LeagueExpV4<'a> {
base: &'a RiotApi, base: &'a RiotApi,
} }
@ -518,11 +535,10 @@ impl<'a> LeagueExpV4<'a> {
pub fn get_league_entries(&self, region: Region, queue: crate::consts::QueueType, tier: crate::consts::Tier, division: crate::consts::Division, page: Option<i32>) pub fn get_league_entries(&self, region: Region, queue: crate::consts::QueueType, tier: crate::consts::Tier, division: crate::consts::Division, page: Option<i32>)
-> impl Future<Output = Result<Vec<league_exp_v4::LeagueEntry>>> + 'a -> impl Future<Output = Result<Vec<league_exp_v4::LeagueEntry>>> + 'a
{ {
let mut query_params = Serializer::new(String::new()); #[allow(unused_mut)]
if let Some(page) = page { query_params.append_pair("page", &*page.to_string()); }; let mut request = self.base.request(Method::GET, region.into(), &format!("/lol/league-exp/v4/entries/{}/{}/{}", queue, tier, division));
let query_string = query_params.finish(); if let Some(page) = page { request = request.query(&[ ("page", page) ]); };
let path_string = format!("/lol/league-exp/v4/entries/{}/{}/{}", queue, tier, division); self.base.execute::<Vec<league_exp_v4::LeagueEntry>>("league-exp-v4.getLeagueEntries", region.into(), request)
self.base.get::<Vec<league_exp_v4::LeagueEntry>>("league-exp-v4.getLeagueEntries", region.into(), path_string, Some(query_string))
} }
} }
@ -532,6 +548,7 @@ impl<'a> LeagueExpV4<'a> {
/// <a href="https://developer.riotgames.com/apis#league-v4" target="_blank">`league-v4`</a> /// <a href="https://developer.riotgames.com/apis#league-v4" target="_blank">`league-v4`</a>
/// ///
/// Note: this struct is automatically generated. /// Note: this struct is automatically generated.
#[repr(transparent)]
pub struct LeagueV4<'a> { pub struct LeagueV4<'a> {
base: &'a RiotApi, base: &'a RiotApi,
} }
@ -547,8 +564,9 @@ impl<'a> LeagueV4<'a> {
pub fn get_challenger_league(&self, region: Region, queue: crate::consts::QueueType) pub fn get_challenger_league(&self, region: Region, queue: crate::consts::QueueType)
-> impl Future<Output = Result<league_v4::LeagueList>> + 'a -> impl Future<Output = Result<league_v4::LeagueList>> + 'a
{ {
let path_string = format!("/lol/league/v4/challengerleagues/by-queue/{}", queue); #[allow(unused_mut)]
self.base.get::<league_v4::LeagueList>("league-v4.getChallengerLeague", region.into(), path_string, None) let mut request = self.base.request(Method::GET, region.into(), &format!("/lol/league/v4/challengerleagues/by-queue/{}", queue));
self.base.execute::<league_v4::LeagueList>("league-v4.getChallengerLeague", region.into(), request)
} }
/// Get league entries in all queues for a given summoner ID. /// Get league entries in all queues for a given summoner ID.
@ -562,8 +580,9 @@ impl<'a> LeagueV4<'a> {
pub fn get_league_entries_for_summoner(&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<Vec<league_v4::LeagueEntry>>> + 'a -> impl Future<Output = Result<Vec<league_v4::LeagueEntry>>> + 'a
{ {
let path_string = format!("/lol/league/v4/entries/by-summoner/{}", encrypted_summoner_id); #[allow(unused_mut)]
self.base.get::<Vec<league_v4::LeagueEntry>>("league-v4.getLeagueEntriesForSummoner", region.into(), path_string, None) let mut request = self.base.request(Method::GET, region.into(), &format!("/lol/league/v4/entries/by-summoner/{}", encrypted_summoner_id));
self.base.execute::<Vec<league_v4::LeagueEntry>>("league-v4.getLeagueEntriesForSummoner", region.into(), request)
} }
/// Get all the league entries. /// Get all the league entries.
@ -580,11 +599,10 @@ impl<'a> LeagueV4<'a> {
pub fn get_league_entries(&self, region: Region, queue: crate::consts::QueueType, tier: crate::consts::Tier, division: crate::consts::Division, page: Option<i32>) pub fn get_league_entries(&self, region: Region, queue: crate::consts::QueueType, tier: crate::consts::Tier, division: crate::consts::Division, page: Option<i32>)
-> impl Future<Output = Result<Vec<league_v4::LeagueEntry>>> + 'a -> impl Future<Output = Result<Vec<league_v4::LeagueEntry>>> + 'a
{ {
let mut query_params = Serializer::new(String::new()); #[allow(unused_mut)]
if let Some(page) = page { query_params.append_pair("page", &*page.to_string()); }; let mut request = self.base.request(Method::GET, region.into(), &format!("/lol/league/v4/entries/{}/{}/{}", queue, tier, division));
let query_string = query_params.finish(); if let Some(page) = page { request = request.query(&[ ("page", page) ]); };
let path_string = format!("/lol/league/v4/entries/{}/{}/{}", queue, tier, division); self.base.execute::<Vec<league_v4::LeagueEntry>>("league-v4.getLeagueEntries", region.into(), request)
self.base.get::<Vec<league_v4::LeagueEntry>>("league-v4.getLeagueEntries", region.into(), path_string, Some(query_string))
} }
/// Get the grandmaster league of a specific queue. /// Get the grandmaster league of a specific queue.
@ -598,8 +616,9 @@ impl<'a> LeagueV4<'a> {
pub fn get_grandmaster_league(&self, region: Region, queue: crate::consts::QueueType) pub fn get_grandmaster_league(&self, region: Region, queue: crate::consts::QueueType)
-> impl Future<Output = Result<league_v4::LeagueList>> + 'a -> impl Future<Output = Result<league_v4::LeagueList>> + 'a
{ {
let path_string = format!("/lol/league/v4/grandmasterleagues/by-queue/{}", queue); #[allow(unused_mut)]
self.base.get::<league_v4::LeagueList>("league-v4.getGrandmasterLeague", region.into(), path_string, None) let mut request = self.base.request(Method::GET, region.into(), &format!("/lol/league/v4/grandmasterleagues/by-queue/{}", queue));
self.base.execute::<league_v4::LeagueList>("league-v4.getGrandmasterLeague", region.into(), request)
} }
/// Get league with given ID, including inactive entries. /// Get league with given ID, including inactive entries.
@ -613,8 +632,9 @@ impl<'a> LeagueV4<'a> {
pub fn get_league_by_id(&self, region: Region, league_id: &str) pub fn get_league_by_id(&self, region: Region, league_id: &str)
-> impl Future<Output = Result<Option<league_v4::LeagueList>>> + 'a -> impl Future<Output = Result<Option<league_v4::LeagueList>>> + 'a
{ {
let path_string = format!("/lol/league/v4/leagues/{}", league_id); #[allow(unused_mut)]
self.base.get_optional::<league_v4::LeagueList>("league-v4.getLeagueById", region.into(), path_string, None) let mut request = self.base.request(Method::GET, region.into(), &format!("/lol/league/v4/leagues/{}", league_id));
self.base.execute_optional::<league_v4::LeagueList>("league-v4.getLeagueById", region.into(), request)
} }
/// Get the master league for given queue. /// Get the master league for given queue.
@ -628,8 +648,9 @@ impl<'a> LeagueV4<'a> {
pub fn get_master_league(&self, region: Region, queue: crate::consts::QueueType) pub fn get_master_league(&self, region: Region, queue: crate::consts::QueueType)
-> impl Future<Output = Result<league_v4::LeagueList>> + 'a -> impl Future<Output = Result<league_v4::LeagueList>> + 'a
{ {
let path_string = format!("/lol/league/v4/masterleagues/by-queue/{}", queue); #[allow(unused_mut)]
self.base.get::<league_v4::LeagueList>("league-v4.getMasterLeague", region.into(), path_string, None) let mut request = self.base.request(Method::GET, region.into(), &format!("/lol/league/v4/masterleagues/by-queue/{}", queue));
self.base.execute::<league_v4::LeagueList>("league-v4.getMasterLeague", region.into(), request)
} }
} }
@ -639,6 +660,7 @@ impl<'a> LeagueV4<'a> {
/// <a href="https://developer.riotgames.com/apis#lol-status-v3" target="_blank">`lol-status-v3`</a> /// <a href="https://developer.riotgames.com/apis#lol-status-v3" target="_blank">`lol-status-v3`</a>
/// ///
/// Note: this struct is automatically generated. /// Note: this struct is automatically generated.
#[repr(transparent)]
pub struct LolStatusV3<'a> { pub struct LolStatusV3<'a> {
base: &'a RiotApi, base: &'a RiotApi,
} }
@ -655,8 +677,9 @@ impl<'a> LolStatusV3<'a> {
pub fn get_shard_data(&self, region: Region) pub fn get_shard_data(&self, region: Region)
-> impl Future<Output = Result<lol_status_v3::ShardStatus>> + 'a -> impl Future<Output = Result<lol_status_v3::ShardStatus>> + 'a
{ {
let path_string = "/lol/status/v3/shard-data".to_owned(); #[allow(unused_mut)]
self.base.get::<lol_status_v3::ShardStatus>("lol-status-v3.getShardData", region.into(), path_string, None) let mut request = self.base.request(Method::GET, region.into(), "/lol/status/v3/shard-data");
self.base.execute::<lol_status_v3::ShardStatus>("lol-status-v3.getShardData", region.into(), request)
} }
} }
@ -666,6 +689,7 @@ impl<'a> LolStatusV3<'a> {
/// <a href="https://developer.riotgames.com/apis#lol-status-v4" target="_blank">`lol-status-v4`</a> /// <a href="https://developer.riotgames.com/apis#lol-status-v4" target="_blank">`lol-status-v4`</a>
/// ///
/// Note: this struct is automatically generated. /// Note: this struct is automatically generated.
#[repr(transparent)]
pub struct LolStatusV4<'a> { pub struct LolStatusV4<'a> {
base: &'a RiotApi, base: &'a RiotApi,
} }
@ -680,8 +704,9 @@ impl<'a> LolStatusV4<'a> {
pub fn get_platform_data(&self, region: Region) pub fn get_platform_data(&self, region: Region)
-> impl Future<Output = Result<lol_status_v4::PlatformData>> + 'a -> impl Future<Output = Result<lol_status_v4::PlatformData>> + 'a
{ {
let path_string = "/lol/status/v4/platform-data".to_owned(); #[allow(unused_mut)]
self.base.get::<lol_status_v4::PlatformData>("lol-status-v4.getPlatformData", region.into(), path_string, None) let mut request = self.base.request(Method::GET, region.into(), "/lol/status/v4/platform-data");
self.base.execute::<lol_status_v4::PlatformData>("lol-status-v4.getPlatformData", region.into(), request)
} }
} }
@ -691,6 +716,7 @@ impl<'a> LolStatusV4<'a> {
/// <a href="https://developer.riotgames.com/apis#lor-deck-v1" target="_blank">`lor-deck-v1`</a> /// <a href="https://developer.riotgames.com/apis#lor-deck-v1" target="_blank">`lor-deck-v1`</a>
/// ///
/// Note: this struct is automatically generated. /// Note: this struct is automatically generated.
#[repr(transparent)]
pub struct LorDeckV1<'a> { pub struct LorDeckV1<'a> {
base: &'a RiotApi, base: &'a RiotApi,
} }
@ -702,6 +728,7 @@ impl<'a> LorDeckV1<'a> {
/// <a href="https://developer.riotgames.com/apis#lor-inventory-v1" target="_blank">`lor-inventory-v1`</a> /// <a href="https://developer.riotgames.com/apis#lor-inventory-v1" target="_blank">`lor-inventory-v1`</a>
/// ///
/// Note: this struct is automatically generated. /// Note: this struct is automatically generated.
#[repr(transparent)]
pub struct LorInventoryV1<'a> { pub struct LorInventoryV1<'a> {
base: &'a RiotApi, base: &'a RiotApi,
} }
@ -713,6 +740,7 @@ impl<'a> LorInventoryV1<'a> {
/// <a href="https://developer.riotgames.com/apis#lor-match-v1" target="_blank">`lor-match-v1`</a> /// <a href="https://developer.riotgames.com/apis#lor-match-v1" target="_blank">`lor-match-v1`</a>
/// ///
/// Note: this struct is automatically generated. /// Note: this struct is automatically generated.
#[repr(transparent)]
pub struct LorMatchV1<'a> { pub struct LorMatchV1<'a> {
base: &'a RiotApi, base: &'a RiotApi,
} }
@ -728,8 +756,9 @@ impl<'a> LorMatchV1<'a> {
pub fn get_match_ids_by_puuid(&self, region: Region, puuid: &str) pub fn get_match_ids_by_puuid(&self, region: Region, puuid: &str)
-> impl Future<Output = Result<Vec<String>>> + 'a -> impl Future<Output = Result<Vec<String>>> + 'a
{ {
let path_string = format!("/lor/match/v1/matches/by-puuid/{}/ids", puuid); #[allow(unused_mut)]
self.base.get::<Vec<String>>("lor-match-v1.getMatchIdsByPUUID", region.into(), path_string, None) let mut request = self.base.request(Method::GET, region.into(), &format!("/lor/match/v1/matches/by-puuid/{}/ids", puuid));
self.base.execute::<Vec<String>>("lor-match-v1.getMatchIdsByPUUID", region.into(), request)
} }
/// Get match by id /// Get match by id
@ -743,8 +772,9 @@ impl<'a> LorMatchV1<'a> {
pub fn get_match(&self, region: Region, match_id: &str) pub fn get_match(&self, region: Region, match_id: &str)
-> impl Future<Output = Result<lor_match_v1::Match>> + 'a -> impl Future<Output = Result<lor_match_v1::Match>> + 'a
{ {
let path_string = format!("/lor/match/v1/matches/{}", match_id); #[allow(unused_mut)]
self.base.get::<lor_match_v1::Match>("lor-match-v1.getMatch", region.into(), path_string, None) let mut request = self.base.request(Method::GET, region.into(), &format!("/lor/match/v1/matches/{}", match_id));
self.base.execute::<lor_match_v1::Match>("lor-match-v1.getMatch", region.into(), request)
} }
} }
@ -754,6 +784,7 @@ impl<'a> LorMatchV1<'a> {
/// <a href="https://developer.riotgames.com/apis#lor-ranked-v1" target="_blank">`lor-ranked-v1`</a> /// <a href="https://developer.riotgames.com/apis#lor-ranked-v1" target="_blank">`lor-ranked-v1`</a>
/// ///
/// Note: this struct is automatically generated. /// Note: this struct is automatically generated.
#[repr(transparent)]
pub struct LorRankedV1<'a> { pub struct LorRankedV1<'a> {
base: &'a RiotApi, base: &'a RiotApi,
} }
@ -768,8 +799,9 @@ impl<'a> LorRankedV1<'a> {
pub fn get_leaderboards(&self, region: Region) pub fn get_leaderboards(&self, region: Region)
-> impl Future<Output = Result<lor_ranked_v1::Leaderboard>> + 'a -> impl Future<Output = Result<lor_ranked_v1::Leaderboard>> + 'a
{ {
let path_string = "/lor/ranked/v1/leaderboards".to_owned(); #[allow(unused_mut)]
self.base.get::<lor_ranked_v1::Leaderboard>("lor-ranked-v1.getLeaderboards", region.into(), path_string, None) let mut request = self.base.request(Method::GET, region.into(), "/lor/ranked/v1/leaderboards");
self.base.execute::<lor_ranked_v1::Leaderboard>("lor-ranked-v1.getLeaderboards", region.into(), request)
} }
} }
@ -779,6 +811,7 @@ impl<'a> LorRankedV1<'a> {
/// <a href="https://developer.riotgames.com/apis#lor-status-v1" target="_blank">`lor-status-v1`</a> /// <a href="https://developer.riotgames.com/apis#lor-status-v1" target="_blank">`lor-status-v1`</a>
/// ///
/// Note: this struct is automatically generated. /// Note: this struct is automatically generated.
#[repr(transparent)]
pub struct LorStatusV1<'a> { pub struct LorStatusV1<'a> {
base: &'a RiotApi, base: &'a RiotApi,
} }
@ -793,8 +826,9 @@ impl<'a> LorStatusV1<'a> {
pub fn get_platform_data(&self, region: Region) pub fn get_platform_data(&self, region: Region)
-> impl Future<Output = Result<lor_status_v1::PlatformData>> + 'a -> impl Future<Output = Result<lor_status_v1::PlatformData>> + 'a
{ {
let path_string = "/lor/status/v1/platform-data".to_owned(); #[allow(unused_mut)]
self.base.get::<lor_status_v1::PlatformData>("lor-status-v1.getPlatformData", region.into(), path_string, None) let mut request = self.base.request(Method::GET, region.into(), "/lor/status/v1/platform-data");
self.base.execute::<lor_status_v1::PlatformData>("lor-status-v1.getPlatformData", region.into(), request)
} }
} }
@ -804,6 +838,7 @@ impl<'a> LorStatusV1<'a> {
/// <a href="https://developer.riotgames.com/apis#match-v4" target="_blank">`match-v4`</a> /// <a href="https://developer.riotgames.com/apis#match-v4" target="_blank">`match-v4`</a>
/// ///
/// Note: this struct is automatically generated. /// Note: this struct is automatically generated.
#[repr(transparent)]
pub struct MatchV4<'a> { pub struct MatchV4<'a> {
base: &'a RiotApi, base: &'a RiotApi,
} }
@ -819,8 +854,9 @@ impl<'a> MatchV4<'a> {
pub fn get_match_ids_by_tournament_code(&self, region: Region, tournament_code: &str) pub fn get_match_ids_by_tournament_code(&self, region: Region, tournament_code: &str)
-> impl Future<Output = Result<Vec<i64>>> + 'a -> impl Future<Output = Result<Vec<i64>>> + 'a
{ {
let path_string = format!("/lol/match/v4/matches/by-tournament-code/{}/ids", tournament_code); #[allow(unused_mut)]
self.base.get::<Vec<i64>>("match-v4.getMatchIdsByTournamentCode", region.into(), path_string, None) let mut request = self.base.request(Method::GET, region.into(), &format!("/lol/match/v4/matches/by-tournament-code/{}/ids", tournament_code));
self.base.execute::<Vec<i64>>("match-v4.getMatchIdsByTournamentCode", region.into(), request)
} }
/// Get match by match ID. /// Get match by match ID.
@ -834,8 +870,9 @@ impl<'a> MatchV4<'a> {
pub fn get_match(&self, region: Region, match_id: i64) pub fn get_match(&self, region: Region, match_id: i64)
-> impl Future<Output = Result<Option<match_v4::Match>>> + 'a -> impl Future<Output = Result<Option<match_v4::Match>>> + 'a
{ {
let path_string = format!("/lol/match/v4/matches/{}", match_id); #[allow(unused_mut)]
self.base.get_optional::<match_v4::Match>("match-v4.getMatch", region.into(), path_string, None) let mut request = self.base.request(Method::GET, region.into(), &format!("/lol/match/v4/matches/{}", match_id));
self.base.execute_optional::<match_v4::Match>("match-v4.getMatch", region.into(), request)
} }
/// Get match by match ID and tournament code. /// Get match by match ID and tournament code.
@ -850,8 +887,9 @@ impl<'a> MatchV4<'a> {
pub fn get_match_by_tournament_code(&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<match_v4::Match>> + 'a -> impl Future<Output = Result<match_v4::Match>> + 'a
{ {
let path_string = format!("/lol/match/v4/matches/{}/by-tournament-code/{}", match_id, tournament_code); #[allow(unused_mut)]
self.base.get::<match_v4::Match>("match-v4.getMatchByTournamentCode", region.into(), path_string, None) let mut request = self.base.request(Method::GET, region.into(), &format!("/lol/match/v4/matches/{}/by-tournament-code/{}", match_id, tournament_code));
self.base.execute::<match_v4::Match>("match-v4.getMatchByTournamentCode", region.into(), request)
} }
/// 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.
@ -878,17 +916,16 @@ impl<'a> MatchV4<'a> {
pub fn get_matchlist(&self, region: Region, encrypted_account_id: &str, begin_time: Option<i64>, begin_index: Option<i32>, champion: Option<&[crate::consts::Champion]>, end_time: Option<i64>, end_index: Option<i32>, queue: Option<&[crate::consts::Queue]>, season: Option<&[crate::consts::Season]>) pub fn get_matchlist(&self, region: Region, encrypted_account_id: &str, begin_time: Option<i64>, begin_index: Option<i32>, champion: Option<&[crate::consts::Champion]>, end_time: Option<i64>, end_index: Option<i32>, queue: Option<&[crate::consts::Queue]>, season: Option<&[crate::consts::Season]>)
-> impl Future<Output = Result<Option<match_v4::Matchlist>>> + 'a -> impl Future<Output = Result<Option<match_v4::Matchlist>>> + 'a
{ {
let mut query_params = Serializer::new(String::new()); #[allow(unused_mut)]
if let Some(begin_time) = begin_time { query_params.append_pair("beginTime", &*begin_time.to_string()); }; let mut request = self.base.request(Method::GET, region.into(), &format!("/lol/match/v4/matchlists/by-account/{}", encrypted_account_id));
if let Some(begin_index) = begin_index { query_params.append_pair("beginIndex", &*begin_index.to_string()); }; if let Some(begin_time) = begin_time { request = request.query(&[ ("beginTime", begin_time) ]); };
if let Some(champion) = champion { query_params.extend_pairs(champion.iter().map(|w| ("champion", Into::<i16>::into(*w).to_string()))); }; if let Some(begin_index) = begin_index { request = request.query(&[ ("beginIndex", begin_index) ]); };
if let Some(end_time) = end_time { query_params.append_pair("endTime", &*end_time.to_string()); }; if let Some(champion) = champion { request = request.query(&*champion.iter().map(|w| ( "champion", w )).collect::<Vec<_>>()); };
if let Some(end_index) = end_index { query_params.append_pair("endIndex", &*end_index.to_string()); }; if let Some(end_time) = end_time { request = request.query(&[ ("endTime", end_time) ]); };
if let Some(queue) = queue { query_params.extend_pairs(queue.iter().map(|w| ("queue", Into::<u16>::into(*w).to_string()))); }; if let Some(end_index) = end_index { request = request.query(&[ ("endIndex", end_index) ]); };
if let Some(season) = season { query_params.extend_pairs(season.iter().map(|w| ("season", Into::<u8>::into(*w).to_string()))); }; if let Some(queue) = queue { request = request.query(&*queue.iter().map(|w| ( "queue", w )).collect::<Vec<_>>()); };
let query_string = query_params.finish(); if let Some(season) = season { request = request.query(&*season.iter().map(|w| ( "season", w )).collect::<Vec<_>>()); };
let path_string = format!("/lol/match/v4/matchlists/by-account/{}", encrypted_account_id); self.base.execute_optional::<match_v4::Matchlist>("match-v4.getMatchlist", region.into(), request)
self.base.get_optional::<match_v4::Matchlist>("match-v4.getMatchlist", region.into(), path_string, Some(query_string))
} }
/// Get match timeline by match ID. /// Get match timeline by match ID.
@ -904,8 +941,9 @@ impl<'a> MatchV4<'a> {
pub fn get_match_timeline(&self, region: Region, match_id: i64) pub fn get_match_timeline(&self, region: Region, match_id: i64)
-> impl Future<Output = Result<Option<match_v4::MatchTimeline>>> + 'a -> impl Future<Output = Result<Option<match_v4::MatchTimeline>>> + 'a
{ {
let path_string = format!("/lol/match/v4/timelines/by-match/{}", match_id); #[allow(unused_mut)]
self.base.get_optional::<match_v4::MatchTimeline>("match-v4.getMatchTimeline", region.into(), path_string, None) let mut request = self.base.request(Method::GET, region.into(), &format!("/lol/match/v4/timelines/by-match/{}", match_id));
self.base.execute_optional::<match_v4::MatchTimeline>("match-v4.getMatchTimeline", region.into(), request)
} }
} }
@ -915,6 +953,7 @@ impl<'a> MatchV4<'a> {
/// <a href="https://developer.riotgames.com/apis#match-v5" target="_blank">`match-v5`</a> /// <a href="https://developer.riotgames.com/apis#match-v5" target="_blank">`match-v5`</a>
/// ///
/// Note: this struct is automatically generated. /// Note: this struct is automatically generated.
#[repr(transparent)]
pub struct MatchV5<'a> { pub struct MatchV5<'a> {
base: &'a RiotApi, base: &'a RiotApi,
} }
@ -932,12 +971,11 @@ impl<'a> MatchV5<'a> {
pub fn get_match_ids_by_puuid(&self, region: Region, puuid: &str, count: Option<i32>, start: Option<i32>) pub fn get_match_ids_by_puuid(&self, region: Region, puuid: &str, count: Option<i32>, start: Option<i32>)
-> impl Future<Output = Result<Vec<String>>> + 'a -> impl Future<Output = Result<Vec<String>>> + 'a
{ {
let mut query_params = Serializer::new(String::new()); #[allow(unused_mut)]
if let Some(count) = count { query_params.append_pair("count", &*count.to_string()); }; let mut request = self.base.request(Method::GET, region.into(), &format!("/lol/match/v5/matches/by-puuid/{}/ids", puuid));
if let Some(start) = start { query_params.append_pair("start", &*start.to_string()); }; if let Some(count) = count { request = request.query(&[ ("count", count) ]); };
let query_string = query_params.finish(); if let Some(start) = start { request = request.query(&[ ("start", start) ]); };
let path_string = format!("/lol/match/v5/matches/by-puuid/{}/ids", puuid); self.base.execute::<Vec<String>>("match-v5.getMatchIdsByPUUID", region.into(), request)
self.base.get::<Vec<String>>("match-v5.getMatchIdsByPUUID", region.into(), path_string, Some(query_string))
} }
/// Get a match by match id /// Get a match by match id
@ -951,8 +989,9 @@ impl<'a> MatchV5<'a> {
pub fn get_match(&self, region: Region, match_id: &str) pub fn get_match(&self, region: Region, match_id: &str)
-> impl Future<Output = Result<match_v5::Match>> + 'a -> impl Future<Output = Result<match_v5::Match>> + 'a
{ {
let path_string = format!("/lol/match/v5/matches/{}", match_id); #[allow(unused_mut)]
self.base.get::<match_v5::Match>("match-v5.getMatch", region.into(), path_string, None) let mut request = self.base.request(Method::GET, region.into(), &format!("/lol/match/v5/matches/{}", match_id));
self.base.execute::<match_v5::Match>("match-v5.getMatch", region.into(), request)
} }
/// Get a match timeline by match id /// Get a match timeline by match id
@ -966,8 +1005,9 @@ impl<'a> MatchV5<'a> {
pub fn get_timeline(&self, region: Region, match_id: &str) pub fn get_timeline(&self, region: Region, match_id: &str)
-> impl Future<Output = Result<match_v5::MatchTimeline>> + 'a -> impl Future<Output = Result<match_v5::MatchTimeline>> + 'a
{ {
let path_string = format!("/lol/match/v5/matches/{}/timeline", match_id); #[allow(unused_mut)]
self.base.get::<match_v5::MatchTimeline>("match-v5.getTimeline", region.into(), path_string, None) let mut request = self.base.request(Method::GET, region.into(), &format!("/lol/match/v5/matches/{}/timeline", match_id));
self.base.execute::<match_v5::MatchTimeline>("match-v5.getTimeline", region.into(), request)
} }
} }
@ -977,6 +1017,7 @@ impl<'a> MatchV5<'a> {
/// <a href="https://developer.riotgames.com/apis#spectator-v4" target="_blank">`spectator-v4`</a> /// <a href="https://developer.riotgames.com/apis#spectator-v4" target="_blank">`spectator-v4`</a>
/// ///
/// Note: this struct is automatically generated. /// Note: this struct is automatically generated.
#[repr(transparent)]
pub struct SpectatorV4<'a> { pub struct SpectatorV4<'a> {
base: &'a RiotApi, base: &'a RiotApi,
} }
@ -992,8 +1033,9 @@ impl<'a> SpectatorV4<'a> {
pub fn get_current_game_info_by_summoner(&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<spectator_v4::CurrentGameInfo>>> + 'a -> impl Future<Output = Result<Option<spectator_v4::CurrentGameInfo>>> + 'a
{ {
let path_string = format!("/lol/spectator/v4/active-games/by-summoner/{}", encrypted_summoner_id); #[allow(unused_mut)]
self.base.get_optional::<spectator_v4::CurrentGameInfo>("spectator-v4.getCurrentGameInfoBySummoner", region.into(), path_string, None) let mut request = self.base.request(Method::GET, region.into(), &format!("/lol/spectator/v4/active-games/by-summoner/{}", encrypted_summoner_id));
self.base.execute_optional::<spectator_v4::CurrentGameInfo>("spectator-v4.getCurrentGameInfoBySummoner", region.into(), request)
} }
/// Get list of featured games. /// Get list of featured games.
@ -1006,8 +1048,9 @@ impl<'a> SpectatorV4<'a> {
pub fn get_featured_games(&self, region: Region) pub fn get_featured_games(&self, region: Region)
-> impl Future<Output = Result<spectator_v4::FeaturedGames>> + 'a -> impl Future<Output = Result<spectator_v4::FeaturedGames>> + 'a
{ {
let path_string = "/lol/spectator/v4/featured-games".to_owned(); #[allow(unused_mut)]
self.base.get::<spectator_v4::FeaturedGames>("spectator-v4.getFeaturedGames", region.into(), path_string, None) let mut request = self.base.request(Method::GET, region.into(), "/lol/spectator/v4/featured-games");
self.base.execute::<spectator_v4::FeaturedGames>("spectator-v4.getFeaturedGames", region.into(), request)
} }
} }
@ -1017,6 +1060,7 @@ impl<'a> SpectatorV4<'a> {
/// <a href="https://developer.riotgames.com/apis#summoner-v4" target="_blank">`summoner-v4`</a> /// <a href="https://developer.riotgames.com/apis#summoner-v4" target="_blank">`summoner-v4`</a>
/// ///
/// Note: this struct is automatically generated. /// Note: this struct is automatically generated.
#[repr(transparent)]
pub struct SummonerV4<'a> { pub struct SummonerV4<'a> {
base: &'a RiotApi, base: &'a RiotApi,
} }
@ -1032,8 +1076,9 @@ impl<'a> SummonerV4<'a> {
pub fn get_by_account_id(&self, region: Region, encrypted_account_id: &str) pub fn get_by_account_id(&self, region: Region, encrypted_account_id: &str)
-> impl Future<Output = Result<summoner_v4::Summoner>> + 'a -> impl Future<Output = Result<summoner_v4::Summoner>> + 'a
{ {
let path_string = format!("/lol/summoner/v4/summoners/by-account/{}", encrypted_account_id); #[allow(unused_mut)]
self.base.get::<summoner_v4::Summoner>("summoner-v4.getByAccountId", region.into(), path_string, None) let mut request = self.base.request(Method::GET, region.into(), &format!("/lol/summoner/v4/summoners/by-account/{}", encrypted_account_id));
self.base.execute::<summoner_v4::Summoner>("summoner-v4.getByAccountId", region.into(), request)
} }
/// Get a summoner by summoner name. /// Get a summoner by summoner name.
@ -1047,8 +1092,9 @@ impl<'a> SummonerV4<'a> {
pub fn get_by_summoner_name(&self, region: Region, summoner_name: &str) pub fn get_by_summoner_name(&self, region: Region, summoner_name: &str)
-> impl Future<Output = Result<Option<summoner_v4::Summoner>>> + 'a -> impl Future<Output = Result<Option<summoner_v4::Summoner>>> + 'a
{ {
let path_string = format!("/lol/summoner/v4/summoners/by-name/{}", summoner_name); #[allow(unused_mut)]
self.base.get_optional::<summoner_v4::Summoner>("summoner-v4.getBySummonerName", region.into(), path_string, None) let mut request = self.base.request(Method::GET, region.into(), &format!("/lol/summoner/v4/summoners/by-name/{}", summoner_name));
self.base.execute_optional::<summoner_v4::Summoner>("summoner-v4.getBySummonerName", region.into(), request)
} }
/// Get a summoner by PUUID. /// Get a summoner by PUUID.
@ -1062,8 +1108,9 @@ impl<'a> SummonerV4<'a> {
pub fn get_by_puuid(&self, region: Region, encrypted_puuid: &str) pub fn get_by_puuid(&self, region: Region, encrypted_puuid: &str)
-> impl Future<Output = Result<summoner_v4::Summoner>> + 'a -> impl Future<Output = Result<summoner_v4::Summoner>> + 'a
{ {
let path_string = format!("/lol/summoner/v4/summoners/by-puuid/{}", encrypted_puuid); #[allow(unused_mut)]
self.base.get::<summoner_v4::Summoner>("summoner-v4.getByPUUID", region.into(), path_string, None) let mut request = self.base.request(Method::GET, region.into(), &format!("/lol/summoner/v4/summoners/by-puuid/{}", encrypted_puuid));
self.base.execute::<summoner_v4::Summoner>("summoner-v4.getByPUUID", region.into(), request)
} }
/// Get a summoner by summoner ID. /// Get a summoner by summoner ID.
@ -1077,8 +1124,9 @@ impl<'a> SummonerV4<'a> {
pub fn get_by_summoner_id(&self, region: Region, encrypted_summoner_id: &str) pub fn get_by_summoner_id(&self, region: Region, encrypted_summoner_id: &str)
-> impl Future<Output = Result<summoner_v4::Summoner>> + 'a -> impl Future<Output = Result<summoner_v4::Summoner>> + 'a
{ {
let path_string = format!("/lol/summoner/v4/summoners/{}", encrypted_summoner_id); #[allow(unused_mut)]
self.base.get::<summoner_v4::Summoner>("summoner-v4.getBySummonerId", region.into(), path_string, None) let mut request = self.base.request(Method::GET, region.into(), &format!("/lol/summoner/v4/summoners/{}", encrypted_summoner_id));
self.base.execute::<summoner_v4::Summoner>("summoner-v4.getBySummonerId", region.into(), request)
} }
} }
@ -1088,6 +1136,7 @@ impl<'a> SummonerV4<'a> {
/// <a href="https://developer.riotgames.com/apis#tft-league-v1" target="_blank">`tft-league-v1`</a> /// <a href="https://developer.riotgames.com/apis#tft-league-v1" target="_blank">`tft-league-v1`</a>
/// ///
/// Note: this struct is automatically generated. /// Note: this struct is automatically generated.
#[repr(transparent)]
pub struct TftLeagueV1<'a> { pub struct TftLeagueV1<'a> {
base: &'a RiotApi, base: &'a RiotApi,
} }
@ -1102,8 +1151,9 @@ impl<'a> TftLeagueV1<'a> {
pub fn get_challenger_league(&self, region: Region) pub fn get_challenger_league(&self, region: Region)
-> impl Future<Output = Result<tft_league_v1::LeagueList>> + 'a -> impl Future<Output = Result<tft_league_v1::LeagueList>> + 'a
{ {
let path_string = "/tft/league/v1/challenger".to_owned(); #[allow(unused_mut)]
self.base.get::<tft_league_v1::LeagueList>("tft-league-v1.getChallengerLeague", region.into(), path_string, None) let mut request = self.base.request(Method::GET, region.into(), "/tft/league/v1/challenger");
self.base.execute::<tft_league_v1::LeagueList>("tft-league-v1.getChallengerLeague", region.into(), request)
} }
/// Get league entries for a given summoner ID. /// Get league entries for a given summoner ID.
@ -1117,8 +1167,9 @@ impl<'a> TftLeagueV1<'a> {
pub fn get_league_entries_for_summoner(&self, region: Region, summoner_id: &str) pub fn get_league_entries_for_summoner(&self, region: Region, summoner_id: &str)
-> impl Future<Output = Result<Vec<tft_league_v1::LeagueEntry>>> + 'a -> impl Future<Output = Result<Vec<tft_league_v1::LeagueEntry>>> + 'a
{ {
let path_string = format!("/tft/league/v1/entries/by-summoner/{}", summoner_id); #[allow(unused_mut)]
self.base.get::<Vec<tft_league_v1::LeagueEntry>>("tft-league-v1.getLeagueEntriesForSummoner", region.into(), path_string, None) let mut request = self.base.request(Method::GET, region.into(), &format!("/tft/league/v1/entries/by-summoner/{}", summoner_id));
self.base.execute::<Vec<tft_league_v1::LeagueEntry>>("tft-league-v1.getLeagueEntriesForSummoner", region.into(), request)
} }
/// Get all the league entries. /// Get all the league entries.
@ -1134,11 +1185,10 @@ impl<'a> TftLeagueV1<'a> {
pub fn get_league_entries(&self, region: Region, tier: &str, division: &str, page: Option<i32>) pub fn get_league_entries(&self, region: Region, tier: &str, division: &str, page: Option<i32>)
-> impl Future<Output = Result<Vec<tft_league_v1::LeagueEntry>>> + 'a -> impl Future<Output = Result<Vec<tft_league_v1::LeagueEntry>>> + 'a
{ {
let mut query_params = Serializer::new(String::new()); #[allow(unused_mut)]
if let Some(page) = page { query_params.append_pair("page", &*page.to_string()); }; let mut request = self.base.request(Method::GET, region.into(), &format!("/tft/league/v1/entries/{}/{}", tier, division));
let query_string = query_params.finish(); if let Some(page) = page { request = request.query(&[ ("page", page) ]); };
let path_string = format!("/tft/league/v1/entries/{}/{}", tier, division); self.base.execute::<Vec<tft_league_v1::LeagueEntry>>("tft-league-v1.getLeagueEntries", region.into(), request)
self.base.get::<Vec<tft_league_v1::LeagueEntry>>("tft-league-v1.getLeagueEntries", region.into(), path_string, Some(query_string))
} }
/// Get the grandmaster league. /// Get the grandmaster league.
@ -1151,8 +1201,9 @@ impl<'a> TftLeagueV1<'a> {
pub fn get_grandmaster_league(&self, region: Region) pub fn get_grandmaster_league(&self, region: Region)
-> impl Future<Output = Result<tft_league_v1::LeagueList>> + 'a -> impl Future<Output = Result<tft_league_v1::LeagueList>> + 'a
{ {
let path_string = "/tft/league/v1/grandmaster".to_owned(); #[allow(unused_mut)]
self.base.get::<tft_league_v1::LeagueList>("tft-league-v1.getGrandmasterLeague", region.into(), path_string, None) let mut request = self.base.request(Method::GET, region.into(), "/tft/league/v1/grandmaster");
self.base.execute::<tft_league_v1::LeagueList>("tft-league-v1.getGrandmasterLeague", region.into(), request)
} }
/// Get league with given ID, including inactive entries. /// Get league with given ID, including inactive entries.
@ -1166,8 +1217,9 @@ impl<'a> TftLeagueV1<'a> {
pub fn get_league_by_id(&self, region: Region, league_id: &str) pub fn get_league_by_id(&self, region: Region, league_id: &str)
-> impl Future<Output = Result<Option<tft_league_v1::LeagueList>>> + 'a -> impl Future<Output = Result<Option<tft_league_v1::LeagueList>>> + 'a
{ {
let path_string = format!("/tft/league/v1/leagues/{}", league_id); #[allow(unused_mut)]
self.base.get_optional::<tft_league_v1::LeagueList>("tft-league-v1.getLeagueById", region.into(), path_string, None) let mut request = self.base.request(Method::GET, region.into(), &format!("/tft/league/v1/leagues/{}", league_id));
self.base.execute_optional::<tft_league_v1::LeagueList>("tft-league-v1.getLeagueById", region.into(), request)
} }
/// Get the master league. /// Get the master league.
@ -1180,8 +1232,9 @@ impl<'a> TftLeagueV1<'a> {
pub fn get_master_league(&self, region: Region) pub fn get_master_league(&self, region: Region)
-> impl Future<Output = Result<tft_league_v1::LeagueList>> + 'a -> impl Future<Output = Result<tft_league_v1::LeagueList>> + 'a
{ {
let path_string = "/tft/league/v1/master".to_owned(); #[allow(unused_mut)]
self.base.get::<tft_league_v1::LeagueList>("tft-league-v1.getMasterLeague", region.into(), path_string, None) let mut request = self.base.request(Method::GET, region.into(), "/tft/league/v1/master");
self.base.execute::<tft_league_v1::LeagueList>("tft-league-v1.getMasterLeague", region.into(), request)
} }
/// Get the top rated ladder for given queue /// Get the top rated ladder for given queue
@ -1195,8 +1248,9 @@ impl<'a> TftLeagueV1<'a> {
pub fn get_top_rated_ladder(&self, region: Region, queue: crate::consts::QueueType) pub fn get_top_rated_ladder(&self, region: Region, queue: crate::consts::QueueType)
-> impl Future<Output = Result<Vec<tft_league_v1::TopRatedLadderEntry>>> + 'a -> impl Future<Output = Result<Vec<tft_league_v1::TopRatedLadderEntry>>> + 'a
{ {
let path_string = format!("/tft/league/v1/rated-ladders/{}/top", queue); #[allow(unused_mut)]
self.base.get::<Vec<tft_league_v1::TopRatedLadderEntry>>("tft-league-v1.getTopRatedLadder", region.into(), path_string, None) let mut request = self.base.request(Method::GET, region.into(), &format!("/tft/league/v1/rated-ladders/{}/top", queue));
self.base.execute::<Vec<tft_league_v1::TopRatedLadderEntry>>("tft-league-v1.getTopRatedLadder", region.into(), request)
} }
} }
@ -1206,6 +1260,7 @@ impl<'a> TftLeagueV1<'a> {
/// <a href="https://developer.riotgames.com/apis#tft-match-v1" target="_blank">`tft-match-v1`</a> /// <a href="https://developer.riotgames.com/apis#tft-match-v1" target="_blank">`tft-match-v1`</a>
/// ///
/// Note: this struct is automatically generated. /// Note: this struct is automatically generated.
#[repr(transparent)]
pub struct TftMatchV1<'a> { pub struct TftMatchV1<'a> {
base: &'a RiotApi, base: &'a RiotApi,
} }
@ -1222,11 +1277,10 @@ impl<'a> TftMatchV1<'a> {
pub fn get_match_ids_by_puuid(&self, region: Region, puuid: &str, count: Option<i32>) pub fn get_match_ids_by_puuid(&self, region: Region, puuid: &str, count: Option<i32>)
-> impl Future<Output = Result<Vec<String>>> + 'a -> impl Future<Output = Result<Vec<String>>> + 'a
{ {
let mut query_params = Serializer::new(String::new()); #[allow(unused_mut)]
if let Some(count) = count { query_params.append_pair("count", &*count.to_string()); }; let mut request = self.base.request(Method::GET, region.into(), &format!("/tft/match/v1/matches/by-puuid/{}/ids", puuid));
let query_string = query_params.finish(); if let Some(count) = count { request = request.query(&[ ("count", count) ]); };
let path_string = format!("/tft/match/v1/matches/by-puuid/{}/ids", puuid); self.base.execute::<Vec<String>>("tft-match-v1.getMatchIdsByPUUID", region.into(), request)
self.base.get::<Vec<String>>("tft-match-v1.getMatchIdsByPUUID", region.into(), path_string, Some(query_string))
} }
/// Get a match by match id /// Get a match by match id
@ -1240,8 +1294,9 @@ impl<'a> TftMatchV1<'a> {
pub fn get_match(&self, region: Region, match_id: &str) pub fn get_match(&self, region: Region, match_id: &str)
-> impl Future<Output = Result<Option<tft_match_v1::Match>>> + 'a -> impl Future<Output = Result<Option<tft_match_v1::Match>>> + 'a
{ {
let path_string = format!("/tft/match/v1/matches/{}", match_id); #[allow(unused_mut)]
self.base.get_optional::<tft_match_v1::Match>("tft-match-v1.getMatch", region.into(), path_string, None) let mut request = self.base.request(Method::GET, region.into(), &format!("/tft/match/v1/matches/{}", match_id));
self.base.execute_optional::<tft_match_v1::Match>("tft-match-v1.getMatch", region.into(), request)
} }
} }
@ -1251,6 +1306,7 @@ impl<'a> TftMatchV1<'a> {
/// <a href="https://developer.riotgames.com/apis#tft-summoner-v1" target="_blank">`tft-summoner-v1`</a> /// <a href="https://developer.riotgames.com/apis#tft-summoner-v1" target="_blank">`tft-summoner-v1`</a>
/// ///
/// Note: this struct is automatically generated. /// Note: this struct is automatically generated.
#[repr(transparent)]
pub struct TftSummonerV1<'a> { pub struct TftSummonerV1<'a> {
base: &'a RiotApi, base: &'a RiotApi,
} }
@ -1266,8 +1322,9 @@ impl<'a> TftSummonerV1<'a> {
pub fn get_by_account_id(&self, region: Region, encrypted_account_id: &str) pub fn get_by_account_id(&self, region: Region, encrypted_account_id: &str)
-> impl Future<Output = Result<tft_summoner_v1::Summoner>> + 'a -> impl Future<Output = Result<tft_summoner_v1::Summoner>> + 'a
{ {
let path_string = format!("/tft/summoner/v1/summoners/by-account/{}", encrypted_account_id); #[allow(unused_mut)]
self.base.get::<tft_summoner_v1::Summoner>("tft-summoner-v1.getByAccountId", region.into(), path_string, None) let mut request = self.base.request(Method::GET, region.into(), &format!("/tft/summoner/v1/summoners/by-account/{}", encrypted_account_id));
self.base.execute::<tft_summoner_v1::Summoner>("tft-summoner-v1.getByAccountId", region.into(), request)
} }
/// Get a summoner by summoner name. /// Get a summoner by summoner name.
@ -1281,8 +1338,9 @@ impl<'a> TftSummonerV1<'a> {
pub fn get_by_summoner_name(&self, region: Region, summoner_name: &str) pub fn get_by_summoner_name(&self, region: Region, summoner_name: &str)
-> impl Future<Output = Result<Option<tft_summoner_v1::Summoner>>> + 'a -> impl Future<Output = Result<Option<tft_summoner_v1::Summoner>>> + 'a
{ {
let path_string = format!("/tft/summoner/v1/summoners/by-name/{}", summoner_name); #[allow(unused_mut)]
self.base.get_optional::<tft_summoner_v1::Summoner>("tft-summoner-v1.getBySummonerName", region.into(), path_string, None) let mut request = self.base.request(Method::GET, region.into(), &format!("/tft/summoner/v1/summoners/by-name/{}", summoner_name));
self.base.execute_optional::<tft_summoner_v1::Summoner>("tft-summoner-v1.getBySummonerName", region.into(), request)
} }
/// Get a summoner by PUUID. /// Get a summoner by PUUID.
@ -1296,8 +1354,9 @@ impl<'a> TftSummonerV1<'a> {
pub fn get_by_puuid(&self, region: Region, encrypted_puuid: &str) pub fn get_by_puuid(&self, region: Region, encrypted_puuid: &str)
-> impl Future<Output = Result<tft_summoner_v1::Summoner>> + 'a -> impl Future<Output = Result<tft_summoner_v1::Summoner>> + 'a
{ {
let path_string = format!("/tft/summoner/v1/summoners/by-puuid/{}", encrypted_puuid); #[allow(unused_mut)]
self.base.get::<tft_summoner_v1::Summoner>("tft-summoner-v1.getByPUUID", region.into(), path_string, None) let mut request = self.base.request(Method::GET, region.into(), &format!("/tft/summoner/v1/summoners/by-puuid/{}", encrypted_puuid));
self.base.execute::<tft_summoner_v1::Summoner>("tft-summoner-v1.getByPUUID", region.into(), request)
} }
/// Get a summoner by summoner ID. /// Get a summoner by summoner ID.
@ -1311,8 +1370,9 @@ impl<'a> TftSummonerV1<'a> {
pub fn get_by_summoner_id(&self, region: Region, encrypted_summoner_id: &str) pub fn get_by_summoner_id(&self, region: Region, encrypted_summoner_id: &str)
-> impl Future<Output = Result<tft_summoner_v1::Summoner>> + 'a -> impl Future<Output = Result<tft_summoner_v1::Summoner>> + 'a
{ {
let path_string = format!("/tft/summoner/v1/summoners/{}", encrypted_summoner_id); #[allow(unused_mut)]
self.base.get::<tft_summoner_v1::Summoner>("tft-summoner-v1.getBySummonerId", region.into(), path_string, None) let mut request = self.base.request(Method::GET, region.into(), &format!("/tft/summoner/v1/summoners/{}", encrypted_summoner_id));
self.base.execute::<tft_summoner_v1::Summoner>("tft-summoner-v1.getBySummonerId", region.into(), request)
} }
} }
@ -1322,6 +1382,7 @@ impl<'a> TftSummonerV1<'a> {
/// <a href="https://developer.riotgames.com/apis#third-party-code-v4" target="_blank">`third-party-code-v4`</a> /// <a href="https://developer.riotgames.com/apis#third-party-code-v4" target="_blank">`third-party-code-v4`</a>
/// ///
/// Note: this struct is automatically generated. /// Note: this struct is automatically generated.
#[repr(transparent)]
pub struct ThirdPartyCodeV4<'a> { pub struct ThirdPartyCodeV4<'a> {
base: &'a RiotApi, base: &'a RiotApi,
} }
@ -1337,8 +1398,9 @@ impl<'a> ThirdPartyCodeV4<'a> {
pub fn get_third_party_code_by_summoner_id(&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<String>> + 'a -> impl Future<Output = Result<String>> + 'a
{ {
let path_string = format!("/lol/platform/v4/third-party-code/by-summoner/{}", encrypted_summoner_id); #[allow(unused_mut)]
self.base.get::<String>("third-party-code-v4.getThirdPartyCodeBySummonerId", region.into(), path_string, None) let mut request = self.base.request(Method::GET, region.into(), &format!("/lol/platform/v4/third-party-code/by-summoner/{}", encrypted_summoner_id));
self.base.execute::<String>("third-party-code-v4.getThirdPartyCodeBySummonerId", region.into(), request)
} }
} }
@ -1348,6 +1410,7 @@ impl<'a> ThirdPartyCodeV4<'a> {
/// <a href="https://developer.riotgames.com/apis#tournament-stub-v4" target="_blank">`tournament-stub-v4`</a> /// <a href="https://developer.riotgames.com/apis#tournament-stub-v4" target="_blank">`tournament-stub-v4`</a>
/// ///
/// Note: this struct is automatically generated. /// Note: this struct is automatically generated.
#[repr(transparent)]
pub struct TournamentStubV4<'a> { pub struct TournamentStubV4<'a> {
base: &'a RiotApi, base: &'a RiotApi,
} }
@ -1363,8 +1426,9 @@ impl<'a> TournamentStubV4<'a> {
pub fn get_lobby_events_by_code(&self, region: Region, tournament_code: &str) pub fn get_lobby_events_by_code(&self, region: Region, tournament_code: &str)
-> impl Future<Output = Result<tournament_stub_v4::LobbyEventWrapper>> + 'a -> impl Future<Output = Result<tournament_stub_v4::LobbyEventWrapper>> + 'a
{ {
let path_string = format!("/lol/tournament-stub/v4/lobby-events/by-code/{}", tournament_code); #[allow(unused_mut)]
self.base.get::<tournament_stub_v4::LobbyEventWrapper>("tournament-stub-v4.getLobbyEventsByCode", region.into(), path_string, None) let mut request = self.base.request(Method::GET, region.into(), &format!("/lol/tournament-stub/v4/lobby-events/by-code/{}", tournament_code));
self.base.execute::<tournament_stub_v4::LobbyEventWrapper>("tournament-stub-v4.getLobbyEventsByCode", region.into(), request)
} }
} }
@ -1374,6 +1438,7 @@ impl<'a> TournamentStubV4<'a> {
/// <a href="https://developer.riotgames.com/apis#tournament-v4" target="_blank">`tournament-v4`</a> /// <a href="https://developer.riotgames.com/apis#tournament-v4" target="_blank">`tournament-v4`</a>
/// ///
/// Note: this struct is automatically generated. /// Note: this struct is automatically generated.
#[repr(transparent)]
pub struct TournamentV4<'a> { pub struct TournamentV4<'a> {
base: &'a RiotApi, base: &'a RiotApi,
} }
@ -1389,8 +1454,9 @@ impl<'a> TournamentV4<'a> {
pub fn get_tournament_code(&self, region: Region, tournament_code: &str) pub fn get_tournament_code(&self, region: Region, tournament_code: &str)
-> impl Future<Output = Result<tournament_v4::TournamentCode>> + 'a -> impl Future<Output = Result<tournament_v4::TournamentCode>> + 'a
{ {
let path_string = format!("/lol/tournament/v4/codes/{}", tournament_code); #[allow(unused_mut)]
self.base.get::<tournament_v4::TournamentCode>("tournament-v4.getTournamentCode", region.into(), path_string, None) let mut request = self.base.request(Method::GET, region.into(), &format!("/lol/tournament/v4/codes/{}", tournament_code));
self.base.execute::<tournament_v4::TournamentCode>("tournament-v4.getTournamentCode", region.into(), request)
} }
/// Gets a list of lobby events by tournament code. /// Gets a list of lobby events by tournament code.
@ -1404,8 +1470,9 @@ impl<'a> TournamentV4<'a> {
pub fn get_lobby_events_by_code(&self, region: Region, tournament_code: &str) pub fn get_lobby_events_by_code(&self, region: Region, tournament_code: &str)
-> impl Future<Output = Result<tournament_v4::LobbyEventWrapper>> + 'a -> impl Future<Output = Result<tournament_v4::LobbyEventWrapper>> + 'a
{ {
let path_string = format!("/lol/tournament/v4/lobby-events/by-code/{}", tournament_code); #[allow(unused_mut)]
self.base.get::<tournament_v4::LobbyEventWrapper>("tournament-v4.getLobbyEventsByCode", region.into(), path_string, None) let mut request = self.base.request(Method::GET, region.into(), &format!("/lol/tournament/v4/lobby-events/by-code/{}", tournament_code));
self.base.execute::<tournament_v4::LobbyEventWrapper>("tournament-v4.getLobbyEventsByCode", region.into(), request)
} }
} }
@ -1415,6 +1482,7 @@ impl<'a> TournamentV4<'a> {
/// <a href="https://developer.riotgames.com/apis#val-content-v1" target="_blank">`val-content-v1`</a> /// <a href="https://developer.riotgames.com/apis#val-content-v1" target="_blank">`val-content-v1`</a>
/// ///
/// Note: this struct is automatically generated. /// Note: this struct is automatically generated.
#[repr(transparent)]
pub struct ValContentV1<'a> { pub struct ValContentV1<'a> {
base: &'a RiotApi, base: &'a RiotApi,
} }
@ -1430,11 +1498,10 @@ impl<'a> ValContentV1<'a> {
pub fn get_content(&self, region: Region, locale: Option<&str>) pub fn get_content(&self, region: Region, locale: Option<&str>)
-> impl Future<Output = Result<val_content_v1::Content>> + 'a -> impl Future<Output = Result<val_content_v1::Content>> + 'a
{ {
let mut query_params = Serializer::new(String::new()); #[allow(unused_mut)]
if let Some(locale) = locale { query_params.append_pair("locale", locale); }; let mut request = self.base.request(Method::GET, region.into(), "/val/content/v1/contents");
let query_string = query_params.finish(); if let Some(locale) = locale { request = request.query(&[ ("locale", locale) ]); };
let path_string = "/val/content/v1/contents".to_owned(); self.base.execute::<val_content_v1::Content>("val-content-v1.getContent", region.into(), request)
self.base.get::<val_content_v1::Content>("val-content-v1.getContent", region.into(), path_string, Some(query_string))
} }
} }
@ -1444,6 +1511,7 @@ impl<'a> ValContentV1<'a> {
/// <a href="https://developer.riotgames.com/apis#val-match-v1" target="_blank">`val-match-v1`</a> /// <a href="https://developer.riotgames.com/apis#val-match-v1" target="_blank">`val-match-v1`</a>
/// ///
/// Note: this struct is automatically generated. /// Note: this struct is automatically generated.
#[repr(transparent)]
pub struct ValMatchV1<'a> { pub struct ValMatchV1<'a> {
base: &'a RiotApi, base: &'a RiotApi,
} }
@ -1459,8 +1527,9 @@ impl<'a> ValMatchV1<'a> {
pub fn get_match(&self, region: Region, match_id: &str) pub fn get_match(&self, region: Region, match_id: &str)
-> impl Future<Output = Result<Option<val_match_v1::Match>>> + 'a -> impl Future<Output = Result<Option<val_match_v1::Match>>> + 'a
{ {
let path_string = format!("/val/match/v1/matches/{}", match_id); #[allow(unused_mut)]
self.base.get_optional::<val_match_v1::Match>("val-match-v1.getMatch", region.into(), path_string, None) let mut request = self.base.request(Method::GET, region.into(), &format!("/val/match/v1/matches/{}", match_id));
self.base.execute_optional::<val_match_v1::Match>("val-match-v1.getMatch", region.into(), request)
} }
/// Get matchlist for games played by puuid /// Get matchlist for games played by puuid
@ -1474,8 +1543,9 @@ impl<'a> ValMatchV1<'a> {
pub fn get_matchlist(&self, region: Region, puuid: &str) pub fn get_matchlist(&self, region: Region, puuid: &str)
-> impl Future<Output = Result<val_match_v1::Matchlist>> + 'a -> impl Future<Output = Result<val_match_v1::Matchlist>> + 'a
{ {
let path_string = format!("/val/match/v1/matchlists/by-puuid/{}", puuid); #[allow(unused_mut)]
self.base.get::<val_match_v1::Matchlist>("val-match-v1.getMatchlist", region.into(), path_string, None) let mut request = self.base.request(Method::GET, region.into(), &format!("/val/match/v1/matchlists/by-puuid/{}", puuid));
self.base.execute::<val_match_v1::Matchlist>("val-match-v1.getMatchlist", region.into(), request)
} }
/// Get recent matches /// Get recent matches
@ -1491,8 +1561,9 @@ impl<'a> ValMatchV1<'a> {
pub fn get_recent(&self, region: Region, queue: &str) pub fn get_recent(&self, region: Region, queue: &str)
-> impl Future<Output = Result<val_match_v1::RecentMatches>> + 'a -> impl Future<Output = Result<val_match_v1::RecentMatches>> + 'a
{ {
let path_string = format!("/val/match/v1/recent-matches/by-queue/{}", queue); #[allow(unused_mut)]
self.base.get::<val_match_v1::RecentMatches>("val-match-v1.getRecent", region.into(), path_string, None) let mut request = self.base.request(Method::GET, region.into(), &format!("/val/match/v1/recent-matches/by-queue/{}", queue));
self.base.execute::<val_match_v1::RecentMatches>("val-match-v1.getRecent", region.into(), request)
} }
} }
@ -1502,6 +1573,7 @@ impl<'a> ValMatchV1<'a> {
/// <a href="https://developer.riotgames.com/apis#val-ranked-v1" target="_blank">`val-ranked-v1`</a> /// <a href="https://developer.riotgames.com/apis#val-ranked-v1" target="_blank">`val-ranked-v1`</a>
/// ///
/// Note: this struct is automatically generated. /// Note: this struct is automatically generated.
#[repr(transparent)]
pub struct ValRankedV1<'a> { pub struct ValRankedV1<'a> {
base: &'a RiotApi, base: &'a RiotApi,
} }
@ -1519,12 +1591,11 @@ impl<'a> ValRankedV1<'a> {
pub fn get_leaderboard(&self, region: Region, act_id: &str, size: Option<i32>, start_index: Option<i32>) pub fn get_leaderboard(&self, region: Region, act_id: &str, size: Option<i32>, start_index: Option<i32>)
-> impl Future<Output = Result<Option<val_ranked_v1::Leaderboard>>> + 'a -> impl Future<Output = Result<Option<val_ranked_v1::Leaderboard>>> + 'a
{ {
let mut query_params = Serializer::new(String::new()); #[allow(unused_mut)]
if let Some(size) = size { query_params.append_pair("size", &*size.to_string()); }; let mut request = self.base.request(Method::GET, region.into(), &format!("/val/ranked/v1/leaderboards/by-act/{}", act_id));
if let Some(start_index) = start_index { query_params.append_pair("startIndex", &*start_index.to_string()); }; if let Some(size) = size { request = request.query(&[ ("size", size) ]); };
let query_string = query_params.finish(); if let Some(start_index) = start_index { request = request.query(&[ ("startIndex", start_index) ]); };
let path_string = format!("/val/ranked/v1/leaderboards/by-act/{}", act_id); self.base.execute_optional::<val_ranked_v1::Leaderboard>("val-ranked-v1.getLeaderboard", region.into(), request)
self.base.get_optional::<val_ranked_v1::Leaderboard>("val-ranked-v1.getLeaderboard", region.into(), path_string, Some(query_string))
} }
} }
@ -1534,6 +1605,7 @@ impl<'a> ValRankedV1<'a> {
/// <a href="https://developer.riotgames.com/apis#val-status-v1" target="_blank">`val-status-v1`</a> /// <a href="https://developer.riotgames.com/apis#val-status-v1" target="_blank">`val-status-v1`</a>
/// ///
/// Note: this struct is automatically generated. /// Note: this struct is automatically generated.
#[repr(transparent)]
pub struct ValStatusV1<'a> { pub struct ValStatusV1<'a> {
base: &'a RiotApi, base: &'a RiotApi,
} }
@ -1548,8 +1620,9 @@ impl<'a> ValStatusV1<'a> {
pub fn get_platform_data(&self, region: Region) pub fn get_platform_data(&self, region: Region)
-> impl Future<Output = Result<val_status_v1::PlatformData>> + 'a -> impl Future<Output = Result<val_status_v1::PlatformData>> + 'a
{ {
let path_string = "/val/status/v1/platform-data".to_owned(); #[allow(unused_mut)]
self.base.get::<val_status_v1::PlatformData>("val-status-v1.getPlatformData", region.into(), path_string, None) let mut request = self.base.request(Method::GET, region.into(), "/val/status/v1/platform-data");
self.base.execute::<val_status_v1::PlatformData>("val-status-v1.getPlatformData", region.into(), request)
} }
} }

View File

@ -2,7 +2,7 @@ use std::future::Future;
use std::sync::Arc; use std::sync::Arc;
use log; use log;
use reqwest::{Client, StatusCode, Request}; use reqwest::{ StatusCode, RequestBuilder };
use crate::Result; use crate::Result;
use crate::ResponseInfo; use crate::ResponseInfo;
@ -34,9 +34,9 @@ impl RegionalRequester {
} }
} }
pub fn execute_raw<'a>(self: Arc<Self>, pub fn execute<'a>(self: Arc<Self>,
config: &'a RiotApiConfig, client: &'a Client, config: &'a RiotApiConfig,
method_id: &'static str, request: Request) method_id: &'static str, request: RequestBuilder)
-> impl Future<Output = Result<ResponseInfo>> + 'a -> impl Future<Output = Result<ResponseInfo>> + 'a
{ {
async move { async move {
@ -52,7 +52,7 @@ impl RegionalRequester {
// Send request. // Send request.
let request_clone = request.try_clone().expect("Failed to clone request."); let request_clone = request.try_clone().expect("Failed to clone request.");
let response = client.execute(request_clone).await let response = request_clone.send().await
.map_err(|e| RiotApiError::new(e, retries, None, None))?; .map_err(|e| RiotApiError::new(e, retries, None, None))?;
// Maybe update rate limits (based on response headers). // Maybe update rate limits (based on response headers).

View File

@ -2,7 +2,7 @@ use std::future::Future;
use std::sync::Arc; use std::sync::Arc;
use log; use log;
use reqwest::{Client, Request, Method, Url}; use reqwest::{ Client, RequestBuilder, Method, Url };
use crate::Result; use crate::Result;
use crate::ResponseInfo; use crate::ResponseInfo;
@ -63,7 +63,7 @@ impl RiotApi {
/// `api_key` should be a Riot Games API key from /// `api_key` should be a Riot Games API key from
/// [https://developer.riotgames.com/](https://developer.riotgames.com/), /// [https://developer.riotgames.com/](https://developer.riotgames.com/),
/// and should look like `"RGAPI-01234567-89ab-cdef-0123-456789abcdef"`. /// and should look like `"RGAPI-01234567-89ab-cdef-0123-456789abcdef"`.
pub fn with_key<T: AsRef<[u8]>>(api_key: T) -> Self { pub fn with_key(api_key: impl AsRef<[u8]>) -> Self {
Self::with_config(RiotApiConfig::with_key(api_key)) Self::with_config(RiotApiConfig::with_key(api_key))
} }
@ -140,16 +140,17 @@ impl RiotApi {
url.set_path(&*path); url.set_path(&*path);
url.set_query(query.as_deref()); url.set_query(query.as_deref());
let request = Request::new(Method::GET, url); let request = self.client.get(url);
self.execute_raw(method_id, region_platform, request) self.execute_raw(method_id, region_platform, request)
} }
pub fn request(&self, method: Method, region_platform: &str, path: &str) -> RequestBuilder {
let base_url_platform = self.config.base_url.replace("{}", region_platform);
self.client.request(method, format!("{}/{}", base_url_platform, path))
}
pub async fn execute_optional<'a, T: serde::de::DeserializeOwned + 'a>(&'a self, pub async fn execute_optional<'a, T: serde::de::DeserializeOwned + 'a>(&'a self,
method_id: &'static str, region_platform: &'static str, request: Request) method_id: &'static str, region_platform: &'static str, request: RequestBuilder)
-> Result<Option<T>> -> Result<Option<T>>
{ {
let rinfo = self.execute_raw(method_id, region_platform, request).await?; let rinfo = self.execute_raw(method_id, region_platform, request).await?;
@ -163,7 +164,7 @@ impl RiotApi {
} }
pub async fn execute<'a, T: serde::de::DeserializeOwned + 'a>(&'a self, pub async fn execute<'a, T: serde::de::DeserializeOwned + 'a>(&'a self,
method_id: &'static str, region_platform: &'static str, request: Request) method_id: &'static str, region_platform: &'static str, request: RequestBuilder)
-> Result<T> -> Result<T>
{ {
let rinfo = self.execute_raw(method_id, region_platform, request).await?; let rinfo = self.execute_raw(method_id, region_platform, request).await?;
@ -173,11 +174,11 @@ impl RiotApi {
value.map_err(|e| RiotApiError::new(e, retries, None, Some(status))) value.map_err(|e| RiotApiError::new(e, retries, None, Some(status)))
} }
pub fn execute_raw(&self, method_id: &'static str, region_platform: &'static str, request: Request) pub fn execute_raw(&self, method_id: &'static str, region_platform: &'static str, request: RequestBuilder)
-> impl Future<Output = Result<ResponseInfo>> + '_ -> impl Future<Output = Result<ResponseInfo>> + '_
{ {
self.regional_requester(region_platform) self.regional_requester(region_platform)
.execute_raw(&self.config, &self.client, method_id, request) .execute(&self.config, method_id, request)
} }
/// Get or create the RegionalRequester for the given region. /// Get or create the RegionalRequester for the given region.

View File

@ -107,47 +107,30 @@ function formatJsonProperty(name) {
return `#[serde(rename = "${name}")]`; return `#[serde(rename = "${name}")]`;
} }
function formatQueryParamStringify(name, prop, useOwned = false) {
const own = useOwned ? '' : '&*';
if (prop['x-enum']) {
switch (prop.type) {
case 'integer':
return `${own}Into::<${enumTypeLookup[prop['x-enum']]}>::into(*${name}).to_string()`;
default: throw new Error(`Enum not supported: ${JSON.stringify(prop)}.`)
}
}
switch (prop.type) {
case 'array': throw new Error(`Cannot formart array: ${JSON.stringify(prop)}.`);
case 'boolean': return `${name} ? "true" : "false"`;
case 'string': return name;
default: return `${own}${name}.to_string()`;
}
}
function formatAddQueryParam(param) { function formatAddQueryParam(param) {
let k = `"${param.name}"`; let k = `"${param.name}"`;
let name = changeCase.snakeCase(param.name); let name = changeCase.snakeCase(param.name);
let nc = param.required ? '' : `if let Some(${name}) = ${name} `; let nc = param.required ? '' : `if let Some(${name}) = ${name} `;
let prop = param.schema; let prop = param.schema;
switch (prop.type) { switch (prop.type) {
case 'array': return `${nc}{ query_params.extend_pairs(${name}.iter()` case 'array': return `${nc}{ request = request.query(&*${name}.iter()`
+ `.map(|w| (${k}, ${formatQueryParamStringify("w", prop.items, true)}))); }`; + `.map(|w| ( ${k}, w )).collect::<Vec<_>>()); }`;
case 'object': throw 'unsupported'; case 'object': throw 'unsupported';
default: default:
return `${nc}{ query_params.append_pair(${k}, ${formatQueryParamStringify(name, prop)}); }`; return `${nc}{ request = request.query(&[ (${k}, ${name}) ]); }`;
} }
} }
function formatRouteArgument(route, pathParams = []) { function formatRouteArgument(route, pathParams = []) {
if (!pathParams.length) if (!pathParams.length)
return `"${route}".to_owned()`; return `"${route}"`;
route = route.replace(/\{\S+?\}/g, '{}'); route = route.replace(/\{\S+?\}/g, '{}');
const args = pathParams const args = pathParams
.map(({name}) => name) .map(({name}) => name)
.map(changeCase.snakeCase) .map(changeCase.snakeCase)
.join(', '); .join(', ');
return `format!("${route}", ${args})`; return `&format!("${route}", ${args})`;
} }
module.exports = { module.exports = {

View File

@ -13,7 +13,7 @@ use crate::models::*;
use std::future::Future; use std::future::Future;
use std::vec::Vec; use std::vec::Vec;
use url::form_urlencoded::Serializer; use reqwest::Method;
use crate::Result; use crate::Result;
use crate::consts::Region; use crate::consts::Region;
@ -57,6 +57,7 @@ impl RiotApi {
/// <a href="https://developer.riotgames.com/apis#{{= endpointName }}" target="_blank">`{{= endpointName }}`</a> /// <a href="https://developer.riotgames.com/apis#{{= endpointName }}" target="_blank">`{{= endpointName }}`</a>
/// ///
/// Note: this struct is automatically generated. /// Note: this struct is automatically generated.
#[repr(transparent)]
pub struct {{= endpoint }}<'a> { pub struct {{= endpoint }}<'a> {
base: &'a RiotApi, base: &'a RiotApi,
} }
@ -90,7 +91,7 @@ impl<'a> {{= endpoint }}<'a> {
let makeParamCode = ''; let makeParamCode = '';
let allParams = get.parameters; let allParams = get.parameters;
let queryParams = []; let queryParams = [];
let routeArgument = dotUtils.formatRouteArgument(route); let routeArgument;
if (allParams && allParams.length) if (allParams && allParams.length)
{ {
let pathParams = allParams.filter(p => 'path' === p.in) let pathParams = allParams.filter(p => 'path' === p.in)
@ -115,6 +116,10 @@ impl<'a> {{= endpoint }}<'a> {
routeArgument = dotUtils.formatRouteArgument(route, pathParams); routeArgument = dotUtils.formatRouteArgument(route, pathParams);
} }
else
{
routeArgument = dotUtils.formatRouteArgument(route);
}
for (var descLine of descArr) for (var descLine of descArr)
{ {
}} }}
@ -142,8 +147,8 @@ impl<'a> {{= endpoint }}<'a> {
pub fn {{= method }}(&self, region: Region{{= argBuilder.join('') }}) pub fn {{= method }}(&self, region: Region{{= argBuilder.join('') }})
-> impl Future<Output = Result<{{= returnType }}>> + 'a -> impl Future<Output = Result<{{= returnType }}>> + 'a
{ {
{{? queryParams.length }} #[allow(unused_mut)]
let mut query_params = Serializer::new(String::new()); let mut request = self.base.request(Method::GET, region.into(), {{= routeArgument }});
{{ {{
for (let queryParam of queryParams) for (let queryParam of queryParams)
{ {
@ -152,10 +157,7 @@ impl<'a> {{= endpoint }}<'a> {
{{ {{
} }
}} }}
let query_string = query_params.finish(); self.base.execute{{= returnOptional ? '_optional' : '' }}::<{{= parseType }}>("{{= operationId }}", region.into(), request)
{{?}}
let path_string = {{= routeArgument }};
self.base.get{{= returnOptional ? '_optional' : '' }}::<{{= parseType }}>("{{= operationId }}", region.into(), path_string, {{= queryParams.length ? 'Some(query_string)' : 'None' }})
} }
{{ {{