Skip to content

Commit

Permalink
feat: add option of dinamicaly users
Browse files Browse the repository at this point in the history
  • Loading branch information
harlleybastos committed Jul 21, 2023
1 parent c899257 commit 6af2cc9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Run tests
run: cargo test --verbose
- name: Run program
run: cargo run
run: cargo run -- "Harlley Davidson"
env:
RIOT_API_KEY: ${{ secrets.RIOT_API_KEY }}

18 changes: 9 additions & 9 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,25 @@ use reqwest::Error;
struct Summoner {
#[serde(rename = "id")]
id: String,
#[serde(rename = "accountId")]
account_id: String,
#[serde(rename = "puuid")]
puuid: String,
#[serde(rename = "name")]
name: String,
#[serde(rename = "profileIconId")]
profile_icon_id: i32,
#[serde(rename = "revisionDate")]
revision_date: i64,
#[serde(rename = "summonerLevel")]
summoner_level: i32,
}

#[tokio::main]
async fn main() -> Result<(), Error> {
let api_key = std::env::var("RIOT_API_KEY").expect("RIOT_API_KEY is not set");
let summoner_name = "Harlley Davidson";

println!("Enter a summoner name: ");

let mut summoner_name = String::new();
std::io::stdin().read_line(&mut summoner_name)
.expect("Failed to read line");

summoner_name = summoner_name.trim().to_string();

let summoner_url = format!(
"https://br1.api.riotgames.com/lol/summoner/v4/summoners/by-name/{}?api_key={}",
Expand All @@ -32,8 +33,7 @@ async fn main() -> Result<(), Error> {
let response = reqwest::get(&summoner_url).await?;
let summoner: Summoner = response.json().await?;

println!("{:#?}", summoner);
println!("Summoner {} has ID: {} with Profile Icon ID: {} and Summoner Level: {}", summoner.name, summoner.id, summoner.profile_icon_id, summoner.summoner_level);

Ok(())
}

0 comments on commit 6af2cc9

Please sign in to comment.