1extern crate reqwest;
4extern crate serde;
5extern crate serde_json;
6use reqwest::Client;
7use serde::Deserialize;
8
9#[derive(Deserialize,Debug,Clone)]
12pub struct Release {
13 pub noteId: u16,
14 pub slug: String,
15 pub date: String,
16 pub body: Option<String>
17}
18
19#[derive(Deserialize,Debug)]
22pub struct NotesList(Vec<Release>);
23
24impl Release {
25
26 #[tokio::main]
29 pub async fn new(client:Client,id:u16) -> Result<Self,Box<dyn std::error::Error>> {
30 let resp = client.get(format!("https://www.toontownrewritten.com/api/releasenotes/{}",id)).send().await?
31 .json::<Self>()
32 .await?;
33 Ok(resp)
34 }
35}
36
37impl NotesList {
38
39 #[tokio::main]
42 pub async fn new(client:Client) -> Result<Self,Box<dyn std::error::Error>> {
43 let resp = client.get("https://www.toontownrewritten.com/api/releasenotes").send().await?
44 .json::<Self>()
45 .await?;
46 Ok(resp)}
47
48 pub fn get_index(&self,index:usize) -> Release {
51 self.0[index].clone()
52 }
53}