Regen, update tests

- New `tft-league-v1.getTopRatedLadder` endpoint. #24
- Updated optionals on `tft-league-v1.LeagueEntryDTO`. #25
- New `RANKED_TFT_TURBO` `QueueType`. #25
- Test for `tft-league-v1.getLeagueEntriesForSummoner` added. #25
- Fixed whitespace on `잘 못` doc test (werid).
This commit is contained in:
Mingwei Samuel 2021-05-09 09:46:10 -07:00
parent a97bceb827
commit 0f400ab43a
7 changed files with 199 additions and 25 deletions

View file

@ -13,8 +13,9 @@ pub enum QueueType {
// League of Legends, Twisted Treeline (3v3), Flex Queue.
RANKED_FLEX_TT,
// Ranked Teamfight Tactics.
#[deprecated(note = "Teamfight Tactics ranks should be acquired using `TftLeagueV1::get_league_entries`.")]
RANKED_TFT,
// Ranked Teamfight Tactics, Turbo gamemode.
RANKED_TFT_TURBO,
}
serde_string!(QueueType);

View file

@ -7,7 +7,7 @@
///////////////////////////////////////////////
// http://www.mingweisamuel.com/riotapi-schema/tool/
// Version 7bea623175b27bdc53a046c4e0d09b0f0d638aa7
// Version d958cb912f35a3eb9091337de469633e228a7aa2
//! Automatically generated endpoint handles.
@ -131,6 +131,15 @@ impl RiotApi {
pub fn match_v4(&self) -> MatchV4 {
MatchV4 { base: self }
}
/// Returns a handle for accessing [MatchV5](crate::endpoints::MatchV5) endpoints.
/// # Riot Developer API Reference
/// <a href="https://developer.riotgames.com/apis#match-v5" target="_blank">`match-v5`</a>
///
/// Note: this method is automatically generated.
#[inline]
pub fn match_v5(&self) -> MatchV5 {
MatchV5 { base: self }
}
/// Returns a handle for accessing [SpectatorV4](crate::endpoints::SpectatorV4) endpoints.
/// # Riot Developer API Reference
/// <a href="https://developer.riotgames.com/apis#spectator-v4" target="_blank">`spectator-v4`</a>
@ -284,8 +293,8 @@ impl<'a> AccountV1<'a> {
/// Get active shard for a player
/// # Parameters
/// * `region` - Region to query.
/// * `puuid`
/// * `game`
/// * `puuid`
/// # Riot Developer API Reference
/// <a href="https://developer.riotgames.com/api-methods/#account-v1/GET_getActiveShard" target="_blank">`account-v1.getActiveShard`</a>
///
@ -483,7 +492,7 @@ impl<'a> LeagueExpV4<'a> {
/// * `queue` - Note that the queue value must be a valid ranked queue.
/// * `tier`
/// * `division`
/// * `page` (optional) - Starts with page 1.
/// * `page` (optional) - Defaults to 1. Starts with page 1.
/// # Riot Developer API Reference
/// <a href="https://developer.riotgames.com/api-methods/#league-exp-v4/GET_getLeagueEntries" target="_blank">`league-exp-v4.getLeagueEntries`</a>
///
@ -545,7 +554,7 @@ impl<'a> LeagueV4<'a> {
/// * `division`
/// * `tier`
/// * `queue` - Note that the queue value must be a valid ranked queue.
/// * `page` (optional) - Starts with page 1.
/// * `page` (optional) - Defaults to 1. Starts with page 1.
/// # Riot Developer API Reference
/// <a href="https://developer.riotgames.com/api-methods/#league-v4/GET_getLeagueEntries" target="_blank">`league-v4.getLeagueEntries`</a>
///
@ -861,6 +870,68 @@ impl<'a> MatchV4<'a> {
}
/// MatchV5 endpoints handle, accessed by calling [`match_v5()`](crate::RiotApi::match_v5) on a [`RiotApi`](crate::RiotApi) instance.
/// # Riot Developer API Reference
/// <a href="https://developer.riotgames.com/apis#match-v5" target="_blank">`match-v5`</a>
///
/// Note: this struct is automatically generated.
pub struct MatchV5<'a> {
base: &'a RiotApi,
}
impl<'a> MatchV5<'a> {
/// Get a list of match ids by puuid
/// # Parameters
/// * `region` - Region to query.
/// * `puuid`
/// * `start` (optional) - Defaults to 0. Start index.
/// * `count` (optional) - Defaults to 20. Valid values: 0 to 100. Match id count.
/// # Riot Developer API Reference
/// <a href="https://developer.riotgames.com/api-methods/#match-v5/GET_getMatchIdsByPUUID" target="_blank">`match-v5.getMatchIdsByPUUID`</a>
///
/// Note: this method is automatically generated.
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
{
let mut query_params = Serializer::new(String::new());
if let Some(count) = count { query_params.append_pair("count", &*count.to_string()); };
if let Some(start) = start { query_params.append_pair("start", &*start.to_string()); };
let query_string = query_params.finish();
let path_string = format!("/lol/match/v5/matches/by-puuid/{}/ids", puuid);
self.base.get::<Vec<String>>("match-v5.getMatchIdsByPUUID", region.into(), path_string, Some(query_string))
}
/// Get a match by match id
/// # Parameters
/// * `region` - Region to query.
/// * `matchId`
/// # Riot Developer API Reference
/// <a href="https://developer.riotgames.com/api-methods/#match-v5/GET_getMatch" target="_blank">`match-v5.getMatch`</a>
///
/// Note: this method is automatically generated.
pub fn get_match(&self, region: Region, match_id: &str)
-> impl Future<Output = Result<match_v5::Match>> + 'a
{
let path_string = format!("/lol/match/v5/matches/{}", match_id);
self.base.get::<match_v5::Match>("match-v5.getMatch", region.into(), path_string, None)
}
/// Get a match timeline by match id
/// # Parameters
/// * `region` - Region to query.
/// * `matchId`
/// # Riot Developer API Reference
/// <a href="https://developer.riotgames.com/api-methods/#match-v5/GET_getTimeline" target="_blank">`match-v5.getTimeline`</a>
///
/// Note: this method is automatically generated.
pub fn get_timeline(&self, region: Region, match_id: &str)
-> impl Future<Output = Result<match_v5::MatchTimeline>> + 'a
{
let path_string = format!("/lol/match/v5/matches/{}/timeline", match_id);
self.base.get::<match_v5::MatchTimeline>("match-v5.getTimeline", region.into(), path_string, None)
}
}
/// SpectatorV4 endpoints handle, accessed by calling [`spectator_v4()`](crate::RiotApi::spectator_v4) on a [`RiotApi`](crate::RiotApi) instance.
/// # Riot Developer API Reference
/// <a href="https://developer.riotgames.com/apis#spectator-v4" target="_blank">`spectator-v4`</a>
@ -998,15 +1069,15 @@ impl<'a> TftLeagueV1<'a> {
/// Get league entries for a given summoner ID.
/// # Parameters
/// * `region` - Region to query.
/// * `encryptedSummonerId`
/// * `summonerId`
/// # Riot Developer API Reference
/// <a href="https://developer.riotgames.com/api-methods/#tft-league-v1/GET_getLeagueEntriesForSummoner" target="_blank">`tft-league-v1.getLeagueEntriesForSummoner`</a>
///
/// Note: this method is automatically generated.
pub fn get_league_entries_for_summoner(&self, region: Region, encrypted_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
{
let path_string = format!("/tft/league/v1/entries/by-summoner/{}", encrypted_summoner_id);
let path_string = format!("/tft/league/v1/entries/by-summoner/{}", summoner_id);
self.base.get::<Vec<tft_league_v1::LeagueEntry>>("tft-league-v1.getLeagueEntriesForSummoner", region.into(), path_string, None)
}
@ -1015,7 +1086,7 @@ impl<'a> TftLeagueV1<'a> {
/// * `region` - Region to query.
/// * `tier`
/// * `division`
/// * `page` (optional) - Starts with page 1.
/// * `page` (optional) - Defaults to 1. Starts with page 1.
/// # Riot Developer API Reference
/// <a href="https://developer.riotgames.com/api-methods/#tft-league-v1/GET_getLeagueEntries" target="_blank">`tft-league-v1.getLeagueEntries`</a>
///
@ -1073,6 +1144,21 @@ impl<'a> TftLeagueV1<'a> {
self.base.get::<tft_league_v1::LeagueList>("tft-league-v1.getMasterLeague", region.into(), path_string, None)
}
/// Get the top rated ladder for given queue
/// # Parameters
/// * `region` - Region to query.
/// * `queue`
/// # Riot Developer API Reference
/// <a href="https://developer.riotgames.com/api-methods/#tft-league-v1/GET_getTopRatedLadder" target="_blank">`tft-league-v1.getTopRatedLadder`</a>
///
/// Note: this method is automatically generated.
pub fn get_top_rated_ladder(&self, region: Region, queue: &str)
-> impl Future<Output = Result<Vec<tft_league_v1::TopRatedLadderEntry>>> + 'a
{
let path_string = format!("/tft/league/v1/rated-ladders/{}/top", queue);
self.base.get::<Vec<tft_league_v1::TopRatedLadderEntry>>("tft-league-v1.getTopRatedLadder", region.into(), path_string, None)
}
}
/// TftMatchV1 endpoints handle, accessed by calling [`tft_match_v1()`](crate::RiotApi::tft_match_v1) on a [`RiotApi`](crate::RiotApi) instance.
@ -1088,7 +1174,7 @@ impl<'a> TftMatchV1<'a> {
/// # Parameters
/// * `region` - Region to query.
/// * `puuid`
/// * `count` (optional)
/// * `count` (optional) - Defaults to 20.
/// # Riot Developer API Reference
/// <a href="https://developer.riotgames.com/api-methods/#tft-match-v1/GET_getMatchIdsByPUUID" target="_blank">`tft-match-v1.getMatchIdsByPUUID`</a>
///
@ -1384,8 +1470,8 @@ impl<'a> ValRankedV1<'a> {
/// # Parameters
/// * `region` - Region to query.
/// * `actId` - Act ids can be found using the val-content API.
/// * `size` (optional)
/// * `startIndex` (optional)
/// * `size` (optional) - Defaults to 200. Valid values: 1 to 200.
/// * `startIndex` (optional) - Defaults to 0.
/// # Riot Developer API Reference
/// <a href="https://developer.riotgames.com/api-methods/#val-ranked-v1/GET_getLeaderboard" target="_blank">`val-ranked-v1.getLeaderboard`</a>
///

View file

@ -7,7 +7,7 @@
///////////////////////////////////////////////
// http://www.mingweisamuel.com/riotapi-schema/tool/
// Version 7bea623175b27bdc53a046c4e0d09b0f0d638aa7
// Version d958cb912f35a3eb9091337de469633e228a7aa2
//! Metadata about the Riot API and Riven.
//!
@ -50,6 +50,9 @@ lazy_static! {
map.insert("/lol/match/v4/matches/{matchId}/by-tournament-code/{tournamentCode}", "match-v4.getMatchByTournamentCode");
map.insert("/lol/match/v4/matchlists/by-account/{encryptedAccountId}", "match-v4.getMatchlist");
map.insert("/lol/match/v4/timelines/by-match/{matchId}", "match-v4.getMatchTimeline");
map.insert("/lol/match/v5/matches/by-puuid/{puuid}/ids", "match-v5.getMatchIdsByPUUID");
map.insert("/lol/match/v5/matches/{matchId}", "match-v5.getMatch");
map.insert("/lol/match/v5/matches/{matchId}/timeline", "match-v5.getTimeline");
map.insert("/lol/spectator/v4/active-games/by-summoner/{encryptedSummonerId}", "spectator-v4.getCurrentGameInfoBySummoner");
map.insert("/lol/spectator/v4/featured-games", "spectator-v4.getFeaturedGames");
map.insert("/lol/summoner/v4/summoners/by-account/{encryptedAccountId}", "summoner-v4.getByAccountId");
@ -57,11 +60,12 @@ lazy_static! {
map.insert("/lol/summoner/v4/summoners/by-puuid/{encryptedPUUID}", "summoner-v4.getByPUUID");
map.insert("/lol/summoner/v4/summoners/{encryptedSummonerId}", "summoner-v4.getBySummonerId");
map.insert("/tft/league/v1/challenger", "tft-league-v1.getChallengerLeague");
map.insert("/tft/league/v1/entries/by-summoner/{encryptedSummonerId}", "tft-league-v1.getLeagueEntriesForSummoner");
map.insert("/tft/league/v1/entries/by-summoner/{summonerId}", "tft-league-v1.getLeagueEntriesForSummoner");
map.insert("/tft/league/v1/entries/{tier}/{division}", "tft-league-v1.getLeagueEntries");
map.insert("/tft/league/v1/grandmaster", "tft-league-v1.getGrandmasterLeague");
map.insert("/tft/league/v1/leagues/{leagueId}", "tft-league-v1.getLeagueById");
map.insert("/tft/league/v1/master", "tft-league-v1.getMasterLeague");
map.insert("/tft/league/v1/rated-ladders/{queue}/top", "tft-league-v1.getTopRatedLadder");
map.insert("/tft/match/v1/matches/by-puuid/{puuid}/ids", "tft-match-v1.getMatchIdsByPUUID");
map.insert("/tft/match/v1/matches/{matchId}", "tft-match-v1.getMatch");
map.insert("/tft/summoner/v1/summoners/by-account/{encryptedAccountId}", "tft-summoner-v1.getByAccountId");

View file

@ -7,7 +7,7 @@
///////////////////////////////////////////////
// http://www.mingweisamuel.com/riotapi-schema/tool/
// Version 7bea623175b27bdc53a046c4e0d09b0f0d638aa7
// Version d958cb912f35a3eb9091337de469633e228a7aa2
//! Data transfer structs.
//!
@ -202,6 +202,7 @@ pub mod league_exp_v4 {
pub queue_type: crate::consts::QueueType,
#[serde(rename = "tier")]
pub tier: crate::consts::Tier,
/// The player's division within a tier.
#[serde(rename = "rank")]
pub rank: crate::consts::Division,
#[serde(rename = "leaguePoints")]
@ -316,6 +317,7 @@ pub mod league_v4 {
pub queue_type: crate::consts::QueueType,
#[serde(rename = "tier")]
pub tier: crate::consts::Tier,
/// The player's division within a tier.
#[serde(rename = "rank")]
pub rank: crate::consts::Division,
#[serde(rename = "leaguePoints")]
@ -1309,6 +1311,31 @@ pub mod match_v4 {
}
}
/// Data structs used by [`MatchV5`](crate::endpoints::MatchV5).
///
/// Note: this module is automatically generated.
#[allow(dead_code)]
pub mod match_v5 {
/// Match data object.
/// # Description
/// UNKNOWN TYPE.
///
/// Note: This struct is automatically generated
#[derive(Debug)]
#[derive(serde::Serialize, serde::Deserialize)]
pub struct Match {
}
/// MatchTimeline data object.
/// # Description
/// UNKNOWN TYPE.
///
/// Note: This struct is automatically generated
#[derive(Debug)]
#[derive(serde::Serialize, serde::Deserialize)]
pub struct MatchTimeline {
}
}
/// Data structs used by [`SpectatorV4`](crate::endpoints::SpectatorV4).
///
/// Note: this module is automatically generated.
@ -1617,8 +1644,9 @@ pub mod tft_league_v1 {
#[derive(Debug)]
#[derive(serde::Serialize, serde::Deserialize)]
pub struct LeagueEntry {
/// Not included for the RANKED_TFT_TURBO queueType.
#[serde(rename = "leagueId")]
pub league_id: String,
pub league_id: Option<String>,
/// Player's encrypted summonerId.
#[serde(rename = "summonerId")]
pub summoner_id: String,
@ -1626,29 +1654,63 @@ pub mod tft_league_v1 {
pub summoner_name: String,
#[serde(rename = "queueType")]
pub queue_type: crate::consts::QueueType,
/// Only included for the RANKED_TFT_TURBO queueType.<br>
/// (Legal values: ORANGE, PURPLE, BLUE, GREEN, GRAY)
#[serde(rename = "ratedTier")]
pub rated_tier: Option<String>,
/// Only included for the RANKED_TFT_TURBO queueType.
#[serde(rename = "ratedRating")]
pub rated_rating: Option<i32>,
/// Not included for the RANKED_TFT_TURBO queueType.
#[serde(rename = "tier")]
pub tier: crate::consts::Tier,
pub tier: Option<crate::consts::Tier>,
/// A player's division within a tier. Not included for the RANKED_TFT_TURBO queueType.
#[serde(rename = "rank")]
pub rank: crate::consts::Division,
pub rank: Option<crate::consts::Division>,
/// Not included for the RANKED_TFT_TURBO queueType.
#[serde(rename = "leaguePoints")]
pub league_points: i32,
pub league_points: Option<i32>,
/// First placement.
#[serde(rename = "wins")]
pub wins: i32,
/// Second through eighth placement.
#[serde(rename = "losses")]
pub losses: i32,
/// Not included for the RANKED_TFT_TURBO queueType.
#[serde(rename = "hotStreak")]
pub hot_streak: bool,
pub hot_streak: Option<bool>,
/// Not included for the RANKED_TFT_TURBO queueType.
#[serde(rename = "veteran")]
pub veteran: bool,
pub veteran: Option<bool>,
/// Not included for the RANKED_TFT_TURBO queueType.
#[serde(rename = "freshBlood")]
pub fresh_blood: bool,
pub fresh_blood: Option<bool>,
/// Not included for the RANKED_TFT_TURBO queueType.
#[serde(rename = "inactive")]
pub inactive: bool,
pub inactive: Option<bool>,
/// Not included for the RANKED_TFT_TURBO queueType.
#[serde(rename = "miniSeries")]
pub mini_series: Option<MiniSeries>,
}
/// TopRatedLadderEntry data object.
#[derive(Debug)]
#[derive(serde::Serialize, serde::Deserialize)]
pub struct TopRatedLadderEntry {
#[serde(rename = "summonerId")]
pub summoner_id: String,
#[serde(rename = "summonerName")]
pub summoner_name: String,
/// (Legal values: ORANGE, PURPLE, BLUE, GREEN, GRAY)
#[serde(rename = "ratedTier")]
pub rated_tier: String,
#[serde(rename = "ratedRating")]
pub rated_rating: i32,
/// First placement.
#[serde(rename = "wins")]
pub wins: i32,
#[serde(rename = "previousUpdateLadderPosition")]
pub previous_update_ladder_position: i32,
}
}
/// Data structs used by [`TftMatchV1`](crate::endpoints::TftMatchV1).
@ -2184,6 +2246,8 @@ pub mod val_match_v1 {
pub match_info: MatchInfo,
#[serde(rename = "players")]
pub players: std::vec::Vec<Player>,
#[serde(rename = "coaches")]
pub coaches: std::vec::Vec<Coach>,
#[serde(rename = "teams")]
pub teams: std::vec::Vec<Team>,
#[serde(rename = "roundResults")]
@ -2273,6 +2337,15 @@ pub mod val_match_v1 {
#[serde(rename = "ultimateCasts")]
pub ultimate_casts: i32,
}
/// Coach data object.
#[derive(Debug)]
#[derive(serde::Serialize, serde::Deserialize)]
pub struct Coach {
#[serde(rename = "puuid")]
pub puuid: String,
#[serde(rename = "teamId")]
pub team_id: String,
}
/// Team data object.
#[derive(Debug)]
#[derive(serde::Serialize, serde::Deserialize)]

View file

@ -1,2 +1,2 @@
#!/bin/bash
RGAPI_KEY="$(cat apikey.txt)" RUST_BACKTRACE=1 cargo test --features nightly -- --nocapture
RGAPI_KEY="$(cat apikey.txt)" RUST_BACKTRACE=1 RUST_LOG=riven=debug cargo test --features nightly -- --nocapture

View file

@ -46,5 +46,15 @@ async_tests!{
rassert_eq!(Some(reqwest::StatusCode::FORBIDDEN), r.unwrap_err().status_code());
Ok(())
},
// https://github.com/MingweiSamuel/Riven/issues/25
tft_league_getbysummoner: async {
let sp = RIOT_API.summoner_v4().get_by_summoner_name(Region::JP, "Caihonbbt");
let sr = sp.await.map_err(|e| e.to_string())?.ok_or("Failed to get \"Caihonbbt\"".to_owned())?;
let lp = RIOT_API.tft_league_v1().get_league_entries_for_summoner(Region::JP, &sr.id);
let lr = lp.await.map_err(|e| e.to_string())?;
rassert!(0 < lr.len());
Ok(())
},
}
}