Skip to content

Commit 93797ae

Browse files
Mikkel Sørensenkirre-bylund
authored andcommitted
Add support for getting Leaderboard details
1 parent 8f2e79d commit 93797ae

File tree

4 files changed

+373
-0
lines changed

4 files changed

+373
-0
lines changed

Runtime/Client/LootLockerEndPoints.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@ public class LootLockerEndPoints
235235
public static EndPointClass getAllMemberRanks = new EndPointClass("leaderboards/member/{0}?count={1}", LootLockerHTTPMethod.GET);
236236
public static EndPointClass getScoreList = new EndPointClass("leaderboards/{0}/list?count={1}", LootLockerHTTPMethod.GET);
237237
public static EndPointClass submitScore = new EndPointClass("leaderboards/{0}/submit", LootLockerHTTPMethod.POST);
238+
public static EndPointClass getLeaderboardData = new EndPointClass("leaderboards/{0}/info", LootLockerHTTPMethod.GET);
238239

239240
// Progressions
240241
[Header("Progressions")]

Runtime/Game/LootLockerSDKManager.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5120,6 +5120,24 @@ public static void SubmitScore(string memberId, int score, string leaderboardKey
51205120
LootLockerAPIManager.SubmitScore(request, leaderboardKey, onComplete);
51215121
}
51225122

5123+
/// <summary>
5124+
/// Get data on a leaderboard, check rewards and when it will reset and the last reset time.
5125+
/// </summary>
5126+
/// <param name="leaderboard_key">Key of the leaderboard to get data from</param>
5127+
/// <param name="onComplete">onComplete Action for handling the response of type LootLockerLeaderboardDetailResponse</param>
5128+
public static void GetLeaderboardData(string leaderboard_key, Action<LootLockerLeaderboardDetailResponse> onComplete)
5129+
{
5130+
if (!CheckInitialized())
5131+
{
5132+
onComplete?.Invoke(LootLockerResponseFactory.SDKNotInitializedError<LootLockerLeaderboardDetailResponse>());
5133+
return;
5134+
}
5135+
5136+
EndPointClass endPoint = LootLockerEndPoints.getLeaderboardData;
5137+
string formatedEndPoint = string.Format(endPoint.endPoint, leaderboard_key);
5138+
LootLockerServerRequest.CallAPI(formatedEndPoint, endPoint.httpMethod, null, (serverResponse) => { LootLockerResponse.Deserialize(onComplete, serverResponse); });
5139+
}
5140+
51235141
#endregion
51245142

