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

Merge pull request #2 from ZelrDev/main

Add annoucements
This commit is contained in:
James Cook 2022-02-06 15:19:14 +00:00 committed by GitHub
commit 5fdd84622e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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 {
ActivityResponse,
AnnoucementsResponse,
BadgesResponse,
BehaviourResponse,
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
* @returns Array of detentions

View file

@ -249,4 +249,32 @@ export interface Detention {
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>