Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export class WrapDirecte {
throw new EcoleDirecteError(`Initial authentication setup failed while fetching GTK: ${message}`);
}

const response = await this.http.request<any>('POST', '/login.awp', {
const response = await this.http.post<any>('/login.awp', {
identifiant: username,
motdepasse: password,
isReLogin: false,
Expand All @@ -88,8 +88,7 @@ export class WrapDirecte {
}, {});

if (response.code === 250) {
const challengeResponse = await this.http.request<{ question: string; propositions: string[] }>(
'POST',
const challengeResponse = await this.http.post<{ question: string; propositions: string[] }>(
'/connexion/doubleauth.awp',
{},
{ verbe: 'get' }
Expand All @@ -111,7 +110,7 @@ export class WrapDirecte {

async directLogin(username: string, password: string, faProof: string, uuid: string = ''): Promise<LoginResult> {
const [cn, cv] = decodeBase64(faProof).split(':');
const response = await this.http.request<any>('POST', '/login.awp', {
const response = await this.http.post<any>('/login.awp', {
identifiant: username,
motdepasse: password,
isReLogin: false,
Expand All @@ -133,14 +132,13 @@ export class WrapDirecte {
throw new EcoleDirecteError('No pending login flow to submit 2FA for. Call login() first.');
}

const challengePostResponse = await this.http.request<{ cn: string; cv: string }>(
'POST',
const challengePostResponse = await this.http.post<{ cn: string; cv: string }>(
'/connexion/doubleauth.awp',
{ choix: encodeBase64(answer) },
{ verbe: 'post' }
);

const finalResponse = await this.http.request<any>('POST', '/login.awp', {
const finalResponse = await this.http.post<any>('/login.awp', {
identifiant: this.currentUsername,
motdepasse: this.currentPassword,
isReLogin: false,
Expand Down
7 changes: 2 additions & 5 deletions src/modules/AbsencesModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,8 @@ export interface CleanAbsence {

export class AbsencesModule extends BaseModule {
async getAbsences(options: BaseModuleOptions = {}): Promise<any> {
const response = await this.http.request<any>(
'POST',
`/eleves/${this.studentId}/viescolaire.awp`,
{},
{ verbe: 'get' }
const response = await this.http.get<any>(
`/eleves/${this.studentId}/viescolaire.awp`
);

if (options.raw) return response.data;
Expand Down
18 changes: 6 additions & 12 deletions src/modules/CloudModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ export interface CleanCloudNode {

export class CloudModule extends BaseModule {
async getCloudFiles(depth: number = 3, options: BaseModuleOptions = {}): Promise<CleanCloudNode[] | any> {
const response = await this.http.request<any>(
'POST',
const response = await this.http.post<any>(
`/cloud/E/${this.studentId}.awp`,
{ profondeur: depth },
{ verbe: 'get', v: this.apiVersion }
Expand All @@ -35,8 +34,7 @@ export class CloudModule extends BaseModule {
}

async createFolder(parentPath: string, folderName: string): Promise<any> {
const response = await this.http.request<any>(
'POST',
const response = await this.http.post<any>(
`/cloud/E/${this.studentId}.awp`,
{
parentNode: { id: parentPath, type: 'folder' },
Expand All @@ -49,8 +47,7 @@ export class CloudModule extends BaseModule {
}

async copyNodes(parentPath: string, nodes: any[]): Promise<any> {
const response = await this.http.request<any>(
'POST',
const response = await this.http.post<any>(
`/cloud/E/${this.studentId}.awp`,
{
parentNode: { id: parentPath, type: 'folder' },
Expand All @@ -62,8 +59,7 @@ export class CloudModule extends BaseModule {
}

async deleteNodes(nodes: any[]): Promise<any> {
const response = await this.http.request<any>(
'POST',
const response = await this.http.post<any>(
`/cloud/E/${this.studentId}/visibility.awp`,
{ tabNodes: nodes },
{ verbe: 'delete', v: this.apiVersion }
Expand All @@ -72,8 +68,7 @@ export class CloudModule extends BaseModule {
}

async restoreNodes(nodes: any[]): Promise<any> {
const response = await this.http.request<any>(
'POST',
const response = await this.http.post<any>(
`/cloud/E/${this.studentId}/visibility.awp`,
{ tabNodes: nodes },
{ verbe: 'post', v: this.apiVersion }
Expand All @@ -88,8 +83,7 @@ export class CloudModule extends BaseModule {
}

async exportToCloud(fileId: number, module: 'CAHIER_DE_TEXTES' | 'MESSAGERIE'): Promise<any> {
const response = await this.http.request<any>(
'POST',
const response = await this.http.post<any>(
'/exportToCloud.awp',
{},
{
Expand Down
3 changes: 1 addition & 2 deletions src/modules/DocumentsModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ export interface CleanDocument {

export class DocumentsModule extends BaseModule {
async getDocuments(options: BaseModuleOptions = {}): Promise<any> {
const response = await this.http.request<any>(
'POST',
const response = await this.http.post<any>(
'/elevesDocuments.awp',
{},
{ archive: '', verbe: 'get' }
Expand Down
3 changes: 1 addition & 2 deletions src/modules/GradesModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,7 @@ export class GradesModule extends BaseModule {
year: string = '',
options: BaseModuleOptions = {}
): Promise<CleanGradesResponse | any> {
const response = await this.http.request<any>(
'POST',
const response = await this.http.post<any>(
`/eleves/${this.studentId}/notes.awp`,
{ anneeScolaire: year },
{ verbe: 'get' }
Expand Down
9 changes: 3 additions & 6 deletions src/modules/HomeworkModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ export interface CleanComment {

export class HomeworkModule extends BaseModule {
async getHomework(date: string, options: BaseModuleOptions = {}): Promise<any> {
const response = await this.http.request<any>(
'POST',
const response = await this.http.post<any>(
`/Eleves/${this.studentId}/cahierdetexte/${date}.awp`,
{},
{ verbe: 'get' }
Expand Down Expand Up @@ -101,17 +100,15 @@ export class HomeworkModule extends BaseModule {
idDevoirsNonEffectues: isDone ? [] : [homeworkId],
};

await this.http.request(
'POST',
await this.http.post(
`/Eleves/${this.studentId}/cahierdetexte.awp`,
data,
{ verbe: 'put' }
);
}

async addComment(homeworkId: number, message: string): Promise<number> {
const response = await this.http.request<any>(
'POST',
const response = await this.http.post<any>(
`/Eleves/${this.studentId}/afaire/commentaires.awp`,
{
message: encodeBase64(message),
Expand Down
36 changes: 12 additions & 24 deletions src/modules/MessagingModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ export interface CleanAttachment {

export class MessagingModule extends BaseModule {
async getMessages(year: string, options: BaseModuleOptions = {}): Promise<any> {
const response = await this.http.request<any>(
'POST',
const response = await this.http.post<any>(
`/eleves/${this.studentId}/messages.awp`,
{ anneeMessages: year },
{ getAll: '1', verbe: 'get', v: this.apiVersion }
Expand Down Expand Up @@ -68,8 +67,7 @@ export class MessagingModule extends BaseModule {
}

async getMessagesByFolder(folderId: number, options: BaseModuleOptions = {}): Promise<any> {
const response = await this.http.request<any>(
'POST',
const response = await this.http.post<any>(
`/eleves/${this.studentId}/messages.awp`,
{},
{
Expand Down Expand Up @@ -101,8 +99,7 @@ export class MessagingModule extends BaseModule {
year: string,
options: BaseModuleOptions & { markAsUnread?: boolean } = {}
): Promise<any> {
const response = await this.http.request<any>(
'POST',
const response = await this.http.post<any>(
`/eleves/${this.studentId}/messages/${messageId}.awp`,
{ anneeMessages: year },
{ verbe: 'get', mode: 'destinataire', v: this.apiVersion }
Expand Down Expand Up @@ -160,8 +157,7 @@ export class MessagingModule extends BaseModule {
const now = new Date();
const formattedDate = now.toISOString().replace('T', ' ').split('.')[0];

const response = await this.http.request<any>(
'POST',
const response = await this.http.post<any>(
`/eleves/${this.studentId}/messages.awp`,
{
message: {
Expand Down Expand Up @@ -193,8 +189,7 @@ export class MessagingModule extends BaseModule {
}

async getContacts(type: 'professeurs' | 'personnels' | 'entreprises'): Promise<any[]> {
const response = await this.http.request<any>(
'POST',
const response = await this.http.post<any>(
`/messagerie/contacts/${type}.awp`,
{},
{ verbe: 'get', v: this.apiVersion }
Expand All @@ -203,8 +198,7 @@ export class MessagingModule extends BaseModule {
}

async markAsRead(ids: number[], year: string): Promise<void> {
await this.http.request(
'POST',
await this.http.post(
`/eleves/${this.studentId}/messages.awp`,
{
action: 'marquerCommeLu',
Expand All @@ -216,8 +210,7 @@ export class MessagingModule extends BaseModule {
}

async markAsUnread(ids: number[], year: string): Promise<void> {
await this.http.request(
'POST',
await this.http.post(
`/eleves/${this.studentId}/messages.awp`,
{
action: 'marquerCommeNonLu',
Expand All @@ -229,8 +222,7 @@ export class MessagingModule extends BaseModule {
}

async archiveMessages(ids: number[], year: string): Promise<void> {
await this.http.request(
'POST',
await this.http.post(
`/eleves/${this.studentId}/messages.awp`,
{
action: 'archiver',
Expand All @@ -242,8 +234,7 @@ export class MessagingModule extends BaseModule {
}

async unarchiveMessages(ids: number[], year: string): Promise<void> {
await this.http.request(
'POST',
await this.http.post(
`/eleves/${this.studentId}/messages.awp`,
{
action: 'desarchiver',
Expand All @@ -255,8 +246,7 @@ export class MessagingModule extends BaseModule {
}

async moveMessages(ids: number[], folderId: number): Promise<void> {
await this.http.request(
'POST',
await this.http.post(
`/eleves/${this.studentId}/messages.awp`,
{
action: 'deplacer',
Expand All @@ -268,8 +258,7 @@ export class MessagingModule extends BaseModule {
}

async createFolder(name: string): Promise<number> {
const response = await this.http.request<any>(
'POST',
const response = await this.http.post<any>(
'/messagerie/classeurs.awp',
{ libelle: name },
{ verbe: 'post', v: this.apiVersion }
Expand All @@ -278,8 +267,7 @@ export class MessagingModule extends BaseModule {
}

async deleteFolder(folderId: number): Promise<void> {
await this.http.request(
'POST',
await this.http.post(
`/messagerie/classeur/${folderId}.awp`,
{},
{ verbe: 'delete', v: this.apiVersion }
Expand Down
9 changes: 3 additions & 6 deletions src/modules/SettingsModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import { BaseModule } from './BaseModule';

export class SettingsModule extends BaseModule {
async updateIndividualParam(value: string): Promise<void> {
await this.http.request(
'POST',
await this.http.post(
'/parametreIndividuel.awp',
{
path: `Préférences/Elèves/accessibiliteVisuelle/id_${this.studentId}`,
Expand All @@ -23,8 +22,7 @@ export class SettingsModule extends BaseModule {
reponse: string;
uuid?: string;
}): Promise<any> {
const response = await this.http.request<any>(
'POST',
const response = await this.http.post<any>(
`/logins/${this.studentLoginId}.awp`,
data,
{ verbe: 'put' }
Expand All @@ -34,8 +32,7 @@ export class SettingsModule extends BaseModule {

async getAccountSettings(idLogin?: number): Promise<any> {
const loginId = idLogin ?? this.studentLoginId;
const response = await this.http.request<any>(
'POST',
const response = await this.http.post<any>(
`/logins/${loginId}.awp`,
{},
{ verbe: 'get' }
Expand Down
6 changes: 2 additions & 4 deletions src/modules/TimelineModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ export interface CleanPostIt {

export class TimelineModule extends BaseModule {
async getStudentTimeline(options: BaseModuleOptions = {}): Promise<any> {
const response = await this.http.request<any>(
'POST',
const response = await this.http.post<any>(
`/eleves/${this.studentId}/timeline.awp`,
{},
{ verbe: 'get' }
Expand All @@ -52,8 +51,7 @@ export class TimelineModule extends BaseModule {
}

async getCommonTimeline(options: BaseModuleOptions = {}): Promise<any> {
const response = await this.http.request<any>(
'POST',
const response = await this.http.post<any>(
`/E/${this.studentId}/timelineAccueilCommun.awp`,
{},
{ verbe: 'get' }
Expand Down
6 changes: 2 additions & 4 deletions src/modules/TimetableModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ export interface CleanCourse {

export class TimetableModule extends BaseModule {
async getTimetable(startDate: string, endDate: string, options: BaseModuleOptions = {}): Promise<any> {
const response = await this.http.request<any>(
'POST',
const response = await this.http.post<any>(
`/E/${this.studentId}/emploidutemps.awp`,
{
dateDebut: startDate,
Expand Down Expand Up @@ -58,8 +57,7 @@ export class TimetableModule extends BaseModule {
}

async getIcalUrl(): Promise<string> {
const response = await this.http.request<{ url: string }>(
'POST',
const response = await this.http.post<{ url: string }>(
`/ical/E/${this.studentId}/url.awp`,
{},
{ verbe: 'get' }
Expand Down
Loading