Skip to content

Commit d47874f

Browse files
Mikkel Sørensenkirre-bylund
authored andcommitted
Added archive listing and details to LeaderboardRequests
This includes the endpoints as well as functions in LootLockerSDKManager
1 parent ca1def6 commit d47874f

File tree

3 files changed

+169
-0
lines changed

3 files changed

+169
-0
lines changed

Runtime/Client/LootLockerEndPoints.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,8 @@ public class LootLockerEndPoints
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);
238238
public static EndPointClass getLeaderboardData = new EndPointClass("leaderboards/{0}/info", LootLockerHTTPMethod.GET);
239+
public static EndPointClass listLeaderboardArchive = new EndPointClass("leaderboards/{0}/archive/list", LootLockerHTTPMethod.GET);
240+
public static EndPointClass getLeaderboardArchive = new EndPointClass("leaderboards/archive/read?key={0}&", LootLockerHTTPMethod.GET);
239241

240242
// Progressions
241243
[Header("Progressions")]

Runtime/Game/LootLockerSDKManager.cs

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

5123+
/// <summary>
5124+
/// List the archived versions of a leaderboard, containing past rewards, ranks, etc.
5125+
/// </summary>
5126+
/// <param name="leaderboard_key">Key of the Leaderboard</param>
5127+
/// <param name="onComplete">onComplete Action for handling the response of type LootLockerLeaderboardHistoryResponse</param>
5128+
public static void ListLeaderboardArchive(string leaderboard_key, Action<LootLockerLeaderboardHistoryResponse> onComplete)
5129+
{
5130+
if (!CheckInitialized())
5131+
{
5132+
onComplete?.Invoke(LootLockerResponseFactory.SDKNotInitializedError<LootLockerLeaderboardHistoryResponse>());
5133+
return;
5134+
}
5135+
5136+
EndPointClass endPoint = LootLockerEndPoints.listLeaderboardArchive;
5137+
string tempEndpoint = string.Format(endPoint.endPoint, leaderboard_key);
5138+
LootLockerServerRequest.CallAPI(tempEndpoint, endPoint.httpMethod, null, ((serverResponse) => { LootLockerResponse.Deserialize(onComplete, serverResponse); }));
5139+
}
5140+
5141+
/// <summary>
5142+
/// Get the details of a Leaderboard Archive, containing past rewards, ranks, etc
5143+
/// </summary>
5144+
/// <param name="key"> Key of the json archive to read</param>
5145+
/// <param name="onComplete"><onComplete Action for handling the response of type LootLockerLeaderboardHistoryDetailsResponse</param>
5146+
public static void GetLeaderboardArchive(string key, Action<LootLockerLeaderboardHistoryDetailsResponse> onComplete)
5147+
{
5148+
GetLeaderboardArchive(key, -1, null, onComplete);
5149+
}
5150+
5151+
/// <summary>
5152+
/// Get the details of a Leaderboard Archive, containing past rewards, ranks, etc
5153+
/// </summary>
5154+
/// <param name="key"> Key of the json archive to read</param>
5155+
/// <param name="count"> Amount of entries to read </param>
5156+
/// <param name="onComplete"><onComplete Action for handling the response of type LootLockerLeaderboardHistoryDetailsResponse</param>
5157+
public static void GetLeaderboardArchive(string key, int count, Action<LootLockerLeaderboardHistoryDetailsResponse> onComplete)
5158+
{
5159+
GetLeaderboardArchive(key, count, null, onComplete);
5160+
}
5161+
5162+
/// <summary>
5163+
/// Get the details of a Leaderboard Archive, containing past rewards, ranks, etc
5164+
/// </summary>
5165+
/// <param name="key"> Key of the json archive to read</param>
5166+
/// <param name="count"> Amount of entries to read </param>
5167+
/// <param name="after"> Return after specified index </param>
5168+
/// <param name="onComplete"><onComplete Action for handling the response of type LootLockerLeaderboardHistoryDetailsResponse</param>
5169+
public static void GetLeaderboardArchive(string key, int count, string after, Action<LootLockerLeaderboardHistoryDetailsResponse> onComplete)
5170+
{
5171+
if (!CheckInitialized())
5172+
{
5173+
onComplete?.Invoke(LootLockerResponseFactory.SDKNotInitializedError<LootLockerLeaderboardHistoryDetailsResponse>());
5174+
return;
5175+
}
5176+
5177+
EndPointClass endPoint = LootLockerEndPoints.getLeaderboardArchive;
5178+
5179+
string tempEndpoint = string.Format(endPoint.endPoint, key);
5180+
5181+
if (count > 0)
5182+
tempEndpoint += $"count={count}&";
5183+
5184+
if (!string.IsNullOrEmpty(after))
5185+
tempEndpoint += $"after={after}&";
5186+
5187+
5188+
LootLockerServerRequest.CallAPI(tempEndpoint, endPoint.httpMethod, null, ((serverResponse) => { LootLockerResponse.Deserialize(onComplete, serverResponse); }));
5189+
}
5190+
51235191
/// <summary>
51245192
/// Get data on a leaderboard, check rewards and when it will reset and the last reset time.
51255193
/// </summary>

