getParticipations method

dynamic getParticipations(
  1. int year,
  2. num weeknumber, {
  3. dynamic user = "~me",
})

Implementation

getParticipations(int year, num weeknumber, {user = "~me"}) async {
  if (weeknumber <= 52 && weeknumber >= 1) {
    final response = await http.get(ZermeloUtil.createApiURL(
        this.school,
        "appointmentparticipations?student=$user&week=$year${weeknumber.round()}&fields=id,appointmentInstance,studentInDepartment,optional,studentEnrolled,attendanceParticipationCoordinator,plannedAttendance,realizedAttendance,publicComment,start,end,subjects,teachers,locations,groups,schedulerRemark,changeDescription,startTimeSlotName,endTimeSlotName,allowedStudentActions,availableSpace,cancelled,appointmentType,content",
        this.accessToken));
    if (response.statusCode == 200) {
      return json
          .decode(response.body)
          .map(
              (appointment) => Appointment.fromJson(json.decode(appointment)))
          .toList()
          .sort((a, b) => a.start.compareTo(b.start));
    } else {
      throw Exception('Failed to load appointments');
    }
  } else
    throw Exception('Weeknumber must be between 1-52');
}