Skip to content

Commit

Permalink
docs(discussions): add a list example
Browse files Browse the repository at this point in the history
  • Loading branch information
Vexcited committed Apr 28, 2024
1 parent b00a90a commit a5ec1c2
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions examples/discussions/list.ts
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)...");
})();

0 comments on commit a5ec1c2

Please sign in to comment.