-
-
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.
docs(discussions): add a list example
- Loading branch information
Showing
1 changed file
with
24 additions
and
0 deletions.
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,24 @@ | ||
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" | ||
}); | ||
|
||
// Get an overview of available discussions. | ||
const discussionsOverview = await pronote.getDiscussionsOverview(); | ||
// Select the first discussion available. | ||
const firstDiscussion = discussionsOverview.discussions[0]; | ||
|
||
// Fetch the messages overview from the discussion. | ||
// You need to fetch the overview in order to send a message. | ||
const messagesOverview = await firstDiscussion.fetchMessagesOverview(); | ||
console.info(firstDiscussion.subject); | ||
console.log("Currently containing", messagesOverview.messages.length, "message(s)..."); | ||
})(); | ||
|