https://github.com/jacoblincool/moodle-rs
Moodle Webservice Client in Rust.
https://github.com/jacoblincool/moodle-rs
moodle
Last synced: about 1 year ago
JSON representation
Moodle Webservice Client in Rust.
- Host: GitHub
- URL: https://github.com/jacoblincool/moodle-rs
- Owner: JacobLinCool
- License: agpl-3.0
- Created: 2023-09-17T19:59:31.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-12-15T02:49:55.000Z (over 2 years ago)
- Last Synced: 2024-04-23T14:05:29.511Z (about 2 years ago)
- Topics: moodle
- Language: Rust
- Homepage: https://docs.rs/moodle
- Size: 695 KB
- Stars: 3
- Watchers: 2
- Forks: 1
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# moodle-rs
Moodle Webservice Client in Rust.
## Features
- Parameters and return values are fully typed.
- However, due to the version differences of Moodle, sometimes you can use `call_raw` to get the raw `serde_json::Value` and parse it yourself.
## Example
See [examples](./examples/).
```rs
use moodle::api::core::course::get_enrolled_courses_by_timeline_classification::{call, Params};
use moodle::client::{login, MoodleClient};
#[tokio::main]
async fn main() {
let base_url = std::env::var("MOODLE_URL").unwrap();
let username = std::env::var("MOODLE_USERNAME").unwrap();
let password = std::env::var("MOODLE_PASSWORD").unwrap();
let token = login(&base_url, &username, &password).await.unwrap();
let mut client = MoodleClient::new(&base_url, &token);
let result = call(
&mut client,
&mut Params {
classification: Some("all".to_string()),
limit: Some(3),
offset: Some(0),
sort: None,
customfieldname: None,
customfieldvalue: None,
searchvalue: None,
},
)
.await;
println!("{:#?}", result);
}
```