51255143
/// <summary>
Lines changed: 343 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,343 @@
1+
using System;
2+
using System.Net;
3+
using LootLocker.Requests;
4+
using UnityEngine;
5+
6+
namespace LootLocker.Requests
7+
{
8+
public class LootLockerLeaderboardDetailResponse : LootLockerResponse
9+
{
10+
/// <summary>
11+
/// The date the Leaderboard was created.
12+
/// </summary>
13+
public string created_at { get; set; }
14+
/// <summary>
15+
/// The date the Leaderboard was last updated.
16+
/// </summary>
17+
public string updated_at { get; set; }
18+
/// <summary>
19+
/// The Leaderboards Key.
20+
/// </summary>
21+
public string key { get; set; }
22+
/// <summary>
23+
/// The direction of the Leaderboard (Ascending / Descending).
24+
/// </summary>
25+
public string direction_method { get; set; }
26+
/// <summary>
27+
/// The name of the Leaderboard.
28+
/// </summary>
29+
public string name { get; set; }
30+
/// <summary>
31+
/// The type of the Leaderboard (Player / Generic).
32+
/// </summary>
33+
public string type { get; set; }
34+
/// <summary>
35+
/// Will the score be overwritten even if it was less than the original score.
36+
/// </summary>
37+
public bool overwrite_score_on_submit { get; set; }
38+
/// <summary>
39+
/// Does the Leaderboard have metadata.
40+
/// </summary>
41+
public bool has_metadata { get; set; }
42+
/// <summary>
43+
/// Schedule of the Leaderboard.
44+
/// </summary>
45+
public LootLockerLeaderboardSchedule schedule { get; set; }
46+
/// <summary>
47+
/// A List of rewards tied to the Leaderboard.
48+
/// </summary>
49+
public LootLockerLeaderboardReward[] rewards { get; set; }
50+
}
51+
52+
public class LootLockerLeaderboardRewardCurrency
53+
{
54+
/// <summary>
55+
/// The date the Currency reward was created.
56+
/// </summary>
57+
public string created_at { get; set; }
58+
/// <summary>
59+
/// The date the Currency reward was last updated.
60+
/// </summary>
61+
public string updated_at { get; set; }
62+
/// <summary>
63+
/// The amount of Currency to be rewarded.
64+
/// </summary>
65+
public string amount { get; set; }
66+
/// <summary>
67+
/// The details on the Currency.
68+
/// </summary>
69+
public LootLockerLeaderboardRewardCurrencyDetails details { get; set; }
70+
/// <summary>
71+
/// The ID of a reward.
72+
/// </summary>
73+
public string reward_id { get; set; }
74+
/// <summary>
75+
/// The ID of the Currency.
76+
/// </summary>
77+
public string currency_id { get; set; }
78+
}
79+
80+
public class LootLockerLeaderboardRewardCurrencyDetails
81+
{
82+
/// <summary>
83+
/// The name of the Currency.
84+
/// </summary>
85+
public string name { get; set; }
86+
/// <summary>
87+
/// The code of the Currency.
88+
/// </summary>
89+
public string code { get; set; }
90+
/// <summary>
91+
/// The amount of the Currency.
92+
/// </summary>
93+
public string amount { get; set; }
94+
/// <summary>
95+
/// The ID of the Currency.
96+
/// </summary>
97+
public string id { get; set; }
98+
}
99+
100+
public class LootLockerLeaderboardRewardProgression
101+
{
102+
/// <summary>
103+
/// The date the Progression Points reward was created.
104+
/// </summary>
105+
public string created_at { get; set; }
106+
/// <summary>
107+
/// The date the Progression Points was last updated.
108+
/// </summary>
109+
public string updated_at { get; set; }
110+
/// <summary>
111+
/// The details of the Progression.
112+
/// </summary>
113+
public LootLockerLeaderboardRewardProgressionDetails details { get; set; }
114+
/// <summary>
115+
/// The amount of Progression Points to be rewarded.
116+
/// </summary>
117+
public int amount { get; set; }
118+
/// <summary>
119+
/// The ID of the Progression.
120+
/// </summary>
121+
public string progression_id { get; set; }
122+
/// <summary>
123+
/// The ID of the reward.
124+
/// </summary>
125+
public string reward_id { get; set; }
126+
}
127+
128+
public class LootLockerLeaderboardRewardProgressionDetails
129+
{
130+
/// <summary>
131+
/// The key of the Progression.
132+
/// </summary>
133+
public string key { get; set; }
134+
/// <summary>
135+
/// The name of the Progression.
136+
/// </summary>
137+
public string name { get; set; }
138+
/// <summary>
139+
/// The amount of Progression Points to be rewarded.
140+
/// </summary>
141+
public int amount { get; set; }
142+
/// <summary>
143+
/// The ID of the Progression.
144+
/// </summary>
145+
public string id { get; set; }
146+
}
147+
148+
public class LootLockerLeaderboardRewardProgressionReset
149+
{
150+
/// <summary>
151+
/// The date the Progression Reset reward was created.
152+
/// </summary>
153+
public string created_at { get; set; }
154+
/// <summary>
155+
/// The date the Progression Reset reward was last updated.
156+
/// </summary>
157+
public string updated_at { get; set; }
158+
/// <summary>
159+
/// The details of the Progression reward.
160+
/// </summary>
161+
public LootLockerLeaderboardRewardProgressionResetDetails details { get; set; }
162+
/// <summary>
163+
/// The ID of the Progression.
164+
/// </summary>
165+
public string progression_id { get; set; }
166+
/// <summary>
167+
/// The ID of the reward.
168+
/// </summary>
169+
public string reward_id { get; set; }
170+
}
171+
172+
public class LootLockerLeaderboardRewardProgressionResetDetails
173+
{
174+
/// <summary>
175+
/// The key of the Progression.
176+
/// </summary>
177+
public string key { get; set; }
178+
/// <summary>
179+
/// The name of the Progression.
180+
/// </summary>
181+
public string name { get; set; }
182+
/// <summary>
183+
/// The ID of the Progression.
184+
/// </summary>
185+
public string id { get; set; }
186+
}
187+
188+
public class LootLockerLeaderboardRewardAsset
189+
{
190+
/// <summary>
191+
/// The date the Asset reward was created.
192+
/// </summary>
193+
public string created_at { get; set; }
194+
/// <summary>
195+
/// The date the Asset reward was last updated.
196+
/// </summary>
197+
public string updated_at { get; set; }
198+
/// <summary>
199+
/// The details on the Asset.
200+
/// </summary>
201+
public LootLockerLeaderboardRewardAssetDetails details { get; set; }
202+
/// <summary>
203+
/// The Asset variation ID, will be null if its not a variation.
204+
/// </summary>
205+
public int asset_variation_id { get; set; }
206+
/// <summary>
207+
/// The Asset rental option ID, will be null if its not a rental.
208+
/// </summary>
209+
public int asset_rental_option_id { get; set; }
210+
/// <summary>
211+
/// The ID of the Asset.
212+
/// </summary>
213+
public int asset_id { get; set; }
214+
/// <summary>
215+
/// The ID of the reward.
216+
/// </summary>
217+
public string reward_id { get; set; }
218+
/// <summary>
219+
/// The ULID of the Asset.
220+
/// </summary>
221+
public string asset_ulid { get; set; }
222+
}
223+
224+
public class LootLockerLeaderboardRewardAssetDetails
225+
{
226+
/// <summary>
227+
/// The name of the Asset.
228+
/// </summary>
229+
public string name { get; set; }
230+
/// <summary>
231+
/// The url to the thumbnail, will be null if its not set in the LootLocker console.
232+
/// </summary>
233+
public string thumbnail { get; set; }
234+
/// <summary>
235+
/// The name of the Variation Asset, will be null if its not a Variation Asset.
236+
/// </summary>
237+
public string variation_name { get; set; }
238+
/// <summary>
239+
/// The name of the Rental Asset, will be null if its not a Variation Asset.
240+
/// </summary>
241+
public string rental_option_name { get; set; }
242+
/// <summary>
243+
/// The ID of the Variation, will be null if its not a Variation Asset.
244+
/// </summary>
245+
public int? variation_id { get; set; }
246+
/// <summary>
247+
/// The ID of the rental option, will be null if its not a Rental Asset.
248+
/// </summary>
249+
public int? rental_option_id { get; set; }
250+
/// <summary>
251+
/// The ID of the Asset.
252+
/// </summary>
253+
public int legacy_id { get; set; }
254+
/// <summary>
255+
/// the ULID of the Asset.
256+
/// </summary>
257+
public string id { get; set; }
258+
}
259+
260+
public class LootLockerLeaderboardReward
261+
{
262+
/// <summary>
263+
/// The kind of reward, (asset / currency / progression points / progression reset).
264+
/// </summary>
265+
public string reward_kind { get; set; }
266+
/// <summary>
267+
/// The Predicates of the reward.
268+
/// </summary>
269+
public LootLockerLeaderboardRewardPredicates predicates { get; set; }
270+
/// <summary>
271+
/// The currency reward, will be null if the reward is of another type.
272+
/// </summary>
273+
public LootLockerLeaderboardRewardCurrency currency { get; set; }
274+
/// <summary>
275+
/// The Progression Reset reward, will be null if the reward is of another type.
276+
/// </summary>
277+
public LootLockerLeaderboardRewardProgressionReset progression_reset { get; set; }
278+
/// <summary>
279+
/// The Progression Points reward, will be null if the reward is of another type.
280+
/// </summary>
281+
public LootLockerLeaderboardRewardProgression progression_points { get; set; }
282+
/// <summary>
283+
/// The Asset reward, will be null if the reward is of another type.
284+
/// </summary>
285+
public LootLockerLeaderboardRewardAsset asset { get; set; }
286+
}
287+
288+
public class LootLockerLeaderboardRewardPredicates
289+
{
290+
/// <summary>
291+
/// The ID of the reward predicate.
292+
/// </summary>
293+
public string id { get; set; }
294+
/// <summary>
295+
/// The type of reward predicate.
296+
/// </summary>
297+
public string type { get; set; }
298+
/// <summary>
299+
/// The details on predicate.
300+
/// </summary>
301+
public LootLockerLeaderboardRewardPredicatesArgs args { get; set; }
302+
}
303+
304+
public class LootLockerLeaderboardRewardPredicatesArgs
305+
{
306+
/// <summary>
307+
/// Max predicate to reward.
308+
/// </summary>
309+
public int max { get; set; }
310+
/// <summary>
311+
/// Min predicate to reward.
312+
/// </summary>
313+
public int min { get; set; }
314+
/// <summary>
315+
/// The reward method (by_rank / by_percent).
316+
/// </summary>
317+
public string method { get; set; }
318+
/// <summary>
319+
/// The direction of the predicate (asc / desc).
320+
/// </summary>
321+
public string direction { get; set; }
322+
}
323+
324+
public class LootLockerLeaderboardSchedule
325+
{
326+
/// <summary>
327+
/// Cron expression used to define the scheduling.
328+
/// </summary>
329+
public string cron_expression { get; set; }
330+
/// <summary>
331+
/// The date when the next Leaderboard reset wil happen.
332+
/// </summary>
333+
public string next_run { get; set; }
334+
/// <summary>
335+
/// The date when the last Leaderboard reset happened.
336+
/// </summary>
337+
public string last_run { get; set; }
338+
/// <summary>
339+
/// A list of all the schedules that has ran.
340+
/// </summary>
341+
public string[] schedule { get; set; }
342+
}
343+
}

Runtime/Game/Requests/LeaderboardDetailsRequest.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)