mirror of https://github.com/MingweiSamuel/Riven
Use new routing instead of region
parent
d4cf56f496
commit
dded4d5644
|
@ -25,7 +25,7 @@ Data structs and endpoints are automatically generated from the
|
|||
|
||||
```rust
|
||||
use riven::RiotApi;
|
||||
use riven::consts::Region;
|
||||
use riven::consts::PlatformRoute;
|
||||
|
||||
// Enter tokio async runtime.
|
||||
let mut rt = tokio::runtime::Runtime::new().unwrap();
|
||||
|
@ -37,7 +37,7 @@ rt.block_on(async {
|
|||
|
||||
// Get summoner data.
|
||||
let summoner = riot_api.summoner_v4()
|
||||
.get_by_summoner_name(Region::NA, "잘 못").await
|
||||
.get_by_summoner_name(PlatformRoute::NA1, "잘 못").await
|
||||
.expect("Get summoner failed.")
|
||||
.expect("There is no summoner with that name.");
|
||||
|
||||
|
@ -46,7 +46,7 @@ rt.block_on(async {
|
|||
|
||||
// Get champion mastery data.
|
||||
let masteries = riot_api.champion_mastery_v4()
|
||||
.get_all_champion_masteries(Region::NA, &summoner.id).await
|
||||
.get_all_champion_masteries(PlatformRoute::NA1, &summoner.id).await
|
||||
.expect("Get champion masteries failed.");
|
||||
|
||||
// Print champioon masteries.
|
||||
|
|
|
@ -31,9 +31,6 @@ pub use queue::*;
|
|||
|
||||
pub mod ranks;
|
||||
|
||||
mod region; // REMOVEME!
|
||||
pub use region::*;
|
||||
|
||||
mod route;
|
||||
pub use route::*;
|
||||
|
||||
|
|
|
@ -1,76 +0,0 @@
|
|||
use strum_macros::{ EnumString, Display, AsRefStr, IntoStaticStr };
|
||||
|
||||
/// A region served by a single game server.
|
||||
/// Each Riot Games API request is directed at a particular region,
|
||||
/// with tournament API requests directed at the AMERICAS "global" region.
|
||||
///
|
||||
/// Valorant regions are prefixed with `VAL_` due to the name collision with
|
||||
/// `BR` ("BR1") for LoL and `BR` ("BR") for Valorant.
|
||||
#[derive(Debug)]
|
||||
#[derive(PartialEq, Eq, Hash, PartialOrd, Ord)]
|
||||
#[derive(EnumString, Display, AsRefStr, IntoStaticStr)]
|
||||
#[derive(Clone, Copy)]
|
||||
pub enum Region {
|
||||
#[strum(to_string="BR1", serialize="BR")]
|
||||
BR,
|
||||
#[strum(to_string="EUN1", serialize="EUNE")]
|
||||
EUNE,
|
||||
#[strum(to_string="EUW1", serialize="EUW")]
|
||||
EUW,
|
||||
#[strum(to_string="NA1", serialize="NA")]
|
||||
NA,
|
||||
#[strum(to_string="KR")]
|
||||
KR,
|
||||
#[strum(to_string="LA1", serialize="LAN")]
|
||||
LAN,
|
||||
#[strum(to_string="LA2", serialize="LAS")]
|
||||
LAS,
|
||||
#[strum(to_string="OC1", serialize="OCE")]
|
||||
OCE,
|
||||
#[strum(to_string="RU")]
|
||||
RU,
|
||||
#[strum(to_string="TR1", serialize="TR")]
|
||||
TR,
|
||||
#[strum(to_string="JP1", serialize="JP")]
|
||||
JP,
|
||||
#[strum(to_string="PBE1", serialize="PBE")]
|
||||
PBE,
|
||||
#[strum(to_string="AMERICAS")]
|
||||
AMERICAS,
|
||||
#[strum(to_string="EUROPE")]
|
||||
EUROPE,
|
||||
#[strum(to_string="ASIA")]
|
||||
ASIA,
|
||||
|
||||
// Problem: serializing and deserializing these will result in a different
|
||||
// enum picked, due to naming collision.
|
||||
#[strum(to_string="AP")]
|
||||
VAL_AP,
|
||||
#[strum(to_string="BR")]
|
||||
VAL_BR,
|
||||
#[strum(to_string="EU")]
|
||||
VAL_EU,
|
||||
#[strum(to_string="KR")]
|
||||
VAL_KR,
|
||||
#[strum(to_string="LATAM")]
|
||||
VAL_LATAM,
|
||||
#[strum(to_string="NA")]
|
||||
VAL_NA,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_basic() {
|
||||
assert_eq!("BR1", Region::BR.to_string());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_get() {
|
||||
assert_eq!(Ok(Region::JP), "JP".parse());
|
||||
assert_eq!(Ok(Region::NA), "NA1".parse());
|
||||
assert!("LA".parse::<Region>().is_err());
|
||||
}
|
||||
}
|
677
src/endpoints.rs
677
src/endpoints.rs
File diff suppressed because it is too large
Load Diff
|
@ -1,14 +1,5 @@
|
|||
const changeCase = require('change-case');
|
||||
|
||||
const enumTypeLookup = {
|
||||
champion: 'i16',
|
||||
gameMode: 'u8',
|
||||
gameType: 'u8',
|
||||
map: 'u8',
|
||||
queue: 'u16',
|
||||
season: 'u8',
|
||||
};
|
||||
|
||||
// flatMap: https://gist.github.com/samgiles/762ee337dff48623e729
|
||||
// [B](f: (A) ⇒ [B]): [B] ; Although the types in the arrays aren't strict (:
|
||||
Array.prototype.flatMap = function(lambda) {
|
||||
|
|
|
@ -16,7 +16,7 @@ use std::vec::Vec;
|
|||
use reqwest::Method;
|
||||
|
||||
use crate::Result;
|
||||
use crate::consts::Region;
|
||||
use crate::consts::{ RegionalRoute, PlatformRoute, ValPlatformRoute };
|
||||
use crate::riot_api::RiotApi;
|
||||
|
||||
{{
|
||||
|
@ -103,7 +103,9 @@ impl<'a> {{= endpoint }}<'a> {
|
|||
let descArr = operation.description.split('\n');
|
||||
|
||||
/* Build argument comment & string. */
|
||||
const argBuilder = [];
|
||||
const argBuilder = [
|
||||
'route: ', dotUtils.changeCase.pascalCase(operation['x-route-enum']), 'Route'
|
||||
];
|
||||
|
||||
/* Add body params before path/query. */
|
||||
if (bodyType) {
|
||||
|
@ -155,7 +157,7 @@ impl<'a> {{= endpoint }}<'a> {
|
|||
}
|
||||
}}
|
||||
/// # Parameters
|
||||
/// * `region` - Region to query.
|
||||
/// * `route` - Route to query.
|
||||
{{
|
||||
if (allParams)
|
||||
{
|
||||
|
@ -171,10 +173,11 @@ impl<'a> {{= endpoint }}<'a> {
|
|||
/// <a href="{{= operation.externalDocs.url }}" target="_blank">`{{= operationId }}`</a>
|
||||
///
|
||||
/// Note: this method is automatically generated.
|
||||
pub fn {{= method }}(&self, region: Region{{= argBuilder.join('') }})
|
||||
pub fn {{= method }}(&self, {{= argBuilder.join('') }})
|
||||
-> impl Future<Output = Result<{{= returnType }}>> + 'a
|
||||
{
|
||||
let request = self.base.request(Method::{{= verb.toUpperCase() }}, region.into(), {{= routeArgument }});
|
||||
let route_str = route.into();
|
||||
let request = self.base.request(Method::{{= verb.toUpperCase() }}, route_str, {{= routeArgument }});
|
||||
{{
|
||||
for (let queryParam of queryParams)
|
||||
{
|
||||
|
@ -194,7 +197,7 @@ impl<'a> {{= endpoint }}<'a> {
|
|||
{{? bodyType }}
|
||||
let request = request.body(serde_json::ser::to_vec(body).unwrap());
|
||||
{{?}}
|
||||
self.base.execute{{= hasReturn ? (returnOptional ? '_opt' : '_val') : '' }}{{= returnTypeTurbofish }}("{{= operationId }}", region.into(), request)
|
||||
self.base.execute{{= hasReturn ? (returnOptional ? '_opt' : '_val') : '' }}{{= returnTypeTurbofish }}("{{= operationId }}", route_str, request)
|
||||
}
|
||||
|
||||
{{
|
||||
|
|
|
@ -9,39 +9,40 @@ use colored::*;
|
|||
|
||||
use riven::consts::*;
|
||||
|
||||
const ROUTE: PlatformRoute = PlatformRoute::EUW1;
|
||||
|
||||
async_tests!{
|
||||
my_runner {
|
||||
// Champion Mastery tests.
|
||||
championmastery_getscore_ma5tery: async {
|
||||
let sum = RIOT_API.summoner_v4().get_by_summoner_name(Region::EUW, "ma5tery");
|
||||
let sum = RIOT_API.summoner_v4().get_by_summoner_name(ROUTE, "ma5tery");
|
||||
let sum = sum.await.map_err(|e| e.to_string())?.ok_or("Failed to get summoner".to_owned())?;
|
||||
|
||||
let p = RIOT_API.champion_mastery_v4().get_champion_mastery_score(Region::EUW, &*sum.id);
|
||||
let p = RIOT_API.champion_mastery_v4().get_champion_mastery_score(ROUTE, &*sum.id);
|
||||
let s = p.await.map_err(|e| e.to_string())?;
|
||||
rassert!(969 <= s && s <= 1000, "Unexpected ma5tery score: {}.", s);
|
||||
Ok(())
|
||||
},
|
||||
championmastery_getall_ma5tery: async {
|
||||
let sum = RIOT_API.summoner_v4().get_by_summoner_name(Region::EUW, "ma5tery");
|
||||
let sum = RIOT_API.summoner_v4().get_by_summoner_name(ROUTE, "ma5tery");
|
||||
let sum = sum.await.map_err(|e| e.to_string())?.ok_or("Failed to get summoner".to_owned())?;
|
||||
|
||||
let p = RIOT_API.champion_mastery_v4().get_all_champion_masteries(Region::EUW, &*sum.id);
|
||||
let p = RIOT_API.champion_mastery_v4().get_all_champion_masteries(ROUTE, &*sum.id);
|
||||
let s = p.await.map_err(|e| e.to_string())?;
|
||||
rassert!(s.len() >= 142, "Expected masteries: {}.", s.len());
|
||||
Ok(())
|
||||
},
|
||||
spectator_combo: async {
|
||||
let featured_p = RIOT_API.spectator_v4().get_featured_games(Region::EUW);
|
||||
let featured_p = RIOT_API.spectator_v4().get_featured_games(ROUTE);
|
||||
let featured = featured_p.await.map_err(|e| e.to_string())?;
|
||||
|
||||
rassert!(featured.game_list.len() > 0);
|
||||
|
||||
let summoner_name = &featured.game_list[0].participants[0].summoner_name;
|
||||
let summoner_p = RIOT_API.summoner_v4().get_by_summoner_name(Region::EUW, summoner_name);
|
||||
let summoner_p = RIOT_API.summoner_v4().get_by_summoner_name(ROUTE, summoner_name);
|
||||
let summoner = summoner_p.await.map_err(|e| e.to_string())?.ok_or("Failed to get summoner".to_owned())?;
|
||||
|
||||
let livegame_p = RIOT_API.spectator_v4().get_current_game_info_by_summoner(Region::EUW, &summoner.id);
|
||||
let livegame_p = RIOT_API.spectator_v4().get_current_game_info_by_summoner(ROUTE, &summoner.id);
|
||||
let livegame_o = livegame_p.await.map_err(|e| e.to_string())?;
|
||||
if let Some(livegame) = livegame_o {
|
||||
let participant_match = livegame.participants.iter().find(|p| p.summoner_name == *summoner_name);
|
||||
|
|
|
@ -9,12 +9,13 @@ use colored::*;
|
|||
|
||||
use riven::consts::*;
|
||||
|
||||
const ROUTE: PlatformRoute = PlatformRoute::JP1;
|
||||
|
||||
async_tests!{
|
||||
my_runner {
|
||||
// Summoner tests.
|
||||
summoner_get_kanjikana: async {
|
||||
let p = RIOT_API.summoner_v4().get_by_summoner_name(Region::JP, "私の 頭が かたい");
|
||||
let p = RIOT_API.summoner_v4().get_by_summoner_name(ROUTE, "私の 頭が かたい");
|
||||
let s = p.await.map_err(|e| e.to_string())?.ok_or("Failed to get myheadhard".to_owned())?;
|
||||
rassert_eq!("私の頭がかたい", s.name);
|
||||
Ok(())
|
||||
|
@ -32,16 +33,16 @@ async_tests!{
|
|||
// If we use `get` (instead of `get_optional`) make sure it errors.
|
||||
get_nonoptional_invalid: async {
|
||||
let path_string = format!("/lol/summoner/v4/summoners/by-name/{}", "SUMMONER THAT DOES NOT EXIST");
|
||||
let request = RIOT_API.request(reqwest::Method::GET, Region::JP.into(), &path_string);
|
||||
let request = RIOT_API.request(reqwest::Method::GET, ROUTE.into(), &path_string);
|
||||
let p = RIOT_API.execute_val::<riven::models::summoner_v4::Summoner>(
|
||||
"summoner-v4.getBySummonerName", Region::JP.into(), request);
|
||||
"summoner-v4.getBySummonerName", ROUTE.into(), request);
|
||||
let r = p.await;
|
||||
rassert!(r.is_err());
|
||||
Ok(())
|
||||
},
|
||||
// Make sure 403 is handled as expected.
|
||||
tournament_forbidden: async {
|
||||
let p = RIOT_API.tournament_v4().get_tournament_code(Region::JP, "INVALID_CODE");
|
||||
let p = RIOT_API.tournament_v4().get_tournament_code(ROUTE.to_regional(), "INVALID_CODE");
|
||||
let r = p.await;
|
||||
rassert!(r.is_err());
|
||||
rassert_eq!(Some(reqwest::StatusCode::FORBIDDEN), r.unwrap_err().status_code());
|
||||
|
@ -51,9 +52,9 @@ async_tests!{
|
|||
// tft-league-v1.getLeagueEntriesForSummoner
|
||||
// https://github.com/MingweiSamuel/Riven/issues/25
|
||||
tft_league_getleagueentriesforsummoner: async {
|
||||
let sp = RIOT_API.summoner_v4().get_by_summoner_name(Region::JP, "Caihonbbt");
|
||||
let sp = RIOT_API.summoner_v4().get_by_summoner_name(ROUTE, "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 lp = RIOT_API.tft_league_v1().get_league_entries_for_summoner(ROUTE, &sr.id);
|
||||
let lr = lp.await.map_err(|e| e.to_string())?;
|
||||
rassert!(0 < lr.len());
|
||||
Ok(())
|
||||
|
@ -61,7 +62,7 @@ async_tests!{
|
|||
// tft-league-v1.getTopRatedLadder
|
||||
// https://github.com/MingweiSamuel/Riven/issues/24
|
||||
tft_league_gettopratedladder: async {
|
||||
let lp = RIOT_API.tft_league_v1().get_top_rated_ladder(Region::JP, QueueType::RANKED_TFT_TURBO);
|
||||
let lp = RIOT_API.tft_league_v1().get_top_rated_ladder(ROUTE, QueueType::RANKED_TFT_TURBO);
|
||||
let lr = lp.await.map_err(|e| e.to_string())?;
|
||||
rassert!(0 < lr.len());
|
||||
Ok(())
|
||||
|
|
|
@ -17,19 +17,21 @@ fn validate_summoners(s1: Summoner, s2: Summoner) -> Result<(), String> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
const ROUTE: PlatformRoute = PlatformRoute::NA1;
|
||||
|
||||
async_tests!{
|
||||
my_runner {
|
||||
// Summoner tests.
|
||||
summoner_double: async {
|
||||
let l1p = RIOT_API.summoner_v4().get_by_summoner_name(Region::NA, "lug nuts k");
|
||||
let l2p = RIOT_API.summoner_v4().get_by_summoner_name(Region::NA, "lugnuts k");
|
||||
let l1p = RIOT_API.summoner_v4().get_by_summoner_name(ROUTE, "lug nuts k");
|
||||
let l2p = RIOT_API.summoner_v4().get_by_summoner_name(ROUTE, "lugnuts k");
|
||||
let l1 = l1p.await.map_err(|e| e.to_string())?.ok_or("Failed to get l1".to_owned())?;
|
||||
let l2 = l2p.await.map_err(|e| e.to_string())?.ok_or("Failed to get l2".to_owned())?;
|
||||
validate_summoners(l1, l2)?;
|
||||
Ok(())
|
||||
},
|
||||
champion_getrotation: async {
|
||||
let p = RIOT_API.champion_v3().get_champion_info(Region::NA);
|
||||
let p = RIOT_API.champion_v3().get_champion_info(ROUTE);
|
||||
let d = p.await.map_err(|e| e.to_string())?;
|
||||
let new_len = d.free_champion_ids_for_new_players.len();
|
||||
let free_len = d.free_champion_ids.len();
|
||||
|
@ -40,7 +42,7 @@ async_tests!{
|
|||
Ok(())
|
||||
},
|
||||
leagueexp_get: async {
|
||||
let p = RIOT_API.league_exp_v4().get_league_entries(Region::NA, QueueType::RANKED_SOLO_5x5, Tier::CHALLENGER, Division::I, None);
|
||||
let p = RIOT_API.league_exp_v4().get_league_entries(ROUTE, QueueType::RANKED_SOLO_5x5, Tier::CHALLENGER, Division::I, None);
|
||||
let d = p.await.map_err(|e| e.to_string())?;
|
||||
rassert!(!d.is_empty(), "Challenger shouldn't be empty.");
|
||||
Ok(())
|
||||
|
@ -48,71 +50,71 @@ async_tests!{
|
|||
|
||||
matchlist_get: async {
|
||||
|
||||
let sp = RIOT_API.summoner_v4().get_by_summoner_name(Region::NA, "haha yes");
|
||||
let sp = RIOT_API.summoner_v4().get_by_summoner_name(ROUTE, "haha yes");
|
||||
let s = sp.await.map_err(|e| e.to_string())?.ok_or("Failed to get \"haha yes\"".to_owned())?;
|
||||
let mp = RIOT_API.match_v4().get_matchlist(Region::NA, &s.account_id, None, Some(2500), None, None, Some(2600), None, None);
|
||||
let mp = RIOT_API.match_v4().get_matchlist(ROUTE, &s.account_id, None, Some(2500), None, None, Some(2600), None, None);
|
||||
let m = mp.await.map_err(|e| e.to_string())?.ok_or("Failed to get matchlist".to_owned())?;
|
||||
rassert!(m.matches.len() > 0, "Matchlist should not be empty");
|
||||
Ok(())
|
||||
},
|
||||
|
||||
match_get: async {
|
||||
let p = RIOT_API.match_v4().get_match(Region::NA, 3190191338);
|
||||
let p = RIOT_API.match_v4().get_match(ROUTE, 3190191338);
|
||||
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_get_bots: async {
|
||||
let p = RIOT_API.match_v4().get_match(Region::NA, 3251803350);
|
||||
let p = RIOT_API.match_v4().get_match(ROUTE, 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_get_odyssey: async {
|
||||
let p = RIOT_API.match_v4().get_match(Region::NA, 2881976826);
|
||||
let p = RIOT_API.match_v4().get_match(ROUTE, 2881976826);
|
||||
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_get_aram: async {
|
||||
let p = RIOT_API.match_v4().get_match(Region::NA, 2961635718);
|
||||
let p = RIOT_API.match_v4().get_match(ROUTE, 2961635718);
|
||||
let m = p.await.map_err(|e| e.to_string())?.ok_or("Failed to get match.".to_owned())?;
|
||||
rassert!(!m.participants.is_empty(), "Match should have participants.");
|
||||
Ok(())
|
||||
},
|
||||
match_get_aram2: async {
|
||||
let p = RIOT_API.match_v4().get_match(Region::NA, 3596184782);
|
||||
let p = RIOT_API.match_v4().get_match(ROUTE, 3596184782);
|
||||
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_get_urf900: async {
|
||||
let p = RIOT_API.match_v4().get_match(Region::NA, 2963663381);
|
||||
let p = RIOT_API.match_v4().get_match(ROUTE, 2963663381);
|
||||
let m = p.await.map_err(|e| e.to_string())?.ok_or("Failed to get match.".to_owned())?;
|
||||
rassert!(!m.participants.is_empty(), "Match should have participants.");
|
||||
Ok(())
|
||||
},
|
||||
match_get_tutorial1: async {
|
||||
let p = RIOT_API.match_v4().get_match(Region::NA, 3432145099);
|
||||
let p = RIOT_API.match_v4().get_match(ROUTE, 3432145099);
|
||||
let m = p.await.map_err(|e| e.to_string())?.ok_or("Failed to get match.".to_owned())?;
|
||||
rassert!(!m.participants.is_empty(), "Match should have participants.");
|
||||
Ok(())
|
||||
},
|
||||
match_get_tutorial2: async {
|
||||
let p = RIOT_API.match_v4().get_match(Region::NA, 3432116214);
|
||||
let p = RIOT_API.match_v4().get_match(ROUTE, 3432116214);
|
||||
let m = p.await.map_err(|e| e.to_string())?.ok_or("Failed to get match.".to_owned())?;
|
||||
rassert!(!m.participants.is_empty(), "Match should have participants.");
|
||||
Ok(())
|
||||
},
|
||||
match_get_tutorial3: async {
|
||||
let p = RIOT_API.match_v4().get_match(Region::NA, 3432156790);
|
||||
let p = RIOT_API.match_v4().get_match(ROUTE, 3432156790);
|
||||
let m = p.await.map_err(|e| e.to_string())?.ok_or("Failed to get match.".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 p = RIOT_API.match_v4().get_match_timeline(ROUTE, 3190191338);
|
||||
let m = p.await.map_err(|e| e.to_string())?.ok_or("Match timeline not found.".to_owned())?;
|
||||
rassert!(!m.frames.is_empty(), "Match timeline should have frames.");
|
||||
Ok(())
|
||||
|
@ -126,17 +128,17 @@ async_tests!{
|
|||
// },
|
||||
// CLASH
|
||||
clash_get_tournaments: async {
|
||||
let p = RIOT_API.clash_v1().get_tournaments(Region::NA);
|
||||
let p = RIOT_API.clash_v1().get_tournaments(ROUTE);
|
||||
let tours = p.await.map_err(|e| e.to_string())?;
|
||||
if let Some(tour0) = tours.first() {
|
||||
let p = RIOT_API.clash_v1().get_tournament_by_id(Region::NA, tour0.id);
|
||||
let p = RIOT_API.clash_v1().get_tournament_by_id(ROUTE, tour0.id);
|
||||
let tour1 = p.await.map_err(|e| e.to_string())?;
|
||||
assert_eq!(Some(tour0.id), tour1.map(|t| t.id));
|
||||
}
|
||||
Ok(())
|
||||
},
|
||||
clash_get_team_by_id: async {
|
||||
let p = RIOT_API.clash_v1().get_team_by_id(Region::NA, "00000000-0000-0000-0000-000000000000");
|
||||
let p = RIOT_API.clash_v1().get_team_by_id(ROUTE, "00000000-0000-0000-0000-000000000000");
|
||||
let team = p.await.map_err(|e| e.to_string())?;
|
||||
assert!(team.is_none());
|
||||
Ok(())
|
||||
|
|
|
@ -10,20 +10,20 @@ use colored::*;
|
|||
use riven::consts::*;
|
||||
use riven::models::summoner_v4::Summoner;
|
||||
|
||||
const REGION: Region = Region::TR;
|
||||
const ROUTE: PlatformRoute = PlatformRoute::TR1;
|
||||
|
||||
|
||||
async_tests!{
|
||||
my_runner {
|
||||
league_summoner_bulk_test: async {
|
||||
let p = RIOT_API.league_v4().get_challenger_league(REGION, QueueType::RANKED_SOLO_5x5);
|
||||
let p = RIOT_API.league_v4().get_challenger_league(ROUTE, QueueType::RANKED_SOLO_5x5);
|
||||
// let p = future_start(p);
|
||||
let ll = p.await.map_err(|e| e.to_string())?;
|
||||
|
||||
println!("{:?} Challenger {} entries.", REGION, ll.entries.len());
|
||||
println!("{:?} Challenger {} entries.", ROUTE, ll.entries.len());
|
||||
|
||||
let sl = ll.entries.iter().take(50)
|
||||
.map(|entry| RIOT_API.summoner_v4().get_by_summoner_id(REGION, &entry.summoner_id))
|
||||
.map(|entry| RIOT_API.summoner_v4().get_by_summoner_id(ROUTE, &entry.summoner_id))
|
||||
.map(tokio::spawn)
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
|
|
|
@ -9,19 +9,19 @@ use colored::*;
|
|||
|
||||
use riven::consts::*;
|
||||
|
||||
const REGION: Region = Region::VAL_LATAM;
|
||||
const ROUTE: ValPlatformRoute = ValPlatformRoute::LATAM;
|
||||
|
||||
|
||||
async_tests!{
|
||||
my_runner {
|
||||
val_content_ranked_test: async {
|
||||
let p = RIOT_API.val_content_v1().get_content(REGION, Some("zh-CN"));
|
||||
let p = RIOT_API.val_content_v1().get_content(ROUTE, Some("zh-CN"));
|
||||
let contents = p.await.map_err(|e| e.to_string())?;
|
||||
|
||||
let act = contents.acts.iter().find(|act| act.is_active)
|
||||
.ok_or(format!("No active acts of {} found.", contents.acts.len()))?;
|
||||
|
||||
let p = RIOT_API.val_ranked_v1().get_leaderboard(REGION, &act.id, None, None);
|
||||
let p = RIOT_API.val_ranked_v1().get_leaderboard(ROUTE, &act.id, None, None);
|
||||
let leaderboard = p.await.map_err(|e| e.to_string())?
|
||||
.ok_or(format!("Failed to get act leaderboard {} {}.", act.id, act.name))?;
|
||||
|
||||
|
|
Loading…
Reference in New Issue