Skip to content

Commit a7b0441

Browse files
Erik Bylundkirre-bylund
authored andcommitted
Add support for entitlement history
1 parent 4449d54 commit a7b0441

File tree

4 files changed

+223
-8
lines changed

4 files changed

+223
-8
lines changed

Runtime/Client/LootLockerEndPoints.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,5 +281,8 @@ public class LootLockerEndPoints
281281
public static EndPointClass reportsCreatePlayer = new EndPointClass("reports/player", LootLockerHTTPMethod.POST);
282282
public static EndPointClass reportsCreateAsset = new EndPointClass("reports/asset", LootLockerHTTPMethod.POST);
283283

284+
// Entitlements
285+
[Header("Entitlements")]
286+
public static EndPointClass listEntitlementHistory = new EndPointClass("entitlements", LootLockerHTTPMethod.GET);
284287
}
285288
}

Runtime/Game/LootLockerSDKManager.cs

Lines changed: 63 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
using Newtonsoft.Json.Linq;
1212
#else
1313
using LLlibs.ZeroDepJson;
14+
using Ionic.Zlib;
15+
using System.Net;
1416
#endif
1517
#if UNITY_EDITOR
1618
using UnityEditor;
@@ -5537,6 +5539,67 @@ public static void ListCatalogItems(string catalogKey, int count, string after,
55375539
}
55385540
#endregion
55395541

5542+
#region Entitlements
5543+
/// <summary>
5544+
/// List this player's historical entitlements
5545+
/// Use this to retrieve information on entitlements the player has received regardless of their origin (for example as an effect of progression, purchases, or leaderboard rewards)
5546+
/// </summary>
5547+
/// <param name="count">Optional: Amount of historical entries to fetch</param>
5548+
/// <param name="after">Optional: Used for pagination, this is the cursor to start getting entries from. Use null or use an overload without the parameter to get entries from the beginning. Use the cursor from a previous call to get the next count of entries in the list.</param>
5549+
/// <param name="onComplete">onComplete Action for handling the response</param>
5550+
public static void ListEntitlements(int count, string after, Action<LootLockerEntitlementHistoryResponse> onComplete)
5551+
{
5552+
if (!CheckInitialized())
5553+
{
5554+
onComplete?.Invoke(LootLockerResponseFactory.SDKNotInitializedError<LootLockerEntitlementHistoryResponse>());
5555+
return;
5556+
}
5557+
5558+
string endpoint = LootLockerEndPoints.listEntitlementHistory.endPoint;
5559+
5560+
if(count > 0 || !string.IsNullOrEmpty(after))
5561+
endpoint += endpoint.Contains("?") ? "&" : "?";
5562+
if (count > 0)
5563+
endpoint += $"count={count}&";
5564+
if (!string.IsNullOrEmpty(after))
5565+
endpoint += $"after={after}&";
5566+
5567+
LootLockerServerRequest.CallAPI(endpoint, LootLockerEndPoints.listEntitlementHistory.httpMethod, onComplete: (serverResponse) => { LootLockerResponse.Deserialize(onComplete, serverResponse); });
5568+
}
5569+
5570+
/// <summary>
5571+
/// List this player's historical entitlements
5572+
/// Use this to retrieve information on entitlements the player has received regardless of their origin (for example as an effect of progression, purchases, or leaderboard rewards)
5573+
/// </summary>
5574+
/// <param name="count">Optional: Amount of historical entries to fetch</param>
5575+
/// <param name="onComplete">onComplete Action for handling the response</param>
5576+
public static void ListEntitlements(int count, Action<LootLockerEntitlementHistoryResponse> onComplete)
5577+
{
5578+
ListEntitlements(count, null, onComplete);
5579+
}
5580+
5581+
/// <summary>
5582+
/// List this player's historical entitlements
5583+
/// Use this to retrieve information on entitlements the player has received regardless of their origin (for example as an effect of progression, purchases, or leaderboard rewards)
5584+
/// </summary>
5585+
/// <param name="after">Optional: Used for pagination, this is the cursor to start getting entries from. Use null or use an overload without the parameter to get entries from the beginning. Use the cursor from a previous call to get the next count of entries in the list.</param>
5586+
/// <param name="onComplete">onComplete Action for handling the response</param>
5587+
public static void ListEntitlements(string after, Action<LootLockerEntitlementHistoryResponse> onComplete)
5588+
{
5589+
ListEntitlements(-1, after, onComplete);
5590+
}
5591+
5592+
/// <summary>
5593+
/// List this player's historical entitlements
5594+
/// Use this to retrieve information on entitlements the player has received regardless of their origin (for example as an effect of progression, purchases, or leaderboard rewards)
5595+
/// </summary>
5596+
/// <param name="onComplete">onComplete Action for handling the response</param>
5597+
public static void ListEntitlements(Action<LootLockerEntitlementHistoryResponse> onComplete)
5598+
{
5599+
ListEntitlements(-1, null, onComplete);
5600+
}
5601+
#endregion
5602+
55405603
#region Misc
55415604

