1.0.8 โข Published 5 months ago
ecoledirecte-client v1.0.8
๐ EcoleDirecte Client
ecoledirecte-client
est un module Node.js permettant d'interagir avec l'API d'Ecole Directe de maniรจre simple et efficace.
๐ Installation
npm install ecoledirecte-client
๐น Importation et Connexion
Connexion ร l'API
const { Auth, Api } = require("ecoledirecte-client");
async function main() {
try {
const auth = new Auth("questions.json");
const api = new Api(await auth.login("MY_LOGIN", "MY_PASSWORD"));
const profile = await api.getProfile();
console.log("Profil's informations :");
console.log("Name :", profile.nom);
console.log("First name :", profile.prenom);
} catch (error) {
console.error(error.message);
}
}
main();
๐ Utilisation of the main features
๐ Get the list of students on a account
async function getStudentsExample() {
const token = await Auth.login("identifiant", "motdepasse");
const api = new Api(token);
const students = await api.getStudents();
console.log(students);
}
getStudentsExample();
๐ Get the notes of a student
async function getNotesExample() {
const token = await Auth.login("identifiant", "motdepasse");
const api = new Api(token);
const students = await api.getStudents();
if (students.length > 0) {
const firstStudent = students[0];
const notes = await firstStudent.getNotes();
console.log(notes);
}
}
getNotesExample();
๐ Get the homeworks day of a student
async function getHomeworksExample() {
const token = await Auth.login("identifiant", "motdepasse");
const api = new Api(token);
const students = await api.getStudents();
if (students.length > 0) {
const firstStudent = students[0];
const homeworksDay = await firstStudent.getHomeworksDay();
console.log(homeworksDay);
}
}
getHomeworksExample();
๐ Get the homeworks of a day
async function getHomeworksExample() {
const token = await Auth.login("identifiant", "motdepasse");
const api = new Api(token);
const students = await api.getStudents();
if (students.length > 0) {
const firstStudent = students[0];
const homeworksDay = await firstStudent.getHomeworksDay();
if (homeworksDay.length > 0) {
const firstHomeworksDay = homeworksDay[0];
const homeworks = await firstHomeworksDay.getMore();
console.log(homeworks);
}
}
}
getHomeworksExample();
๐ Example of questions.json
:
{
"question": "Quelle est votre ville de rรฉsidence ?",
"reponse": "Paris"
},
Several questions are possible, see the questions.json.example
file for more information.
๐ ๏ธ Dependencies
- Node.js >= 16 (necessary for the module to work)
๐ Contribution
If you want to improve this project : 1. Fork the GitHub repo. 2. Clone the project :
git clone https://github.com/ton-user/ecoledirecte-client.git
- Installe les dรฉpendances :
npm install
- Create a branch and propose your changes.
๐ Licence
This project is under the MIT license. You can use it freely as long as you mention the original author.
๐ Contact
If you encounter a problem, open an issue on GitHub. ๐
You can also reach me by email at contact@pierre.ebele.fr
or pierre@ebele.fr