From a5ec1c28921539937db3ed22f283a3b46545e17a Mon Sep 17 00:00:00 2001 From: Mikkel RINGAUD Date: Sun, 28 Apr 2024 19:11:18 +0200 Subject: [PATCH] docs(discussions): add a list example --- examples/discussions/list.ts | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 examples/discussions/list.ts diff --git a/examples/discussions/list.ts b/examples/discussions/list.ts new file mode 100644 index 0000000..ad09215 --- /dev/null +++ b/examples/discussions/list.ts @@ -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)..."); +})(); +