blob: e51409a96118b960476e7eb4f729eeeb8c8ca686 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
use anyhow::Context;
use pandascore::{
endpoint::all::leagues::GetLeagueMatches,
model::{EventStatus, Identifier},
Client,
};
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let token = std::env::var("PANDASCORE_TOKEN").context("PANDASCORE_TOKEN missing")?;
let arg = std::env::args().nth(1).unwrap_or_else(|| "293".to_owned());
let status = std::env::args().nth(2);
let id = arg
.parse::<u64>()
.map_or_else(|_| Identifier::Slug(&arg), Identifier::Id);
let status = match status.as_deref() {
None => None,
Some("past") => Some(EventStatus::Past),
Some("running") => Some(EventStatus::Running),
Some("upcoming") => Some(EventStatus::Upcoming),
Some(status) => return Err(anyhow::anyhow!("Invalid status: {}", status)),
};
let get_league_matches = GetLeagueMatches::builder()
.id(id)
.maybe_status(status)
.build();
let client = Client::new(reqwest::Client::new(), token)?;
let response = client.execute(get_league_matches).await?;
println!("{response:#?}");
Ok(())
}
|