Skip to content

Commit d244907

Browse files
Erik Bylundkirre-bylund
authored andcommitted
Add support for catalogs
1 parent a55bb6a commit d244907

File tree

5 files changed

+466
-0
lines changed

5 files changed

+466
-0
lines changed

Runtime/Client/LootLockerEndPoints.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,11 @@ public class LootLockerEndPoints
247247
public static EndPointClass getWalletByWalletId = new EndPointClass("v1/wallets/{0]", LootLockerHTTPMethod.GET);
248248
public static EndPointClass getWalletByHolderId = new EndPointClass("v1/wallets/holder/{0}", LootLockerHTTPMethod.GET);
249249

250+
// Catalogs
251+
[Header("Catalogs")]
252+
public static EndPointClass listCatalogs = new EndPointClass("v1/game/catalog", LootLockerHTTPMethod.GET);
253+
public static EndPointClass listCatalogItems = new EndPointClass("v1/game/catalog/{0}/prices", LootLockerHTTPMethod.GET);
254+
250255
// Misc
251256
[Header("Misc")]
252257
public static EndPointClass ping = new EndPointClass("ping", LootLockerHTTPMethod.GET);

Runtime/Client/LootLockerServerRequest.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ public static T Deserialize<T>(LootLockerResponse serverResponse,
207207
return response;
208208
}
209209
}
210+
210211
public class LootLockerPaginationResponse<TKey>
211212
{
212213
public int total { get; set; }

Runtime/Game/LootLockerSDKManager.cs

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5092,6 +5092,49 @@ public static void GetWalletByHolderID(string holderID, Action<LootLockerGetWall
50925092

50935093
#endregion
50945094

5095+
#region Catalog
5096+
/// <summary>
5097+
/// List the catalogs available for the game
5098+
/// </summary>
5099+
/// <param name="onComplete">onComplete Action for handling the response</param>
5100+
public static void ListCatalogs(Action<LootLockerListCatalogsResponse> onComplete)
5101+
{
5102+
if (!CheckInitialized())
5103+
{
5104+
onComplete?.Invoke(LootLockerResponseFactory.SDKNotInitializedError<LootLockerListCatalogsResponse>());
5105+
return;
5106+
}
5107+
5108+
LootLockerServerRequest.CallAPI(LootLockerEndPoints.listCatalogs.endPoint, LootLockerEndPoints.listCatalogs.httpMethod, onComplete: (serverResponse) => { LootLockerResponse.Deserialize(onComplete, serverResponse); });
5109+
}
5110+
5111+
/// <summary>
5112+
/// List the items available in a specific catalog
5113+
/// </summary>
5114+
/// <param name="catalogKey">Unique Key of the catalog that you want to get items for</param>
5115+
/// <param name="count">Amount of catalog items to receive. Use null to simply get the default amount.</param>
5116+
/// <param name="after">Used for pagination, this is the cursor to start getting items from. Use null to get items from the beginning. Use the cursor from a previous call to get the next count of items in the list.</param>
5117+
/// <param name="onComplete">onComplete Action for handling the response</param>
5118+
public static void ListCatalogItems(string catalogKey, int count, string after, Action<LootLockerListCatalogItemsResponse> onComplete)
5119+
{
5120+
if (!CheckInitialized())
5121+
{
5122+
onComplete?.Invoke(LootLockerResponseFactory.SDKNotInitializedError<LootLockerListCatalogItemsResponse>());
5123+
return;
5124+
}
5125+
var endpoint = string.Format(LootLockerEndPoints.listCatalogItems.endPoint, catalogKey);
5126+
5127+
endpoint += "?";
5128+
if (count > 0)
5129+
endpoint += $"per_page={count}&";
5130+
5131+
if (!string.IsNullOrEmpty(after))
5132+
endpoint += $"cursor={after}&";
5133+
5134+
LootLockerServerRequest.CallAPI(endpoint, LootLockerEndPoints.listCatalogItems.httpMethod, onComplete: (serverResponse) => { LootLockerCatalogRequestUtils.ParseLootLockerListCatalogItemsResponse(onComplete, serverResponse); });
5135+
}
5136+
#endregion
5137+
50955138
#region Misc
50965139

50975140
/// <summary>

0 commit comments

Comments
 (0)