var AttendanceService = {}

/**
 * @return A set of session IDs
 */
/*
AttendanceService.getAttendingSessions = function(userId) {
}
*/

AttendanceService.markAttendance = function(sessionId, onOk) {
    new Ajax.Request(createLinkTo("/json/attendance/create"), {
        method: 'post',
        postBody: Object.toJSON({sessionId: sessionId}),
        contentType: "application/json",
        on201: function() {
            onOk()
        },
        on403: function(response) {
            window.location = response.getHeader("Location")
        }
    });
}

AttendanceService.unmarkAttendance = function(sessionId, onOk) {
    new Ajax.Request(createLinkTo("/json/attendance/delete"), {
        method: 'post',
        postBody: Object.toJSON({sessionId: sessionId}),
        contentType: "application/json",
        on200: function() {
            onOk()
        },
        on403: function(response) {
            window.location = response.getHeader("Location")
        }
    });
}

