parent
7bf6daa598
commit
63516bf7e6
@ -1,3 +1,49 @@ |
|||||||
|
use serde::Deserialize; |
||||||
|
use std::{thread, time}; |
||||||
|
|
||||||
|
extern crate reqwest; |
||||||
|
|
||||||
|
const API_URL: &str = "https://status.robertsspaceindustries.com/"; |
||||||
|
|
||||||
|
const STATUS_URL: &str = "https://status.robertsspaceindustries.com/static/content/api/v0/systems.en.json"; |
||||||
|
const INCIDENTS_URL: &str = "https://status.robertsspaceindustries.com/static/content/api/v0/incidents/timeline.en.json"; |
||||||
|
|
||||||
|
|
||||||
|
#[derive(Deserialize, Debug)] |
||||||
|
struct Status { |
||||||
|
name: String, |
||||||
|
status: String, |
||||||
|
order: u8, |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
fn get_incidents() -> Result<(),reqwest::Error> { |
||||||
|
// TODO add parsing for the data this returns
|
||||||
|
let res = reqwest::blocking::get(INCIDENTS_URL)?; |
||||||
|
let data = res.text()?; |
||||||
|
// let pu = &data[1];
|
||||||
|
// let ea = &data[2];
|
||||||
|
//println!("Persistent Universe: {}\nEA: {}", pu.status, ea.status);
|
||||||
|
dbg!(data); |
||||||
|
Ok(()) |
||||||
|
} |
||||||
|
|
||||||
|
fn get_status() -> Result<(),reqwest::Error> { |
||||||
|
let res = reqwest::blocking::get(STATUS_URL)?; |
||||||
|
let data = res.json::<Vec<Status>>()?; |
||||||
|
let pu = &data[1]; |
||||||
|
let ea = &data[2]; |
||||||
|
println!("Persistent Universe: {}\nEA: {}", pu.status, ea.status); |
||||||
|
Ok(()) |
||||||
|
} |
||||||
|
|
||||||
fn main() { |
fn main() { |
||||||
println!("Hello, world!"); |
match get_status(){ |
||||||
|
Err(e) => println!("{:?}", e), |
||||||
|
_ => () |
||||||
|
} |
||||||
|
// match get_incidents(){
|
||||||
|
// Err(e) => println!("{:?}", e),
|
||||||
|
// _ => ()
|
||||||
|
// }
|
||||||
} |
} |
||||||
|
Loading…
Reference in new issue