forked from mirror/Riven
1
0
Fork 0

readme example

users/mingwei/surf
Mingwei Samuel 2019-11-03 14:36:30 -08:00
parent 1581425206
commit 3d0b42e31c
4 changed files with 15 additions and 13 deletions

View File

@ -23,9 +23,13 @@ Riven currently uses nightly Rust.
use riven::RiotApi;
use riven::consts::Region;
async {
// Enter tokio async runtime.
let rt = tokio::runtime::Runtime::new().unwrap();
rt.block_on(async {
// Create RiotApi instance from key.
let riot_api = RiotApi::with_key("RGAPI-01234567-89ab-cdef-0123-456789abcdef");
let api_key = "RGAPI-01234567-89ab-cdef-0123-456789abcdef";
# let api_key = std::env::var("RGAPI_KEY").ok().or_else(|| std::fs::read_to_string("apikey.txt").ok()).unwrap();
let riot_api = RiotApi::with_key(api_key);
// Get summoner data.
let summoner = riot_api.summoner_v4()
@ -48,10 +52,8 @@ async {
mastery.champion_id.to_string(),
mastery.champion_points, mastery.champion_level);
}
}
});
```
Full code in [tests/readme.rs.ignored](./tests/readme.rs.ignored)
Output:
```text
잘 못 Champion Masteries:

View File

@ -7,7 +7,7 @@ macro_rules! async_tests {
env_logger::init();
std::process::exit({
let mut rt = tokio::runtime::current_thread::Runtime::new()
let rt = tokio::runtime::Runtime::new()
.expect("Failed to create runtime.");
let (_, errs) = rt.block_on(async {

View File

@ -19,7 +19,7 @@ async_tests!{
my_runner {
league_summoner_bulk_test: async {
let leagues = (1..20)
let leagues = (1..10)
.map(async move |i| {
let leaguelist = RIOT_API.league_v4().get_league_entries(REGION,
QueueType::RANKED_SOLO_5x5, Tier::GOLD, Division::III, Some(i));