module api_modules.classroom_compliance.api;

import handy_httpd.handlers.path_handler : PathHandler;
import handy_httpd.components.request : Method;

import api_modules.classroom_compliance.api_class;
import api_modules.classroom_compliance.api_student;
import api_modules.classroom_compliance.api_entry;
import api_modules.classroom_compliance.api_export;

void registerApiEndpoints(PathHandler handler) {
    const ROOT_PATH = "/api/classroom-compliance";
    
    handler.addMapping(Method.POST, ROOT_PATH ~ "/classes", &createClass);
    handler.addMapping(Method.GET, ROOT_PATH ~ "/classes", &getClasses);
    const CLASS_PATH = ROOT_PATH ~ "/classes/:classId:ulong";
    handler.addMapping(Method.GET, CLASS_PATH, &getClass);
    handler.addMapping(Method.DELETE, CLASS_PATH, &deleteClass);
    handler.addMapping(Method.POST, CLASS_PATH ~ "/archived", &setArchived);
    handler.addMapping(Method.GET, CLASS_PATH ~ "/notes", &getClassNotes);
    handler.addMapping(Method.POST, CLASS_PATH ~ "/notes", &createClassNote);
    handler.addMapping(Method.DELETE, CLASS_PATH ~ "/notes/:noteId:ulong", &deleteClassNote);
    handler.addMapping(Method.PUT, CLASS_PATH ~ "/reset-desk-numbers", &resetStudentDesks);
    handler.addMapping(Method.PUT, CLASS_PATH ~ "/score-parameters", &updateScoreParameters);

    handler.addMapping(Method.POST, CLASS_PATH ~ "/students", &createStudent);
    handler.addMapping(Method.GET, CLASS_PATH ~ "/students", &getStudents);
    const STUDENT_PATH = CLASS_PATH ~ "/students/:studentId:ulong";
    handler.addMapping(Method.GET, STUDENT_PATH, &getStudent);
    handler.addMapping(Method.PUT, STUDENT_PATH, &updateStudent);
    handler.addMapping(Method.DELETE, STUDENT_PATH, &deleteStudent);
    handler.addMapping(Method.PUT, STUDENT_PATH ~ "/class", &moveStudentToOtherClass);
    handler.addMapping(Method.GET, STUDENT_PATH ~ "/entries", &getStudentEntries);
    handler.addMapping(Method.GET, STUDENT_PATH ~ "/overview", &getStudentOverview);
    handler.addMapping(Method.GET, STUDENT_PATH ~ "/labels", &getStudentLabels);
    handler.addMapping(Method.POST, STUDENT_PATH ~ "/labels", &updateStudentLabels);

    handler.addMapping(Method.GET, CLASS_PATH ~ "/entries", &getEntries);
    handler.addMapping(Method.POST, CLASS_PATH ~ "/entries", &saveEntries);

    handler.addMapping(Method.GET, ROOT_PATH ~ "/export", &getFullExport);
}