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.
This project aims to stick a type on intranet resources so that every possible members are clearly represented and safely accessible.
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. };