import { BaseController } from "./base-controller"; import type { ClassDTO } from "@dwengo-1/common/interfaces/class"; import type { StudentsResponse } from "./students"; import type { AssignmentsResponse } from "./assignments"; import type { TeachersResponse } from "@/controllers/teachers.ts"; import type { TeacherInvitationsResponse } from "@/controllers/teacher-invitations.ts"; export interface ClassesResponse { classes: ClassDTO[] | string[]; } export interface ClassResponse { class: ClassDTO; } export class ClassController extends BaseController { constructor() { super("class"); } async getAll(full = true): Promise { return this.get(`/`, { full }); } async getById(id: string): Promise { return this.get(`/${id}`); } async createClass(data: ClassDTO): Promise { return this.post(`/`, data); } async deleteClass(id: string): Promise { return this.delete(`/${id}`); } async updateClass(id: string, data: Partial): Promise { return this.put(`/${id}`, data); } async getStudents(id: string, full = true): Promise { return this.get(`/${id}/students`, { full }); } async addStudent(id: string, username: string): Promise { return this.post(`/${id}/students`, { username }); } async deleteStudent(id: string, username: string): Promise { return this.delete(`/${id}/students/${username}`); } async getTeachers(id: string, full = true): Promise { return this.get(`/${id}/teachers`, { full }); } async addTeacher(id: string, username: string): Promise { return this.post(`/${id}/teachers`, { username }); } async deleteTeacher(id: string, username: string): Promise { return this.delete(`/${id}/teachers/${username}`); } async getTeacherInvitations(id: string, full = true): Promise { return this.get(`/${id}/teacher-invitations`, { full }); } async getAssignments(id: string, full = true): Promise { return this.get(`/${id}/assignments`, { full }); } }