chgk_rating 1.0.2 copy "chgk_rating: ^1.0.2" to clipboard
chgk_rating: ^1.0.2 copied to clipboard

Dart wrapper client for the competitive What? Where? When? rating WebAPIRating https://api.rating.chgk.net/

example/chgk_rating.dart

import 'package:chgk_rating/chgk_rating.dart';
import 'package:chgk_rating/src/models/token_response.dart';

/// This example shows how to fetch [Player] data with additional information
Future<void> main() async {
  final ChgkRating chgkRating = ChgkRating();

  /// Search for the player by [name] and [surname]
  final Iterable<Player> playerSearch =
      await chgkRating.getPlayerBy(name: 'Денис', surname: 'Куценко');
  print('PlayerSearch data: $playerSearch');

  if (playerSearch.isNotEmpty) {
    final Player player = playerSearch.first;
    print('Player data: $player');
    final int playerId = player.id;

    /// Fetch player's teams
    final Iterable<PlayerTeam> playerTeamList =
        await chgkRating.getPlayerTeamList(playerId);
    print('PlayerTeam list data: $playerTeamList');
    final int teamId =
        playerTeamList.isNotEmpty ? playerTeamList.first.idTeam : 58380;

    /// Fetch player's tournaments for the last season
    final Iterable<PlayerTournament> playerTournamentResponse =
        await chgkRating.getPlayerTournamentList(playerId);
    print('PlayerTournamentResponse data: $playerTournamentResponse');
    final int tournamentId = playerTournamentResponse.isNotEmpty
        ? playerTournamentResponse.first.idTournament
        : 5021;

    /// Fetch team data using [teamId]
    final Team team = await chgkRating.getTeamById(teamId);
    print('Team data: $team');

    /// Fetch tournament details by [tournamentId]
    final Tournament tournamentDetails =
        await chgkRating.getTournamentDetails(tournamentId);
    print('TournamentDetails $tournamentDetails');

    /// Get user JWT token using email and password
    final TokenResponse? tokenResponse =
        await chgkRating.postToken('email@email.com', 'password');
    print('TokenResponse $tokenResponse');
  }
}
1
likes
150
points
90
downloads

Publisher

verified publishervmpay.eu

Weekly Downloads

Dart wrapper client for the competitive What? Where? When? rating WebAPIRating https://api.rating.chgk.net/

Repository (GitHub)
View/report issues

Documentation

API reference

License

Apache-2.0 (license)

Dependencies

collection, dio, meta, mockito

More

Packages that depend on chgk_rating