1
0
Fork 0
mirror of https://github.com/classchartsapi/classcharts-api-js.git synced 2026-05-14 11:58:13 +00:00

Add listAnnoucements

This commit is contained in:
ZelrDev 2022-02-06 15:14:48 +00:00
parent 114c3d86c6
commit 685dddbcc7
2 changed files with 42 additions and 1 deletions

View file

@ -2,6 +2,7 @@ import Undici from "undici";
import { RequestOptions } from "undici/types/dispatcher"; import { RequestOptions } from "undici/types/dispatcher";
import { import {
ActivityResponse, ActivityResponse,
AnnoucementsResponse,
BadgesResponse, BadgesResponse,
BehaviourResponse, BehaviourResponse,
DetentionsResponse, DetentionsResponse,
@ -208,6 +209,18 @@ export class ClasschartsClient {
} }
); );
} }
/**
* Lists the logged in student's annoucements
* @returns Array of annoucements
*/
async listAnnoucements(): Promise<AnnoucementsResponse> {
return await this.makeAuthedRequest(
API_BASE + "/annoucements/" + this.studentId,
{
method: "GET",
}
);
}
/** /**
* Gets the logged in student's detentions * Gets the logged in student's detentions
* @returns Array of detentions * @returns Array of detentions

View file

@ -249,4 +249,32 @@ export interface Detention {
name: string; name: string;
}; };
} }
export type DetentionsResponse = Array<Detention>; export type DetentionsResponse = Array<Detention>;
export interface Annoucement {
id: number;
title: string;
description: string | null;
school_name: string;
teacher_name: string;
school_logo: string | null;
sticky: "yes" | "no";
state: string | null;
timestamp: string;
attachments: Array<{
filename: string;
url: string;
}>;
for_pupils: Array<any>;
comment_visibility: string;
allow_comments: "yes" | "no";
allow_reactions: "yes" | "no";
allow_consent: "yes" | "no";
priority_pinned: "yes" | "no";
requires_consent: "yes" | "no";
can_change_consent: boolean;
consent: string | null;
pupil_consents: Array<any>;
}
export type AnnoucementsResponse = Array<Annoucement>