getTournamentResults method

Future<Iterable<TournamentTeamResults>> getTournamentResults(
  1. String tournamentId
)

Requests tournament results TournamentTeamResults from server.

Requires tournament identifier tournamentId. Returns tournament team results object TournamentTeamResults list in case of success or empty list if tournament results not found. Throws DioError in case of network connection problems.

Implementation

Future<Iterable<TournamentTeamResults>> getTournamentResults(
    String tournamentId) async {
  final int id = tournamentId.parseIdOrThrow;
  try {
    final Response<dynamic> response =
        await _dio.get('/tournaments.$extensionJson/$id/list');
    return (response.data as List<dynamic>)
        .map((dynamic e) => TournamentTeamResults.fromMap(e));
  } on DioError catch (e) {
    if (e.message.isNotFoundError) {
      return <TournamentTeamResults>[];
    } else {
      rethrow;
    }
  }
}