ttr_api/
releasenotes.rs

1//!Tools for Toontown Rewritten's Release Notes API
2
3extern crate reqwest;
4extern crate serde;
5extern crate serde_json;
6use reqwest::Client;
7use serde::Deserialize;
8
9///Struct for and individual entry in the release notes API for Toontown Rewritten. It does not have any formal documentation. You can find it at <https://www.toontownrewritten.com/api/releasenotes> or <https://www.toontownrewritten.com/api/releasenotes/[id]>.
10
11#[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///Struct for the release notes API for Toontown Rewritten. It does not have any formal documentation. You can find it at <https://www.toontownrewritten.com/api/releasenotes>.
20
21#[derive(Deserialize,Debug)]
22pub struct NotesList(Vec<Release>);
23
24impl Release {
25
26    ///Get specific release notes by noteID.
27    
28    #[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    ///Grabs a complete list of release notes from the API.
40    
41    #[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    ///Grabs a specific note index from NotesList.
49    
50    pub fn get_index(&self,index:usize) -> Release {
51        self.0[index].clone()
52    }
53}