55425605
/// <summary>
@@ -5573,12 +5636,4 @@ public static Platforms GetLastActivePlatform()
55735636

55745637
#endregion
55755638
}
5576-
5577-
public class ResponseError
5578-
{
5579-
public bool success { get; set; }
5580-
public string error { get; set; }
5581-
public string[] messages { get; set; }
5582-
public string error_id { get; set; }
5583-
}
55845639
}
Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
namespace LootLocker.Requests
2+
{
3+
//==================================================
4+
// Data Definitions
5+
//==================================================
6+
7+
/// <summary>
8+
/// </summary>
9+
public class LootLockerEntitlementHistoryItem
10+
{
11+
12+
/// <summary>
13+
/// TODO: Document
14+
/// </summary>
15+
public string created_at { get; set; }
16+
17+
/// <summary>
18+
/// TODO: Document
19+
/// </summary>
20+
public string reward_kind { get; set; }
21+
22+
/// <summary>
23+
/// TODO: Document
24+
/// </summary>
25+
public string id { get; set; }
26+
27+
/// <summary>
28+
/// TODO: Document
29+
/// </summary>
30+
public string reward_id { get; set; }
31+
32+
/// <summary>
33+
/// TODO: Document
34+
/// </summary>
35+
public string catalog_id { get; set; }
36+
37+
/// <summary>
38+
/// TODO: Document
39+
/// </summary>
40+
public bool purchasable { get; set; }
41+
}
42+
43+
/// <summary>
44+
/// </summary>
45+
public class LootLockerEntitlementHistoryMetadata
46+
{
47+
48+
/// <summary>
49+
/// TODO: Document
50+
/// </summary>
51+
public string key { get; set; }
52+
53+
/// <summary>
54+
/// TODO: Document
55+
/// </summary>
56+
public string value { get; set; }
57+
}
58+
59+
/// <summary>
60+
/// </summary>
61+
public class LootLockerEntitlementHistoryReward
62+
{
63+
64+
/// <summary>
65+
/// TODO: Document
66+
/// </summary>
67+
public string created_at { get; set; }
68+
69+
/// <summary>
70+
/// TODO: Document
71+
/// </summary>
72+
public string entitlement_id { get; set; }
73+
74+
/// <summary>
75+
/// TODO: Document
76+
/// </summary>
77+
public string id { get; set; }
78+
79+
/// <summary>
80+
/// TODO: Document
81+
/// </summary>
82+
public string reward_id { get; set; }
83+
}
84+
85+
//==================================================
86+
// Response Definitions
87+
//==================================================
88+
89+
/// <summary>
90+
/// </summary>
91+
public class LootLockerEntitlementHistoryResponse : LootLockerResponse
92+
{
93+
94+
/// <summary>
95+
/// TODO: Document
96+
/// </summary>
97+
public LootLockerEntitlementListing[] listings { get; set; }
98+
99+
/// <summary>
100+
/// TODO: Document
101+
/// </summary>
102+
public LootLockerPaginationResponse<string> pagination { get; set; }
103+
}
104+
105+
/// <summary>
106+
/// </summary>
107+
public class LootLockerEntitlementListing
108+
{
109+
110+
/// <summary>
111+
/// TODO: Document
112+
/// </summary>
113+
public string created_at { get; set; }
114+
115+
/// <summary>
116+
/// TODO: Document
117+
/// </summary>
118+
public string id { get; set; }
119+
120+
/// <summary>
121+
/// TODO: Document
122+
/// </summary>
123+
public LootLockerEntitlementHistoryItem[] items { get; set; }
124+
125+
/// <summary>
126+
/// TODO: Document
127+
/// </summary>
128+
public LootLockerEntitlementHistoryMetadata[] metadata { get; set; }
129+
130+
/// <summary>
131+
/// TODO: Document
132+
/// </summary>
133+
public string player_id { get; set; }
134+
135+
/// <summary>
136+
/// TODO: Document
137+
/// </summary>
138+
public LootLockerEntitlementHistoryReward[] rewards { get; set; }
139+
140+
/// <summary>
141+
/// TODO: Document
142+
/// </summary>
143+
public string status { get; set; }
144+
145+
/// <summary>
146+
/// TODO: Document
147+
/// </summary>
148+
public string store { get; set; }
149+
150+
/// <summary>
151+
/// TODO: Document
152+
/// </summary>
153+
public string type { get; set; }
154+
}
155+
}

Runtime/Game/Requests/EntitlementRequests.cs.meta

Lines changed: 2 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)