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:
parent
114c3d86c6
commit
685dddbcc7
2 changed files with 42 additions and 1 deletions
|
|
@ -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
|
||||
|
|
|
|||
28
src/types.ts
28
src/types.ts
|
|
@ -250,3 +250,31 @@ export interface 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>
|
||||
Loading…
Add table
Add a link
Reference in a new issue