All files / src/api/teacher TeacherClassAPI.js

75% Statements 18/24
100% Branches 2/2
75% Functions 9/12
75% Lines 18/24

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67          7x 6x       3x 2x       3x 2x       4x 3x                                     27x 2x       2x 2x       3x 2x       2x     2x       3x 2x      
import axios from "axios";
import { API_ENDPOINTS } from "@/api/endpoints";
 
export class TeacherClassAPI {
    async fetchAllClasses(query) {
        const response = await axios.get(`${API_ENDPOINTS.teacher.class.fetchAll}${query ?? ""}`);
        return response;
    }
 
    async createNewClass(payload) {
        const response = await axios.post(API_ENDPOINTS.teacher.class.create, payload);
        return response;
    }
 
    async deleteClass(classUUID) {
        const response = await axios.delete(API_ENDPOINTS.teacher.class.delete(classUUID));
        return response;
    }
 
    async updateClass(classUUID, classDetails) {
        const response = await axios.put(API_ENDPOINTS.teacher.class.update(classUUID), classDetails);
        return response;
    }
 
    async addClassPhoto(classUUID, imageFile) {
        const response = await axios.post(API_ENDPOINTS.teacher.class.photo.add(classUUID), imageFile);
        return response;
    }
 
    async updateClassPhoto(classUUID, imageFile) {
        const response = await axios.patch(API_ENDPOINTS.teacher.class.photo.update(classUUID), imageFile);
        return response;
    }
 
    async deleteClassPhoto(classUUID) {
        const response = await axios.delete(API_ENDPOINTS.teacher.class.photo.delete(classUUID));
        return response;
    }
 
    async fetchSpecificClassByCode(classCode) {
        const response = await axios.get(API_ENDPOINTS.teacher.class.find(classCode));
        return response;
    }
 
    async fetchClassRoster(classID) {
        const response = await axios.get(API_ENDPOINTS.teacher.class.roster.fetch(classID));
        return response;
    }
 
    async acceptStudent(classID, studentID) {
        const response = await axios.patch(API_ENDPOINTS.teacher.class.student.accept(classID, studentID));
        return response;
    }
 
    async approveLeave(classID, studentID) {
        const response = await axios.patch(API_ENDPOINTS.teacher.class.student.leaveApproved(classID, studentID), {
            is_granted: true,
        });
        return response;
    }
 
    async removeStudent(classID, studentID) {
        const response = await axios.delete(API_ENDPOINTS.teacher.class.student.remove(classID, studentID));
        return response;
    }
}