barebones riot_api + middleware Riven hack
commit
d747d1a6fa
|
@ -0,0 +1,2 @@
|
||||||
|
/target
|
||||||
|
.env
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,15 @@
|
||||||
|
[package]
|
||||||
|
name = "lol-pairing-stat-fetcher-rs"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
async-trait = "0.1.77"
|
||||||
|
dotenvy = "0.15.7"
|
||||||
|
redis = "0.24.0"
|
||||||
|
reqwest = "0.11.24"
|
||||||
|
reqwest-middleware = { git = "https://git.zynh.me/Zynh0722/reqwest-middleware.git" }
|
||||||
|
riven = { git = "https://git.zynh.me/Zynh0722/Riven.git", branch = "feat-middleware" }
|
||||||
|
tokio = { version = "1.36.0", features = ["full"] }
|
|
@ -0,0 +1 @@
|
||||||
|
RG_API_KEY=api_key_here
|
|
@ -0,0 +1,38 @@
|
||||||
|
use std::error::Error;
|
||||||
|
|
||||||
|
use reqwest_middleware::ClientBuilder;
|
||||||
|
use riven::{RiotApi, RiotApiConfig};
|
||||||
|
|
||||||
|
#[tokio::main]
|
||||||
|
async fn main() -> Result<(), Box<dyn Error>> {
|
||||||
|
let r_api = fetch_api()?;
|
||||||
|
|
||||||
|
let summoner = r_api
|
||||||
|
.summoner_v4()
|
||||||
|
.get_by_summoner_name(riven::consts::PlatformRoute::NA1, "RavenShade")
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
println!("{:#?}", summoner);
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn fetch_api() -> Result<RiotApi, Box<dyn Error>> {
|
||||||
|
dotenvy::dotenv()?;
|
||||||
|
|
||||||
|
let rg_api_key: String = std::env::var("RG_API_KEY")?;
|
||||||
|
let mut default_headers = reqwest::header::HeaderMap::new();
|
||||||
|
default_headers.insert(
|
||||||
|
RiotApiConfig::RIOT_KEY_HEADER,
|
||||||
|
reqwest::header::HeaderValue::from_bytes(rg_api_key.as_ref()).unwrap(),
|
||||||
|
);
|
||||||
|
|
||||||
|
let c_builder = ClientBuilder::new(
|
||||||
|
reqwest::ClientBuilder::new()
|
||||||
|
.default_headers(default_headers)
|
||||||
|
.build()?,
|
||||||
|
);
|
||||||
|
let config = RiotApiConfig::with_client_builder(c_builder);
|
||||||
|
|
||||||
|
Ok(RiotApi::new(config))
|
||||||
|
}
|
Loading…
Reference in New Issue