Dnevnik-Mos-Rust
A rust API wrapper for accessing the https://dnevnik.mos.ru internal API
All API info was gathered by reverse engineering the network requests.
Goals
- [X] Marks API (mostly)
- [X] Lessons API
- [X] Attendance/visits API
- [ ] Basic Authentication
- [ ] Teacher-Side API
Usage
```rust
use dnevnik::prelude::*;
// assuming you are using tokio, anyhow and chrono
[tokio::main]
async fn main() -> anyhow::Result<()> {
let authtoken: String = "Your auth token";
let diary: Diary = Diary::new(authtoken).await?;
let studentprofile: StudentProfile = diary.profile;
// Gets homework for the last week
let homework: Vec = diary.homework(
Utc::now() - Duration::days(7),
Utc::now()
).await?;
// Downloads all attachment files from this homework
homework.iter().foreach(|hw| {
if !hw.homeworkentry.attachments.isempty() {
let attachment: &HomeworkAttachment = &hw.homeworkentry.attachments[0];
println!(
"Downloading attachment for {} (path: {})",
hw.homeworkentry.subject().name,
attachment.filename
);
let path: PathBuf = PathBuf::from(&attachment.filename);
diary.download_attachment(path.clone(), attachment).await?;
}
});
Ok(())
}
```
More examples are TBD