Update for account-v1 endpoint, fix for missing match-v4.PlayerDto.summonerId on bot games

Also adds test with bot game.
pull/23/head
Mingwei Samuel 2020-07-26 16:33:03 -07:00
parent bdba6bb70c
commit 1a88ae6365
5 changed files with 112 additions and 4 deletions

View File

@ -310,6 +310,8 @@ pub enum Champion {
#[strum(to_string="Xin Zhao", serialize="XinZhao")] XinZhao = 5,
/// Yasuo (`Yasuo`, 157).
#[strum(to_string="Yasuo", serialize="Yasuo")] Yasuo = 157,
/// Yone (`Yone`, 777).
#[strum(to_string="Yone", serialize="Yone")] Yone = 777,
/// Yorick (`Yorick`, 83).
#[strum(to_string="Yorick", serialize="Yorick")] Yorick = 83,
/// Yuumi (`Yuumi`, 350).
@ -495,6 +497,7 @@ impl Champion {
Self::Xerath => "Xerath",
Self::XinZhao => "XinZhao",
Self::Yasuo => "Yasuo",
Self::Yone => "Yone",
Self::Yorick => "Yorick",
Self::Yuumi => "Yuumi",
Self::Zac => "Zac",

View File

@ -7,7 +7,7 @@
///////////////////////////////////////////////
// http://www.mingweisamuel.com/riotapi-schema/tool/
// Version af29e140a03aabbd77664b926746eecaae877d2b
// Version d1d3a7a4176fd7b1ca98b43811dbe6ac3951b9b6
//! Automatically generated endpoint handles.
@ -23,6 +23,15 @@ use crate::consts::Region;
use crate::riot_api::RiotApi;
impl RiotApi {
/// Returns a handle for accessing [AccountV1](crate::endpoints::AccountV1) endpoints.
/// # Riot Developer API Reference
/// <a href="https://developer.riotgames.com/apis#account-v1" target="_blank">`account-v1`</a>
///
/// Note: this method is automatically generated.
#[inline]
pub fn account_v1(&self) -> AccountV1 {
AccountV1 { base: self }
}
/// Returns a handle for accessing [ChampionMasteryV4](crate::endpoints::ChampionMasteryV4) endpoints.
/// # Riot Developer API Reference
/// <a href="https://developer.riotgames.com/apis#champion-mastery-v4" target="_blank">`champion-mastery-v4`</a>
@ -187,6 +196,64 @@ impl RiotApi {
}
}
/// AccountV1 endpoints handle, accessed by calling [`account_v1()`](crate::RiotApi::account_v1) on a [`RiotApi`](crate::RiotApi) instance.
/// # Riot Developer API Reference
/// <a href="https://developer.riotgames.com/apis#account-v1" target="_blank">`account-v1`</a>
///
/// Note: this struct is automatically generated.
pub struct AccountV1<'a> {
base: &'a RiotApi,
}
impl<'a> AccountV1<'a> {
/// Get account by puuid
/// # Parameters
/// * `region` - Region to query.
/// * `puuid`
/// # Riot Developer API Reference
/// <a href="https://developer.riotgames.com/api-methods/#account-v1/GET_getByPuuid" target="_blank">`account-v1.getByPuuid`</a>
///
/// Note: this method is automatically generated.
pub fn get_by_puuid(&self, region: Region, puuid: &str)
-> impl Future<Output = Result<account_v1::Account>> + 'a
{
let path_string = format!("/riot/account/v1/accounts/by-puuid/{}", puuid);
self.base.get::<account_v1::Account>("account-v1.getByPuuid", region.into(), path_string, None)
}
/// Get account by riot id
/// # Parameters
/// * `region` - Region to query.
/// * `tagLine`
/// * `gameName`
/// # Riot Developer API Reference
/// <a href="https://developer.riotgames.com/api-methods/#account-v1/GET_getByRiotId" target="_blank">`account-v1.getByRiotId`</a>
///
/// Note: this method is automatically generated.
pub fn get_by_riot_id(&self, region: Region, game_name: &str, tag_line: &str)
-> impl Future<Output = Result<Option<account_v1::Account>>> + 'a
{
let path_string = format!("/riot/account/v1/accounts/by-riot-id/{}/{}", game_name, tag_line);
self.base.get_optional::<account_v1::Account>("account-v1.getByRiotId", region.into(), path_string, None)
}
/// Get active shard for a player
/// # Parameters
/// * `region` - Region to query.
/// * `puuid`
/// * `game`
/// # Riot Developer API Reference
/// <a href="https://developer.riotgames.com/api-methods/#account-v1/GET_getActiveShard" target="_blank">`account-v1.getActiveShard`</a>
///
/// Note: this method is automatically generated.
pub fn get_active_shard(&self, region: Region, game: &str, puuid: &str)
-> impl Future<Output = Result<Option<account_v1::ActiveShard>>> + 'a
{
let path_string = format!("/riot/account/v1/active-shards/by-game/{}/by-puuid/{}", game, puuid);
self.base.get_optional::<account_v1::ActiveShard>("account-v1.getActiveShard", region.into(), path_string, None)
}
}
/// ChampionMasteryV4 endpoints handle, accessed by calling [`champion_mastery_v4()`](crate::RiotApi::champion_mastery_v4) on a [`RiotApi`](crate::RiotApi) instance.
/// # Riot Developer API Reference
/// <a href="https://developer.riotgames.com/apis#champion-mastery-v4" target="_blank">`champion-mastery-v4`</a>

View File

@ -7,7 +7,7 @@
///////////////////////////////////////////////
// http://www.mingweisamuel.com/riotapi-schema/tool/
// Version af29e140a03aabbd77664b926746eecaae877d2b
// Version d1d3a7a4176fd7b1ca98b43811dbe6ac3951b9b6
//! Metadata about the Riot API and Riven.
//!
@ -20,6 +20,9 @@ use lazy_static::lazy_static;
lazy_static! {
pub static ref ENDPOINT_PATH_METHODID: HashMap<&'static str, &'static str> = {
let mut map = HashMap::new();
map.insert("/riot/account/v1/accounts/by-puuid/{puuid}", "account-v1.getByPuuid");
map.insert("/riot/account/v1/accounts/by-riot-id/{gameName}/{tagLine}", "account-v1.getByRiotId");
map.insert("/riot/account/v1/active-shards/by-game/{game}/by-puuid/{puuid}", "account-v1.getActiveShard");
map.insert("/lol/champion-mastery/v4/champion-masteries/by-summoner/{encryptedSummonerId}", "champion-mastery-v4.getAllChampionMasteries");
map.insert("/lol/champion-mastery/v4/champion-masteries/by-summoner/{encryptedSummonerId}/by-champion/{championId}", "champion-mastery-v4.getChampionMastery");
map.insert("/lol/champion-mastery/v4/scores/by-summoner/{encryptedSummonerId}", "champion-mastery-v4.getChampionMasteryScore");

View File

@ -7,7 +7,7 @@
///////////////////////////////////////////////
// http://www.mingweisamuel.com/riotapi-schema/tool/
// Version af29e140a03aabbd77664b926746eecaae877d2b
// Version d1d3a7a4176fd7b1ca98b43811dbe6ac3951b9b6
//! Data transfer structs.
//!
@ -16,6 +16,35 @@
//!
//! Note: these modules are automatically generated.
/// Data structs used by [`AccountV1`](crate::endpoints::AccountV1).
///
/// Note: this module is automatically generated.
#[allow(dead_code)]
pub mod account_v1 {
/// Account data object.
#[derive(Debug)]
#[derive(serde::Serialize, serde::Deserialize)]
pub struct Account {
#[serde(rename = "puuid")]
pub puuid: String,
#[serde(rename = "gameName")]
pub game_name: String,
#[serde(rename = "tagLine")]
pub tag_line: String,
}
/// ActiveShard data object.
#[derive(Debug)]
#[derive(serde::Serialize, serde::Deserialize)]
pub struct ActiveShard {
#[serde(rename = "puuid")]
pub puuid: String,
#[serde(rename = "game")]
pub game: String,
#[serde(rename = "activeShard")]
pub active_shard: String,
}
}
/// Data structs used by [`ChampionMasteryV4`](crate::endpoints::ChampionMasteryV4).
///
/// Note: this module is automatically generated.
@ -494,7 +523,7 @@ pub mod match_v4 {
pub summoner_name: String,
/// Player's summonerId (Encrypted)
#[serde(rename = "summonerId")]
pub summoner_id: String,
pub summoner_id: Option<String>,
/// Player's original platformId.
#[serde(rename = "platformId")]
pub platform_id: String,

View File

@ -51,6 +51,12 @@ async_tests!{
rassert!(!m.participants.is_empty(), "Match should have participants.");
Ok(())
},
match_get_bots: async {
let p = RIOT_API.match_v4().get_match(Region::NA, 3251803350);
let m = p.await.map_err(|e| e.to_string())?.ok_or("Match not found.".to_owned())?;
rassert!(!m.participants.is_empty(), "Match should have participants.");
Ok(())
},
match_gettimeline: async {
let p = RIOT_API.match_v4().get_match_timeline(Region::NA, 3190191338);
let m = p.await.map_err(|e| e.to_string())?.ok_or("Match timeline not found.".to_owned())?;