classcharts/lib.rs
1#![recursion_limit = "256"]
2
3//! # An unoffical ClassCharts Student API Library
4//!
5//! [Repository](https://github.com/veloii/classcharts-rs)
6//!
7//! The student version of ClassCharts is allows students to view their homework, timetable,
8//! attendance, etc. This library aims to help people create applications to interact with the
9//! ClassCharts API.
10//!
11//! ## Prerequisites
12//!
13//! * A ClassCharts Access Code (provided by your school). This is NOT saved or sent to anywhere
14//! but ClassChart's servers.
15//!
16//! ## Usage
17//!
18//! To create a ClassCharts Student Client and get their info.
19//!
20//! ```rust,no_run
21//! use classcharts::Client;
22//! # #[tokio::main]
23//! # async fn main() {
24//! let mut client = Client::create("your access code", "your date of birth
25//! (DD/MM/YYYY)", None).await.unwrap();
26//!
27//! let student_info = client.get_student_info().await.unwrap();
28//! println!("{:?}", student_info);
29//! # }
30//! ```
31//!
32//! To view the current student's homework:
33//!
34//! ```rust,no_run
35//! # use classcharts::Client;
36//! # #[tokio::main]
37//! # async fn main() {
38//! # let mut client = Client::create("your access code", "your date of birth
39//! # (DD/MM/YYYY)", None).await.unwrap();
40//! let homework = client.get_homeworks(None).await.unwrap();
41//! # }
42//! ```
43//!
44//! For a complete list of ClassCharts methods the `Client` exposes:
45//! * `get_activity`
46//! * `get_full_activity`
47//! * `get_announcements`
48//! * `get_attendance`
49//! * `get_badges`
50//! * `get_behaviour`
51//! * `get_detentions`
52//! * `get_homeworks`
53//! * `get_lessons`
54//! * `get_pupilfields`
55//! * `get_rewards`
56//! * `purchase_reward`
57//! * `get_student_info`
58//!
59//! They will all return a `Result<SuccessResponse, ErrorResponse>`.
60//!
61//! # Responses and Errors
62//!
63//! This library trys to not abstract over the ClassCharts API too much.
64//!
65//! ## `SuccessResponse<Data, Meta>` struct
66//!
67//! This wraps the `Data` and `Meta` in a struct with their respective property names. This will be
68//! emitted when the ClassCharts API returns `{ success: 1 }`.
69//!
70//! You can find the specfic `Data` / `Meta` under `classcharts::api`, for example
71//! `classcharts::api::homework::HomeworkData`.
72//!
73//! ## `ErrorResponse` enum
74//!
75//! This will be either:
76//! * `GenericClientError` - reqwest:Error
77//! * `TextParsingError` - reqwest:Error
78//! * `SerdeJsonParsingError` - serde_json::Error
79//! * `ClassChartsStatusError` - This will occur when the ClassCharts API returns a non `{ success: 1 }` with no error message attribute
80//! * `ClassChartsError` - Similar to `ClassChartsStatusError`, but it includes the error message attribute ClassCharts returned
81
82mod client;
83mod macros;
84
85pub use client::ErrorResponse;
86pub use client::SuccessResponse;
87pub use client::Client;
88pub use client::ClientCreationError as ClientError;
89pub mod api;