get method

Future<PlayerLeaderboardScoreListResponse> get(
  1. String playerId,
  2. String leaderboardId,
  3. String timeSpan, {
  4. String? includeRankType,
  5. String? language,
  6. int? maxResults,
  7. String? pageToken,
  8. String? $fields,
})

Get high scores, and optionally ranks, in leaderboards for the currently authenticated player.

For a specific time span, `leaderboardId` can be set to `ALL` to retrieve data for all leaderboards in a given time span. `NOTE: You cannot ask for 'ALL' leaderboards and 'ALL' timeSpans in the same request; only one parameter may be set to 'ALL'.

Request parameters:

playerId - A player ID. A value of me may be used in place of the authenticated player's ID.

leaderboardId - The ID of the leaderboard. Can be set to 'ALL' to retrieve data for all leaderboards for this application.

timeSpan - The time span for the scores and ranks you're requesting. Possible string values are:

  • "ALL" : Get the high scores for all time spans. If this is used, maxResults values will be ignored.
  • "ALL_TIME" : Get the all time high score.
  • "WEEKLY" : List the top scores for the current day.
  • "DAILY" : List the top scores for the current week.

includeRankType - The types of ranks to return. If the parameter is omitted, no ranks will be returned. Possible string values are:

  • "ALL" : Retrieve all supported ranks. In HTTP, this parameter value can also be specified as ALL.
  • "PUBLIC" : Retrieve public ranks, if the player is sharing their gameplay activity publicly.
  • "SOCIAL" : (Obsolete) Retrieve the social rank.
  • "FRIENDS" : Retrieve the rank on the friends collection.

language - The preferred language to use for strings returned by this method.

maxResults - The maximum number of leaderboard scores to return in the response. For any response, the actual number of leaderboard scores returned may be less than the specified maxResults.

pageToken - The token returned by the previous request.

$fields - Selector specifying which fields to include in a partial response.

Completes with a PlayerLeaderboardScoreListResponse.

Completes with a commons.ApiRequestError if the API endpoint returned an error.

If the used http.Client completes with an error when making a REST call, this method will complete with the same error.

Implementation

async.Future<PlayerLeaderboardScoreListResponse> get(
  core.String playerId,
  core.String leaderboardId,
  core.String timeSpan, {
  core.String? includeRankType,
  core.String? language,
  core.int? maxResults,
  core.String? pageToken,
  core.String? $fields,
}) async {
  final queryParams_ = <core.String, core.List<core.String>>{
    if (includeRankType != null) 'includeRankType': [includeRankType],
    if (language != null) 'language': [language],
    if (maxResults != null) 'maxResults': ['${maxResults}'],
    if (pageToken != null) 'pageToken': [pageToken],
    if ($fields != null) 'fields': [$fields],
  };

  final url_ = 'games/v1/players/' +
      commons.escapeVariable('$playerId') +
      '/leaderboards/' +
      commons.escapeVariable('$leaderboardId') +
      '/scores/' +
      commons.escapeVariable('$timeSpan');

  final response_ = await _requester.request(
    url_,
    'GET',
    queryParams: queryParams_,
  );
  return PlayerLeaderboardScoreListResponse.fromJson(
      response_ as core.Map<core.String, core.dynamic>);
}