-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
29 lines (24 loc) · 946 Bytes
/
index.js
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
// utils
import RequestSession from "./utils/requests.js";
// objects
import Personalia from "./objects/personalia.js";
import AgendaWeek from "./objects/agena.js";
// Represents an authenticated osiris client
export default class Client {
constructor(token, baseURL="https://glr.osiris-student.nl") {
this.session = new RequestSession(token, baseURL);
}
changeToken(token) {
this.session.token = token
}
async getPersonalia() {
const request = await this.session.request("https://glr.osiris-student.nl/student/osiris/gebruiker", "GET");
return new Personalia(request.data);
}
async getAgenda(offset=0, limit=5) {
// adding url params.
let url = `/student/osiris/student/rooster/per_week?offset=${offset}&limit=${limit}`;
const request = await this.session.request(url, "GET");
return request.data.items.map(week => new AgendaWeek(week))
}
}