epitech_api #0.2.0
A library for interacting with the EPITECH intranet API
#api
#async
#epitech
#intranet
#web
Maintenance intention for this crate
Owned by 
Nicolas Polomack
Downloaded 239 times
Created on Mar 22 2021, 01:39
Last updated on Mar 22 2021, 01:39
Link to Repository
Link to Documentation

 EPITECH-API

Crates.io Crates.io Crates.io Dependabot Status

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.
};