-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implement
holidays
on instance
- Loading branch information
Showing
4 changed files
with
60 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { authenticatePronoteCredentials, PronoteApiAccountId } from "../src"; | ||
|
||
(async () => { | ||
const pronote = await authenticatePronoteCredentials("https://pronote-vm.dev/pronote", { | ||
accountTypeID: PronoteApiAccountId.Student, | ||
username: "lisa.boulanger", // using my VM credentials here because the demo instance doesn't have any messages. | ||
password: "12345678", | ||
|
||
// Because this is just an example, don't forget to change this. | ||
deviceUUID: "my-device-uuid" | ||
}); | ||
|
||
for (const holiday of pronote.holidays) { | ||
console.info("=>", holiday.name); | ||
console.info("Starts", holiday.start.toLocaleDateString(), "until", holiday.end.toLocaleDateString()); | ||
} | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { PronoteApiLoginInformations } from "~/api"; | ||
import { readPronoteApiDate } from "~/pronote/dates"; | ||
|
||
class Holiday { | ||
readonly #id: string; | ||
readonly #name: string; | ||
|
||
readonly #start: Date; | ||
readonly #end: Date; | ||
|
||
constructor (data: PronoteApiLoginInformations["response"]["donnees"]["General"]["listeJoursFeries"]["V"][number]) { | ||
this.#id = data.N; | ||
this.#name = data.L; | ||
|
||
this.#start = readPronoteApiDate(data.dateDebut.V); | ||
this.#end = readPronoteApiDate(data.dateFin.V); | ||
} | ||
|
||
public get id (): string { | ||
return this.#id; | ||
} | ||
|
||
public get name (): string { | ||
return this.#name; | ||
} | ||
|
||
public get start (): Date { | ||
return this.#start; | ||
} | ||
|
||
public get end (): Date { | ||
return this.#end; | ||
} | ||
} | ||
|
||
export default Holiday; |