-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.ts
More file actions
59 lines (48 loc) · 1.74 KB
/
example.ts
File metadata and controls
59 lines (48 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import { WrapDirecte } from './src/index';
async function exampleUsage() {
const client = new WrapDirecte();
try {
// Login (this will require real credentials and may need 2FA)
const loginResult = await client.login('USERNAME', 'PASSWORD');
if (loginResult.status === '2FA_REQUIRED') {
console.log('2FA Required:', loginResult.challenge?.question);
console.log('Proposals:', loginResult.challenge?.proposals);
// In a real scenario, get user input for answer
// const answer = '...';
// await client.submit2FA(answer);
console.log('Skipping 2FA for demo purposes');
return;
}
// Get account info
const account = client.getAccount();
console.log('Logged in as:', account?.firstName, account?.lastName);
// Example: Get homework for a date
if (client.homework) {
const homework = await client.homework.getHomework('2026-04-08');
console.log('Homework:', homework);
}
// Example: Get grades
if (client.grades) {
const { grades, periods } = await client.grades.getGrades('2025-2026');
console.log('Grades:', grades.length, 'items');
console.log('Periods:', periods.length, 'periods');
}
// Example: Get timetable
if (client.timetable) {
const timetable = await client.timetable.getTimetable('2026-04-01', '2026-04-07');
console.log('Timetable:', timetable.length, 'courses');
}
// Example: Get absences
if (client.absences) {
const absences = await client.absences.getAbsences();
console.log('Absences:', absences.length, 'items');
}
// Logout
await client.logout();
console.log('Logged out');
} catch (error) {
console.error('Error:', error);
}
}
// Run the example
exampleUsage();