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 |
|
---|
18 | namespace Google\Service\Games\Resource;
|
---|
19 |
|
---|
20 | use Google\Service\Games\LeaderboardScores;
|
---|
21 | use Google\Service\Games\PlayerLeaderboardScoreListResponse;
|
---|
22 | use Google\Service\Games\PlayerScoreListResponse;
|
---|
23 | use Google\Service\Games\PlayerScoreResponse;
|
---|
24 | use 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 | */
|
---|
34 | class 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 | * @throws \Google\Service\Exception
|
---|
61 | */
|
---|
62 | public function get($playerId, $leaderboardId, $timeSpan, $optParams = [])
|
---|
63 | {
|
---|
64 | $params = ['playerId' => $playerId, 'leaderboardId' => $leaderboardId, 'timeSpan' => $timeSpan];
|
---|
65 | $params = array_merge($params, $optParams);
|
---|
66 | return $this->call('get', [$params], PlayerLeaderboardScoreListResponse::class);
|
---|
67 | }
|
---|
68 | /**
|
---|
69 | * Lists the scores in a leaderboard, starting from the top. (scores.listScores)
|
---|
70 | *
|
---|
71 | * @param string $leaderboardId The ID of the leaderboard.
|
---|
72 | * @param string $collection The collection of scores you're requesting.
|
---|
73 | * @param string $timeSpan Required. The time span for the scores and ranks
|
---|
74 | * you're requesting.
|
---|
75 | * @param array $optParams Optional parameters.
|
---|
76 | *
|
---|
77 | * @opt_param string language The preferred language to use for strings returned
|
---|
78 | * by this method.
|
---|
79 | * @opt_param int maxResults The maximum number of leaderboard scores to return
|
---|
80 | * in the response. For any response, the actual number of leaderboard scores
|
---|
81 | * returned may be less than the specified `maxResults`.
|
---|
82 | * @opt_param string pageToken The token returned by the previous request.
|
---|
83 | * @return LeaderboardScores
|
---|
84 | * @throws \Google\Service\Exception
|
---|
85 | */
|
---|
86 | public function listScores($leaderboardId, $collection, $timeSpan, $optParams = [])
|
---|
87 | {
|
---|
88 | $params = ['leaderboardId' => $leaderboardId, 'collection' => $collection, 'timeSpan' => $timeSpan];
|
---|
89 | $params = array_merge($params, $optParams);
|
---|
90 | return $this->call('list', [$params], LeaderboardScores::class);
|
---|
91 | }
|
---|
92 | /**
|
---|
93 | * Lists the scores in a leaderboard around (and including) a player's score.
|
---|
94 | * (scores.listWindow)
|
---|
95 | *
|
---|
96 | * @param string $leaderboardId The ID of the leaderboard.
|
---|
97 | * @param string $collection The collection of scores you're requesting.
|
---|
98 | * @param string $timeSpan Required. The time span for the scores and ranks
|
---|
99 | * you're requesting.
|
---|
100 | * @param array $optParams Optional parameters.
|
---|
101 | *
|
---|
102 | * @opt_param string language The preferred language to use for strings returned
|
---|
103 | * by this method.
|
---|
104 | * @opt_param int maxResults The maximum number of leaderboard scores to return
|
---|
105 | * in the response. For any response, the actual number of leaderboard scores
|
---|
106 | * returned may be less than the specified `maxResults`.
|
---|
107 | * @opt_param string pageToken The token returned by the previous request.
|
---|
108 | * @opt_param int resultsAbove The preferred number of scores to return above
|
---|
109 | * the player's score. More scores may be returned if the player is at the
|
---|
110 | * bottom of the leaderboard; fewer may be returned if the player is at the top.
|
---|
111 | * Must be less than or equal to maxResults.
|
---|
112 | * @opt_param bool returnTopIfAbsent True if the top scores should be returned
|
---|
113 | * when the player is not in the leaderboard. Defaults to true.
|
---|
114 | * @return LeaderboardScores
|
---|
115 | * @throws \Google\Service\Exception
|
---|
116 | */
|
---|
117 | public function listWindow($leaderboardId, $collection, $timeSpan, $optParams = [])
|
---|
118 | {
|
---|
119 | $params = ['leaderboardId' => $leaderboardId, 'collection' => $collection, 'timeSpan' => $timeSpan];
|
---|
120 | $params = array_merge($params, $optParams);
|
---|
121 | return $this->call('listWindow', [$params], LeaderboardScores::class);
|
---|
122 | }
|
---|
123 | /**
|
---|
124 | * Submits a score to the specified leaderboard. (scores.submit)
|
---|
125 | *
|
---|
126 | * @param string $leaderboardId The ID of the leaderboard.
|
---|
127 | * @param string $score Required. The score you're submitting. The submitted
|
---|
128 | * score is ignored if it is worse than a previously submitted score, where
|
---|
129 | * worse depends on the leaderboard sort order. The meaning of the score value
|
---|
130 | * depends on the leaderboard format type. For fixed-point, the score represents
|
---|
131 | * the raw value. For time, the score represents elapsed time in milliseconds.
|
---|
132 | * For currency, the score represents a value in micro units.
|
---|
133 | * @param array $optParams Optional parameters.
|
---|
134 | *
|
---|
135 | * @opt_param string language The preferred language to use for strings returned
|
---|
136 | * by this method.
|
---|
137 | * @opt_param string scoreTag Additional information about the score you're
|
---|
138 | * submitting. Values must contain no more than 64 URI-safe characters as
|
---|
139 | * defined by section 2.3 of RFC 3986.
|
---|
140 | * @return PlayerScoreResponse
|
---|
141 | * @throws \Google\Service\Exception
|
---|
142 | */
|
---|
143 | public function submit($leaderboardId, $score, $optParams = [])
|
---|
144 | {
|
---|
145 | $params = ['leaderboardId' => $leaderboardId, 'score' => $score];
|
---|
146 | $params = array_merge($params, $optParams);
|
---|
147 | return $this->call('submit', [$params], PlayerScoreResponse::class);
|
---|
148 | }
|
---|
149 | /**
|
---|
150 | * Submits multiple scores to leaderboards. (scores.submitMultiple)
|
---|
151 | *
|
---|
152 | * @param PlayerScoreSubmissionList $postBody
|
---|
153 | * @param array $optParams Optional parameters.
|
---|
154 | *
|
---|
155 | * @opt_param string language The preferred language to use for strings returned
|
---|
156 | * by this method.
|
---|
157 | * @return PlayerScoreListResponse
|
---|
158 | * @throws \Google\Service\Exception
|
---|
159 | */
|
---|
160 | public function submitMultiple(PlayerScoreSubmissionList $postBody, $optParams = [])
|
---|
161 | {
|
---|
162 | $params = ['postBody' => $postBody];
|
---|
163 | $params = array_merge($params, $optParams);
|
---|
164 | return $this->call('submitMultiple', [$params], PlayerScoreListResponse::class);
|
---|
165 | }
|
---|
166 | }
|
---|
167 |
|
---|
168 | // Adding a class alias for backwards compatibility with the previous class name.
|
---|
169 | class_alias(Scores::class, 'Google_Service_Games_Resource_Scores');
|
---|