use assist::{AllDepartment, AllMajor, AllPrefix};
use reqwest::ClientBuilder;
use serde_json::Value;
#[tokio::main]
async fn main() {
let client = ClientBuilder::new().build().unwrap();
let url = "https://assist.org/api/articulation/Agreements?Key=74/8/to/11/AllPrefixes";
let json_str = client.get(url).send().await.unwrap().json::<Value>().await.unwrap().get("result").unwrap().get("articulations").unwrap().to_string().replace("\\\"", "\"").replace("\\\"", "\"");
let _articulations: Vec<AllPrefix> = serde_json::from_str(&json_str[1..=json_str.len()-2]).unwrap();
eprintln!("AllPrefix deserialization works");
let url = url.replace("AllPrefixes", "AllDepartments");
let json_str = client.get(url.clone()).send().await.unwrap().json::<Value>().await.unwrap().get("result").unwrap().get("articulations").unwrap().to_string().replace("\\\"", "\"").replace("\\\"", "\"");
println!("{}", json_str);
let articulations: Vec<AllDepartment> = serde_json::from_str(&json_str[1..=json_str.len()-2]).unwrap();
println!("{:#?}", articulations);
eprintln!("AllDepartment deserialization works");
let url = url.replace("AllDepartments", "AllMajors");
let json_str = client.get(url).send().await.unwrap().json::<Value>().await.unwrap().get("result").unwrap().get("articulations").unwrap().to_string().replace("\\\"", "\"").replace("\\\"", "\"");
println!("{}", json_str);
let articulations: Vec<AllMajor> = serde_json::from_str(&json_str[1..=json_str.len()-2]).unwrap();
eprintln!("AllMajor deserialization works");
println!("{:#?}", articulations);
}