20 releases
0.2.0 | Jan 16, 2020 |
---|---|
0.1.18 | Nov 10, 2019 |
0.1.17 | Oct 23, 2019 |
0.1.15 | Dec 3, 2018 |
0.1.8 | Jul 3, 2018 |
#2028 in Web programming
69 downloads per month
32KB
908 lines
EPITECH-API
This is a Rust library built on top of reqwest for interacting with the EPITECH intranet.
This library focuses on ease-of-use and type-safety.
Goal
This project aims to stick a type on intranet resources so that every possible members are clearly represented and safely accessible.
How to use
Everything originates from the Client
struct.
You can create an Client
this way:
use epitech_api::{Client, Error};
let result = Client::builder()
.autologin("[INSERT AUTOLOGIN LINK HERE]")
.authenticate()
.await; // This returns a `Result<Client, Error>`.
let client = match result {
Ok(client) => client,
Err(err) => , // Handle authentication error here.
};
Right after this, you're already authenticated to the intranet and ready to proceed with requests.
You can, for instance, request the list of all students in a promotion this way:
// This makes the request and returns a `Result<Vec<UserEntry>, Error>`.
let result = client.fetch_student_list()
.location(Location::Strasbourg)
.promo(Promo::Tek2)
.year(2020)
.send()
.await;
Client::make_request
allows you to make an arbitrary request to the intranet:
// Notice that only the path component of the route can be passed to the method.
let my_student_infos = match client.make_request("/user").await {
Ok(text: String) => , // Here, `text` represents the raw intranet response body.
Err(err: Error) => , // Handle request error here.
};
Dependencies
~4–9MB
~193K SLoC