getCourses method

  1. @override
Future<List<MoodleCourse>> getCourses(
  1. String token
)
override

Fetches all courses the user is enrolled in and that are compatible with the app.

Implementation

@override
Future<List<MoodleCourse>> getCourses(String token) async {
  try {
    final response = await _apiService.callFunction(
      token: token,
      function: 'local_lbplanner_courses_get_all_courses',
      body: {},
    );

    response.assertList();

    return response.asList.map(MoodleCourse.fromJson).toList();
  } catch (e, s) {
    log('Failed to fetch courses', e, s);
    rethrow;
  }
}