get method

Future<List> get(
  1. DateTime startDate,
  2. DateTime endDate, {
  3. dynamic user = "~me",
})

Implementation

Future<List> get(DateTime startDate, DateTime endDate, {user = "~me"}) async {
  final response = await http.get(ZermeloUtil.createApiURL(
      this.school,
      "appointments?user=$user&start=${(startDate.millisecondsSinceEpoch / 1000).round()}&end=${(endDate.millisecondsSinceEpoch / 1000).round()}",
      this.accessToken));
  if (response.statusCode == 200) {
    return json
        .decode(response.body)['response']['data']
        .map((appointment) => Appointment.fromJson(appointment))
        .toList();
  } else {
    print(
        "Server returned with an error ${response.statusCode} (${response.body})");
    throw Exception('Failed to load appointments');
  }
}