list method

Future<List<Job>> list({
  1. List<JobScope>? scopes,
  2. int? page,
  3. int? perPage,
})

Implementation

Future<List<Job>> list(
    {List<JobScope>? scopes, int? page, int? perPage}) async {
  final queryParameters = <String, dynamic>{};

  if (scopes != null && scopes.isNotEmpty) {
    if (scopes.length == 1) {
      queryParameters['scope'] = _enumToString(scopes.first);
    } else {
      for (var i = 0; i < scopes.length; i++) {
        queryParameters['scope[$i]'] = _enumToString(scopes[i]);
      }
    }
  }

  final uri = _project.buildUri(['jobs'],
      queryParameters: queryParameters, page: page, perPage: perPage);
  final jsonList = _responseToList(await _gitLab.request(uri));

  return jsonList.map((json) => new Job.fromJson(json)).toList();
}