/
achievements.clj
176 lines (150 loc) · 5.15 KB
/
achievements.clj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
(ns happygapi.games.achievements
"Google Play Game Services API: achievements.
The API for Google Play Game Services.
See: https://developers.google.com/games/services/api/reference/rest/v1/achievements"
(:require [cheshire.core :as json]
[clj-http.client :as http]
[happy.util :as util]))
(defn increment$
"https://developers.google.com/games/services/api/reference/rest/v1/achievements/increment
Required parameters: achievementId, stepsToIncrement
Optional parameters: requestId
Increments the steps of the achievement with the given ID for the currently authenticated player."
{:scopes ["https://www.googleapis.com/auth/games"]}
[auth parameters]
{:pre [(util/has-keys?
parameters
#{:achievementId :stepsToIncrement})]}
(util/get-response
(http/post
(util/get-url
"https://www.googleapis.com/games/v1/"
"achievements/{achievementId}/increment"
#{:achievementId :stepsToIncrement}
parameters)
(merge-with
merge
{:throw-exceptions false,
:query-params parameters,
:accept :json,
:as :json}
auth))))
(defn list$
"https://developers.google.com/games/services/api/reference/rest/v1/achievements/list
Required parameters: playerId
Optional parameters: language, maxResults, pageToken, state
Lists the progress for all your application's achievements for the currently authenticated player."
{:scopes ["https://www.googleapis.com/auth/games"]}
[auth parameters]
{:pre [(util/has-keys? parameters #{:playerId})]}
(util/get-response
(http/get
(util/get-url
"https://www.googleapis.com/games/v1/"
"players/{playerId}/achievements"
#{:playerId}
parameters)
(merge-with
merge
{:throw-exceptions false,
:query-params parameters,
:accept :json,
:as :json}
auth))))
(defn reveal$
"https://developers.google.com/games/services/api/reference/rest/v1/achievements/reveal
Required parameters: achievementId
Optional parameters: none
Sets the state of the achievement with the given ID to REVEALED for the currently authenticated player."
{:scopes ["https://www.googleapis.com/auth/games"]}
[auth parameters]
{:pre [(util/has-keys? parameters #{:achievementId})]}
(util/get-response
(http/post
(util/get-url
"https://www.googleapis.com/games/v1/"
"achievements/{achievementId}/reveal"
#{:achievementId}
parameters)
(merge-with
merge
{:throw-exceptions false,
:query-params parameters,
:accept :json,
:as :json}
auth))))
(defn setStepsAtLeast$
"https://developers.google.com/games/services/api/reference/rest/v1/achievements/setStepsAtLeast
Required parameters: achievementId, steps
Optional parameters: none
Sets the steps for the currently authenticated player towards unlocking an achievement. If the steps parameter is less than the current number of steps that the player already gained for the achievement, the achievement is not modified."
{:scopes ["https://www.googleapis.com/auth/games"]}
[auth parameters]
{:pre [(util/has-keys? parameters #{:achievementId :steps})]}
(util/get-response
(http/post
(util/get-url
"https://www.googleapis.com/games/v1/"
"achievements/{achievementId}/setStepsAtLeast"
#{:achievementId :steps}
parameters)
(merge-with
merge
{:throw-exceptions false,
:query-params parameters,
:accept :json,
:as :json}
auth))))
(defn unlock$
"https://developers.google.com/games/services/api/reference/rest/v1/achievements/unlock
Required parameters: achievementId
Optional parameters: builtinGameId
Unlocks this achievement for the currently authenticated player."
{:scopes ["https://www.googleapis.com/auth/games"]}
[auth parameters]
{:pre [(util/has-keys? parameters #{:achievementId})]}
(util/get-response
(http/post
(util/get-url
"https://www.googleapis.com/games/v1/"
"achievements/{achievementId}/unlock"
#{:achievementId}
parameters)
(merge-with
merge
{:throw-exceptions false,
:query-params parameters,
:accept :json,
:as :json}
auth))))
(defn updateMultiple$
"https://developers.google.com/games/services/api/reference/rest/v1/achievements/updateMultiple
Required parameters: none
Optional parameters: builtinGameId
Body:
{:kind string,
:updates [{:achievementId string,
:incrementPayload GamesAchievementIncrement,
:kind string,
:setStepsAtLeastPayload GamesAchievementSetStepsAtLeast,
:updateType string}]}
Updates multiple achievements for the currently authenticated player."
{:scopes ["https://www.googleapis.com/auth/games"]}
[auth parameters body]
{:pre [(util/has-keys? parameters #{})]}
(util/get-response
(http/post
(util/get-url
"https://www.googleapis.com/games/v1/"
"achievements/updateMultiple"
#{}
parameters)
(merge-with
merge
{:content-type :json,
:body (json/generate-string body),
:throw-exceptions false,
:query-params parameters,
:accept :json,
:as :json}
auth))))