Runtime/Game/Requests/LeaderboardRequest.cs

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,105 @@ public class LootLockerSubmitScoreResponse : LootLockerResponse
7373
public string metadata { get; set; }
7474
}
7575

76+
public class LootLockerLeaderboardHistoryResponse : LootLockerResponse
77+
{
78+
/// <summary>
79+
/// A List of past Leaderboards.
80+
/// </summary>
81+
public LootLockerLeaderboardArchive[] archives { get; set; }
82+
}
83+
84+
public class LootLockerLeaderboardArchive
85+
{
86+
/// <summary>
87+
/// The date when the archived Leaderboard was modified.
88+
/// </summary>
89+
public string last_modified { get; set; }
90+
/// <summary>
91+
/// The type of content (application/json).
92+
/// </summary>
93+
public string content_type { get; set; }
94+
/// <summary>
95+
/// The Key which is used to identify a json body of an old Leaderboard.
96+
/// </summary>
97+
public string key { get; set; }
98+
/// <summary>
99+
/// Length of the archived Leaderboard.
100+
/// </summary>
101+
public int content_length { get; set; }
102+
}
103+
public class LootLockerLeaderboardHistoryDetailsResponse : LootLockerResponse
104+
{
105+
/// <summary>
106+
/// Pagination.
107+
/// </summary>
108+
public LootLockerPaginationResponse<string> pagination { get; set; }
109+
/// <summary>
110+
/// A list of players and details from the archived Leaderboard.
111+
/// </summary>
112+
public LootLockerLeaderboardHistoryDetails[] items { get; set; }
113+
}
114+
public class LootLockerLeaderboardHistoryDetails
115+
{
116+
/// <summary>
117+
/// The Player on the archived Leaderboard.
118+
/// </summary>
119+
public LootLockerLeaderBoardPlayer player { get; set; }
120+
/// <summary>
121+
/// Metadata if any was supplied.
122+
/// </summary>
123+
public string metadata { get; set; }
124+
/// <summary>
125+
/// The Player's member ID on the Archived Leaderboard.
126+
/// </summary>
127+
public string member_id { get; set; }
128+
/// <summary>
129+
/// The Player's rank on the archived Leaderboard.
130+
/// </summary>
131+
public int rank { get; set; }
132+
/// <summary>
133+
/// The Player's Score on the archived Leaderboard.
134+
/// </summary>
135+
public int score { get; set; }
136+
137+
}
138+
public class LootLockerLeaderBoardPlayer
139+
{
140+
/// <summary>
141+
/// The name of the Player.
142+
/// </summary>
143+
public string name { get; set; }
144+
/// <summary>
145+
/// The Public UID of the Player.
146+
/// </summary>
147+
public string public_uid { get; set; }
148+
/// <summary>
149+
/// The ID of the Player.
150+
/// </summary>
151+
public int id { get; set; }
152+
/// <summary>
153+
/// The ULID of the Player.
154+
/// </summary>
155+
public string player_ulid { get; set; }
156+
157+
}
158+
[Serializable]
159+
public class LootLockerLeaderboardArchiveRequest
160+
{
161+
/// <summary>
162+
/// The identifying Key of an archived leaderboard.
163+
/// </summary>
164+
public string key { get; set; }
165+
/// <summary>
166+
/// Count of entries to read.
167+
/// </summary>
168+
public int count { get; set; }
169+
/// <summary>
170+
/// After specified index.
171+
/// </summary>
172+
public string after { get; set; }
173+
174+
}
76175

77176
public class LootLockerSubmitScoreRequest
78177
{

0 commit comments

Comments
 (0)