Skip to content

Commit a55bb6a

Browse files
Erik Bylundkirre-bylund
authored andcommitted
Add support for catalog purchases
1 parent 381a619 commit a55bb6a

File tree

3 files changed

+59
-0
lines changed

3 files changed

+59
-0
lines changed

Runtime/Client/LootLockerEndPoints.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ public class LootLockerEndPoints
195195
public static EndPointClass androidPurchaseVerification = new EndPointClass("v1/purchase", LootLockerHTTPMethod.POST);
196196
public static EndPointClass pollingOrderStatus = new EndPointClass("v1/purchase/{0}", LootLockerHTTPMethod.GET);
197197
public static EndPointClass activatingARentalAsset = new EndPointClass("v1/asset/instance/{0}/activate", LootLockerHTTPMethod.POST);
198+
public static EndPointClass purchaseCatalogItem = new EndPointClass("/purchase", LootLockerHTTPMethod.POST);
198199

199200
// EventTrigger
200201
[Header("EventTrigger")]

Runtime/Game/LootLockerSDKManager.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4310,6 +4310,29 @@ public static void ActivateRentalAsset(int assetInstanceID, Action<LootLockerAct
43104310
data.getRequests.Add(assetInstanceID.ToString());
43114311
LootLockerAPIManager.ActivateRentalAsset(data, onComplete);
43124312
}
4313+
4314+
/// <summary>
4315+
/// Purchase one or more catalog items using a specified wallet
4316+
/// </summary>
4317+
/// <param name="walletID">The id of the wallet to use for the purchase</param>
4318+
/// <param name="itemsToPurchase">A list of items to purchase along with the quantity of each item to purchase</param>
4319+
/// <param name="onComplete">onComplete Action for handling the response</param>
4320+
public static void LootLockerPurchaseCatalogItems(string walletID, LootLockerCatalogItemAndQuantityPair[] itemsToPurchase, Action<LootLockerPurchaseCatalogItemResponse> onComplete)
4321+
{
4322+
if (!CheckInitialized())
4323+
{
4324+
onComplete?.Invoke(LootLockerResponseFactory.SDKNotInitializedError<LootLockerPurchaseCatalogItemResponse>());
4325+
return;
4326+
}
4327+
4328+
LootLockerPurchaseCatalogItemRequest data = new LootLockerPurchaseCatalogItemRequest();
4329+
data.wallet_id = walletID;
4330+
data.items = itemsToPurchase;
4331+
var body = LootLockerJson.SerializeObject(new { data });
4332+
4333+
LootLockerServerRequest.CallAPI(LootLockerEndPoints.purchaseCatalogItem.endPoint, LootLockerEndPoints.purchaseCatalogItem.httpMethod, body, onComplete: (serverResponse) => { LootLockerResponse.Deserialize(onComplete, serverResponse); });
4334+
}
4335+
43134336
#endregion
43144337

43154338
#region Collectables

Runtime/Game/Requests/PurchaseRequest.cs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,41 @@ public class LootLockerAndroidPurchaseVerificationRequest
3737
public int asset_id { get; set; }
3838
public string purchase_token { get; set; }
3939
}
40+
41+
public class LootLockerPurchaseCatalogItemResponse : LootLockerResponse
42+
{
43+
44+
}
45+
46+
/*
47+
*
48+
*/
49+
public class LootLockerCatalogItemAndQuantityPair
50+
{
51+
/*
52+
* The unique id of the catalog item to purchase
53+
*/
54+
public string catalog_item_id { get; set; }
55+
/*
56+
* The quantity of the specified item to purchase
57+
*/
58+
public int quantity { get; set; }
59+
}
60+
61+
/*
62+
*
63+
*/
64+
public class LootLockerPurchaseCatalogItemRequest
65+
{
66+
/*
67+
* The id of the wallet to be used for the purchase
68+
*/
69+
public string wallet_id { get; set; }
70+
/*
71+
* A list of items to purchase
72+
*/
73+
public LootLockerCatalogItemAndQuantityPair[] items { get; set; }
74+
}
4075
}
4176

4277
namespace LootLocker

0 commit comments

Comments
 (0)