1<?php
2/*
3 * Copyright 2014 Google Inc.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
6 * use this file except in compliance with the License. You may obtain a copy of
7 * the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14 * License for the specific language governing permissions and limitations under
15 * the License.
16 */
17
18namespace Google\Service\Games\Resource;
19
20use Google\Service\Games\LeaderboardScores;
21use Google\Service\Games\PlayerLeaderboardScoreListResponse;
22use Google\Service\Games\PlayerScoreListResponse;
23use Google\Service\Games\PlayerScoreResponse;
24use Google\Service\Games\PlayerScoreSubmissionList;
25
26/**
27 * The "scores" collection of methods.
28 * Typical usage is:
29 *  <code>
30 *   $gamesService = new Google\Service\Games(...);
31 *   $scores = $gamesService->scores;
32 *  </code>
33 */
34class Scores extends \Google\Service\Resource
35{
36  /**
37   * Get high scores, and optionally ranks, in leaderboards for the currently
38   * authenticated player. For a specific time span, `leaderboardId` can be set to
39   * `ALL` to retrieve data for all leaderboards in a given time span. `NOTE: You
40   * cannot ask for 'ALL' leaderboards and 'ALL' timeSpans in the same request;
41   * only one parameter may be set to 'ALL'. (scores.get)
42   *
43   * @param string $playerId A player ID. A value of `me` may be used in place of
44   * the authenticated player's ID.
45   * @param string $leaderboardId The ID of the leaderboard. Can be set to 'ALL'
46   * to retrieve data for all leaderboards for this application.
47   * @param string $timeSpan The time span for the scores and ranks you're
48   * requesting.
49   * @param array $optParams Optional parameters.
50   *
51   * @opt_param string includeRankType The types of ranks to return. If the
52   * parameter is omitted, no ranks will be returned.
53   * @opt_param string language The preferred language to use for strings returned
54   * by this method.
55   * @opt_param int maxResults The maximum number of leaderboard scores to return
56   * in the response. For any response, the actual number of leaderboard scores
57   * returned may be less than the specified `maxResults`.
58   * @opt_param string pageToken The token returned by the previous request.
59   * @return PlayerLeaderboardScoreListResponse
60   */
61  public function get($playerId, $leaderboardId, $timeSpan, $optParams = [])
62  {
63    $params = ['playerId' => $playerId, 'leaderboardId' => $leaderboardId, 'timeSpan' => $timeSpan];
64    $params = array_merge($params, $optParams);
65    return $this->call('get', [$params], PlayerLeaderboardScoreListResponse::class);
66  }
67  /**
68   * Lists the scores in a leaderboard, starting from the top. (scores.listScores)
69   *
70   * @param string $leaderboardId The ID of the leaderboard.
71   * @param string $collection The collection of scores you're requesting.
72   * @param string $timeSpan The time span for the scores and ranks you're
73   * requesting.
74   * @param array $optParams Optional parameters.
75   *
76   * @opt_param string language The preferred language to use for strings returned
77   * by this method.
78   * @opt_param int maxResults The maximum number of leaderboard scores to return
79   * in the response. For any response, the actual number of leaderboard scores
80   * returned may be less than the specified `maxResults`.
81   * @opt_param string pageToken The token returned by the previous request.
82   * @return LeaderboardScores
83   */
84  public function listScores($leaderboardId, $collection, $timeSpan, $optParams = [])
85  {
86    $params = ['leaderboardId' => $leaderboardId, 'collection' => $collection, 'timeSpan' => $timeSpan];
87    $params = array_merge($params, $optParams);
88    return $this->call('list', [$params], LeaderboardScores::class);
89  }
90  /**
91   * Lists the scores in a leaderboard around (and including) a player's score.
92   * (scores.listWindow)
93   *
94   * @param string $leaderboardId The ID of the leaderboard.
95   * @param string $collection The collection of scores you're requesting.
96   * @param string $timeSpan The time span for the scores and ranks you're
97   * requesting.
98   * @param array $optParams Optional parameters.
99   *
100   * @opt_param string language The preferred language to use for strings returned
101   * by this method.
102   * @opt_param int maxResults The maximum number of leaderboard scores to return
103   * in the response. For any response, the actual number of leaderboard scores
104   * returned may be less than the specified `maxResults`.
105   * @opt_param string pageToken The token returned by the previous request.
106   * @opt_param int resultsAbove The preferred number of scores to return above
107   * the player's score. More scores may be returned if the player is at the
108   * bottom of the leaderboard; fewer may be returned if the player is at the top.
109   * Must be less than or equal to maxResults.
110   * @opt_param bool returnTopIfAbsent True if the top scores should be returned
111   * when the player is not in the leaderboard. Defaults to true.
112   * @return LeaderboardScores
113   */
114  public function listWindow($leaderboardId, $collection, $timeSpan, $optParams = [])
115  {
116    $params = ['leaderboardId' => $leaderboardId, 'collection' => $collection, 'timeSpan' => $timeSpan];
117    $params = array_merge($params, $optParams);
118    return $this->call('listWindow', [$params], LeaderboardScores::class);
119  }
120  /**
121   * Submits a score to the specified leaderboard. (scores.submit)
122   *
123   * @param string $leaderboardId The ID of the leaderboard.
124   * @param string $score The score you're submitting. The submitted score is
125   * ignored if it is worse than a previously submitted score, where worse depends
126   * on the leaderboard sort order. The meaning of the score value depends on the
127   * leaderboard format type. For fixed-point, the score represents the raw value.
128   * For time, the score represents elapsed time in milliseconds. For currency,
129   * the score represents a value in micro units.
130   * @param array $optParams Optional parameters.
131   *
132   * @opt_param string language The preferred language to use for strings returned
133   * by this method.
134   * @opt_param string scoreTag Additional information about the score you're
135   * submitting. Values must contain no more than 64 URI-safe characters as
136   * defined by section 2.3 of RFC 3986.
137   * @return PlayerScoreResponse
138   */
139  public function submit($leaderboardId, $score, $optParams = [])
140  {
141    $params = ['leaderboardId' => $leaderboardId, 'score' => $score];
142    $params = array_merge($params, $optParams);
143    return $this->call('submit', [$params], PlayerScoreResponse::class);
144  }
145  /**
146   * Submits multiple scores to leaderboards. (scores.submitMultiple)
147   *
148   * @param PlayerScoreSubmissionList $postBody
149   * @param array $optParams Optional parameters.
150   *
151   * @opt_param string language The preferred language to use for strings returned
152   * by this method.
153   * @return PlayerScoreListResponse
154   */
155  public function submitMultiple(PlayerScoreSubmissionList $postBody, $optParams = [])
156  {
157    $params = ['postBody' => $postBody];
158    $params = array_merge($params, $optParams);
159    return $this->call('submitMultiple', [$params], PlayerScoreListResponse::class);
160  }
161}
162
163// Adding a class alias for backwards compatibility with the previous class name.
164class_alias(Scores::class, 'Google_Service_Games_Resource_Scores');
165