getTeamRatingById method

Future<TeamRating?> getTeamRatingById(
  1. String teamId,
  2. int releaseId
)

Requests team rating TeamRating from server.

Requires team identifier teamId and release identifier releaseId. Returns team rating object TeamRating in case of success or Null if team rating not found. Throws DioError in case of network connection problems.

Implementation

Future<TeamRating?> getTeamRatingById(String teamId, int releaseId) async {
  final int id = teamId.parseIdOrThrow;
  try {
    final Response<dynamic> response =
        await _dio.get('/teams.$extensionJson/$id/rating/$releaseId');
    if (response.data is Iterable) {
      return null;
    } else {
      return TeamRating.fromMap(response.data);
    }
  } on DioError catch (e) {
    if (e.message.isNotFoundError) {
      return null;
    } else {
      rethrow;
    }
  }
}