submit method

Future<PlayerScoreResponse> submit(
  1. String leaderboardId,
  2. String score, {
  3. String? language,
  4. String? scoreTag,
  5. String? $fields,
})

Submits a score to the specified leaderboard.

Request parameters:

leaderboardId - The ID of the leaderboard.

score - Required. The score you're submitting. The submitted score is ignored if it is worse than a previously submitted score, where worse depends on the leaderboard sort order. The meaning of the score value depends on the leaderboard format type. For fixed-point, the score represents the raw value. For time, the score represents elapsed time in milliseconds. For currency, the score represents a value in micro units.

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

scoreTag - Additional information about the score you're submitting. Values must contain no more than 64 URI-safe characters as defined by section 2.3 of RFC 3986. Value must have pattern \[a-zA-Z0-9-._~\]{0,64}.

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

Completes with a PlayerScoreResponse.

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<PlayerScoreResponse> submit(
  core.String leaderboardId,
  core.String score, {
  core.String? language,
  core.String? scoreTag,
  core.String? $fields,
}) async {
  final queryParams_ = <core.String, core.List<core.String>>{
    'score': [score],
    if (language != null) 'language': [language],
    if (scoreTag != null) 'scoreTag': [scoreTag],
    if ($fields != null) 'fields': [$fields],
  };

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

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