getTask method

  1. @override
Future<MoodleTask> getTask(
  1. String token,
  2. int id
)
override

Gets a single task by its id.

Implementation

@override
Future<MoodleTask> getTask(String token, int id) async {
  log('Fetching task with id $id');

  try {
    final response = await _apiService.callFunction(
      token: token,
      function: 'local_lbplanner_modules_get_module',
      body: {
        'moduleid': id,
      },
    );

    response.assertJson();

    log('Fetched task with id $id');

    return MoodleTask.fromJson(response.asJson);
  } catch (e, s) {
    log('Failed to fetch task with id $id', e, s);
    rethrow;
  }
}