Skip to content

Commit a24883e

Browse files
Erik Bylundkirre-bylund
authored andcommitted
Realign to continued backend implementation
1 parent d244907 commit a24883e

9 files changed

+289
-167
lines changed

Runtime/Client/LootLockerEndPoints.cs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +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);
198+
public static EndPointClass purchaseCatalogItem = new EndPointClass("purchase", LootLockerHTTPMethod.POST);
199199

200200
// EventTrigger
201201
[Header("EventTrigger")]
@@ -237,20 +237,21 @@ public class LootLockerEndPoints
237237

238238
// Currencies
239239
[Header("Currencies")]
240-
public static EndPointClass listCurrencies = new EndPointClass("v1/currency", LootLockerHTTPMethod.GET);
241-
public static EndPointClass getCurrencyByCode = new EndPointClass("v1/currency/{0]", LootLockerHTTPMethod.GET);
242-
public static EndPointClass getCurrencyDenominations = new EndPointClass("v1/currency/{0}/denominations", LootLockerHTTPMethod.GET);
240+
public static EndPointClass listCurrencies = new EndPointClass("currencies", LootLockerHTTPMethod.GET);
241+
public static EndPointClass getCurrencyDenominationsByCode = new EndPointClass("currency/code/{0}/denominations", LootLockerHTTPMethod.GET);
243242

244243
// Balances
245244
[Header("Balances")]
246-
public static EndPointClass listBalancesInWallet = new EndPointClass("v1/balances/wallet/{0}", LootLockerHTTPMethod.GET);
247-
public static EndPointClass getWalletByWalletId = new EndPointClass("v1/wallets/{0]", LootLockerHTTPMethod.GET);
248-
public static EndPointClass getWalletByHolderId = new EndPointClass("v1/wallets/holder/{0}", LootLockerHTTPMethod.GET);
245+
public static EndPointClass listBalancesInWallet = new EndPointClass("balances/wallet/{0}", LootLockerHTTPMethod.GET);
246+
public static EndPointClass getWalletByWalletId = new EndPointClass("wallet/{0}", LootLockerHTTPMethod.GET);
247+
public static EndPointClass getWalletByHolderId = new EndPointClass("wallet/holder/{0}", LootLockerHTTPMethod.GET);
248+
public static EndPointClass creditBalanceToWallet = new EndPointClass("balances/credit", LootLockerHTTPMethod.POST);
249+
public static EndPointClass debitBalanceToWallet = new EndPointClass("balances/debit", LootLockerHTTPMethod.POST);
249250

250251
// Catalogs
251252
[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);
253+
public static EndPointClass listCatalogs = new EndPointClass("catalogs", LootLockerHTTPMethod.GET);
254+
public static EndPointClass listCatalogItemsByKey = new EndPointClass("catalog/key/{0}/prices", LootLockerHTTPMethod.GET);
254255

255256
// Misc
256257
[Header("Misc")]

Runtime/Game/LootLockerSDKManager.cs

Lines changed: 66 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@
22
using System.Collections.Generic;
33
using System.IO;
44
using UnityEngine;
5-
using System.Security.Cryptography;
65
using System.Text;
76
using LootLocker.LootLockerEnums;
87
using static LootLocker.LootLockerConfig;
98
using System.Linq;
109
using File = System.IO.File;
11-
using System.Net;
10+
using System.Security.Cryptography;
1211
#if UNITY_EDITOR
1312
using UnityEditor;
1413
#endif
@@ -4314,21 +4313,21 @@ public static void ActivateRentalAsset(int assetInstanceID, Action<LootLockerAct
43144313
/// <summary>
43154314
/// Purchase one or more catalog items using a specified wallet
43164315
/// </summary>
4317-
/// <param name="walletID">The id of the wallet to use for the purchase</param>
4316+
/// <param name="walletId">The id of the wallet to use for the purchase</param>
43184317
/// <param name="itemsToPurchase">A list of items to purchase along with the quantity of each item to purchase</param>
43194318
/// <param name="onComplete">onComplete Action for handling the response</param>
4320-
public static void LootLockerPurchaseCatalogItems(string walletID, LootLockerCatalogItemAndQuantityPair[] itemsToPurchase, Action<LootLockerPurchaseCatalogItemResponse> onComplete)
4319+
public static void LootLockerPurchaseCatalogItems(string walletId, LootLockerCatalogItemAndQuantityPair[] itemsToPurchase, Action<LootLockerPurchaseCatalogItemResponse> onComplete)
43214320
{
43224321
if (!CheckInitialized())
43234322
{
43244323
onComplete?.Invoke(LootLockerResponseFactory.SDKNotInitializedError<LootLockerPurchaseCatalogItemResponse>());
43254324
return;
43264325
}
4327-
4328-
LootLockerPurchaseCatalogItemRequest data = new LootLockerPurchaseCatalogItemRequest();
4329-
data.wallet_id = walletID;
4330-
data.items = itemsToPurchase;
4331-
var body = LootLockerJson.SerializeObject(new { data });
4326+
var body = LootLockerJson.SerializeObject(new LootLockerPurchaseCatalogItemRequest
4327+
{
4328+
wallet_id = walletId,
4329+
items = itemsToPurchase
4330+
});
43324331

43334332
LootLockerServerRequest.CallAPI(LootLockerEndPoints.purchaseCatalogItem.endPoint, LootLockerEndPoints.purchaseCatalogItem.httpMethod, body, onComplete: (serverResponse) => { LootLockerResponse.Deserialize(onComplete, serverResponse); });
43344333
}
@@ -4991,6 +4990,7 @@ public static void GetRemovedUGCForPlayer(GetRemovedUGCForPlayerInput input, Act
49914990
/// <param name="onComplete">onComplete Action for handling the response</param>
49924991
public static void ListCurrencies(Action<LootLockerListCurrenciesResponse> onComplete)
49934992
{
4993+
LootLockerCurrency cur;
49944994
if (!CheckInitialized())
49954995
{
49964996
onComplete?.Invoke(LootLockerResponseFactory.SDKNotInitializedError<LootLockerListCurrenciesResponse>());
@@ -5000,40 +5000,22 @@ public static void ListCurrencies(Action<LootLockerListCurrenciesResponse> onCom
50005000
LootLockerServerRequest.CallAPI(LootLockerEndPoints.listCurrencies.endPoint, LootLockerEndPoints.listCurrencies.httpMethod, onComplete: (serverResponse) => { LootLockerResponse.Deserialize(onComplete, serverResponse); });
50015001
}
50025002

5003-
/// <summary>
5004-
/// Get a specific currency by code
5005-
/// </summary>
5006-
/// <param name="currencyCode">The short code for the currency to fetch information for</param>
5007-
/// <param name="onComplete">onComplete Action for handling the response</param>
5008-
public static void GetCurrencyByCode(string currencyCode, Action<LootLockerGetCurrencyByCodeResponse> onComplete)
5009-
{
5010-
if (!CheckInitialized())
5011-
{
5012-
onComplete?.Invoke(LootLockerResponseFactory.SDKNotInitializedError<LootLockerGetCurrencyByCodeResponse>());
5013-
return;
5014-
}
5015-
5016-
var endpoint = string.Format(LootLockerEndPoints.getCurrencyByCode.endPoint, currencyCode);
5017-
5018-
LootLockerServerRequest.CallAPI(endpoint, LootLockerEndPoints.getCurrencyByCode.httpMethod, onComplete: (serverResponse) => { LootLockerResponse.Deserialize(onComplete, serverResponse); });
5019-
}
5020-
50215003
/// <summary>
50225004
/// Get a list of the denominations available for a specific currency
50235005
/// </summary>
5024-
/// <param name="currencyCode">The short code for the currency to fetch denominations for</param>
5006+
/// <param name="currencyCode">The code of the currency to fetch denominations for</param>
50255007
/// <param name="onComplete">onComplete Action for handling the response</param>
5026-
public static void GetCurrencyDenominations(string currencyCode, Action<LootLockerListDenominationsResponse> onComplete)
5008+
public static void GetCurrencyDenominationsByCode(string currencyCode, Action<LootLockerListDenominationsResponse> onComplete)
50275009
{
50285010
if (!CheckInitialized())
50295011
{
50305012
onComplete?.Invoke(LootLockerResponseFactory.SDKNotInitializedError<LootLockerListDenominationsResponse>());
50315013
return;
50325014
}
50335015

5034-
var endpoint = string.Format(LootLockerEndPoints.getCurrencyDenominations.endPoint, currencyCode);
5016+
var endpoint = string.Format(LootLockerEndPoints.getCurrencyDenominationsByCode.endPoint, currencyCode);
50355017

5036-
LootLockerServerRequest.CallAPI(endpoint, LootLockerEndPoints.getCurrencyDenominations.httpMethod, onComplete: (serverResponse) => { LootLockerResponse.Deserialize(onComplete, serverResponse); });
5018+
LootLockerServerRequest.CallAPI(endpoint, LootLockerEndPoints.getCurrencyDenominationsByCode.httpMethod, onComplete: (serverResponse) => { LootLockerResponse.Deserialize(onComplete, serverResponse); });
50375019
}
50385020

50395021
#endregion
@@ -5042,54 +5024,94 @@ public static void GetCurrencyDenominations(string currencyCode, Action<LootLock
50425024
/// <summary>
50435025
/// Get a list of balances in a specified wallet
50445026
/// </summary>
5045-
/// <param name="walletID">Unique ID of the wallet to get balances for</param>
5027+
/// <param name="walletId">Unique ID of the wallet to get balances for</param>
50465028
/// <param name="onComplete">onComplete Action for handling the response</param>
5047-
public static void ListBalancesInWallet(string walletID, Action<LootLockerListBalancesForWalletResponse> onComplete)
5029+
public static void ListBalancesInWallet(string walletId, Action<LootLockerListBalancesForWalletResponse> onComplete)
50485030
{
50495031
if (!CheckInitialized())
50505032
{
50515033
onComplete?.Invoke(LootLockerResponseFactory.SDKNotInitializedError<LootLockerListBalancesForWalletResponse>());
50525034
return;
50535035
}
5054-
var endpoint = string.Format(LootLockerEndPoints.listBalancesInWallet.endPoint, walletID);
5036+
var endpoint = string.Format(LootLockerEndPoints.listBalancesInWallet.endPoint, walletId);
50555037

50565038
LootLockerServerRequest.CallAPI(endpoint, LootLockerEndPoints.listBalancesInWallet.httpMethod, onComplete: (serverResponse) => { LootLockerResponse.Deserialize(onComplete, serverResponse); });
50575039
}
50585040

50595041
/// <summary>
50605042
/// Get information about a specified wallet
50615043
/// </summary>
5062-
/// <param name="walletID">Unique ID of the wallet to get information for</param>
5044+
/// <param name="walletId">Unique ID of the wallet to get information for</param>
50635045
/// <param name="onComplete">onComplete Action for handling the response</param>
5064-
public static void GetWalletByWalletID(string walletID, Action<LootLockerGetWalletResponse> onComplete)
5046+
public static void GetWalletByWalletId(string walletId, Action<LootLockerGetWalletResponse> onComplete)
50655047
{
50665048
if (!CheckInitialized())
50675049
{
50685050
onComplete?.Invoke(LootLockerResponseFactory.SDKNotInitializedError<LootLockerGetWalletResponse>());
50695051
return;
50705052
}
5071-
var endpoint = string.Format(LootLockerEndPoints.getWalletByWalletId.endPoint, walletID);
5053+
var endpoint = string.Format(LootLockerEndPoints.getWalletByWalletId.endPoint, walletId);
50725054

50735055
LootLockerServerRequest.CallAPI(endpoint, LootLockerEndPoints.getWalletByWalletId.httpMethod, onComplete: (serverResponse) => { LootLockerResponse.Deserialize(onComplete, serverResponse); });
50745056
}
50755057

50765058
/// <summary>
50775059
/// Get information about a wallet for a specified holder
50785060
/// </summary>
5079-
/// <param name="holderID">Unique ID of the holder of the wallet you want to get information for</param>
5061+
/// <param name="holderId">Ulid of the holder of the wallet you want to get information for</param>
50805062
/// <param name="onComplete">onComplete Action for handling the response</param>
5081-
public static void GetWalletByHolderID(string holderID, Action<LootLockerGetWalletResponse> onComplete)
5063+
public static void GetWalletByHolderId(string holderId, Action<LootLockerGetWalletResponse> onComplete)
50825064
{
50835065
if (!CheckInitialized())
50845066
{
50855067
onComplete?.Invoke(LootLockerResponseFactory.SDKNotInitializedError<LootLockerGetWalletResponse>());
50865068
return;
50875069
}
5088-
var endpoint = string.Format(LootLockerEndPoints.getWalletByHolderId.endPoint, holderID);
5070+
var endpoint = string.Format(LootLockerEndPoints.getWalletByHolderId.endPoint, holderId);
50895071

50905072
LootLockerServerRequest.CallAPI(endpoint, LootLockerEndPoints.getWalletByHolderId.httpMethod, onComplete: (serverResponse) => { LootLockerResponse.Deserialize(onComplete, serverResponse); });
50915073
}
50925074

5075+
/// <summary>
5076+
/// Credit (increase) the specified amount of the provided currency to the provided wallet
5077+
/// </summary>
5078+
/// <param name="walletId">Unique ID of the wallet to credit the given amount of the given currency to</param>
5079+
/// <param name="currencyId">Unique ID of the currency to credit</param>
5080+
/// <param name="amount">The amount of the given currency to credit to the given wallet</param>
5081+
/// <param name="onComplete">onComplete Action for handling the response</param>
5082+
public static void CreditBalanceToWallet(string walletId, string currencyId, string amount, Action<LootLockerBalanceForWalletResponse> onComplete)
5083+
{
5084+
if (!CheckInitialized())
5085+
{
5086+
onComplete?.Invoke(LootLockerResponseFactory.SDKNotInitializedError<LootLockerBalanceForWalletResponse>());
5087+
return;
5088+
}
5089+
5090+
var json = LootLockerJson.SerializeObject(new LootLockerCreditRequest() { amount = amount, currency_id = currencyId, wallet_id = walletId });
5091+
5092+
LootLockerServerRequest.CallAPI(LootLockerEndPoints.creditBalanceToWallet.endPoint, LootLockerEndPoints.creditBalanceToWallet.httpMethod, json, onComplete: (serverResponse) => { LootLockerResponse.Deserialize(onComplete, serverResponse); });
5093+
}
5094+
5095+
/// <summary>
5096+
/// Debit (decrease) the specified amount of the provided currency to the provided wallet
5097+
/// </summary>
5098+
/// <param name="walletId">Unique ID of the wallet to debit the given amount of the given currency from</param>
5099+
/// <param name="currencyId">Unique ID of the currency to debit</param>
5100+
/// <param name="amount">The amount of the given currency to debit from the given wallet</param>
5101+
/// <param name="onComplete">onComplete Action for handling the response</param>
5102+
public static void DebitBalanceToWallet(string walletId, string currencyId, string amount, Action<LootLockerBalanceForWalletResponse> onComplete)
5103+
{
5104+
if (!CheckInitialized())
5105+
{
5106+
onComplete?.Invoke(LootLockerResponseFactory.SDKNotInitializedError<LootLockerBalanceForWalletResponse>());
5107+
return;
5108+
}
5109+
5110+
var json = LootLockerJson.SerializeObject(new LootLockerDebitRequest() { amount = amount, currency_id = currencyId, wallet_id = walletId });
5111+
5112+
LootLockerServerRequest.CallAPI(LootLockerEndPoints.debitBalanceToWallet.endPoint, LootLockerEndPoints.debitBalanceToWallet.httpMethod, json, onComplete: (serverResponse) => { LootLockerResponse.Deserialize(onComplete, serverResponse); });
5113+
}
5114+
50935115
#endregion
50945116

50955117
#region Catalog
@@ -5115,14 +5137,14 @@ public static void ListCatalogs(Action<LootLockerListCatalogsResponse> onComplet
51155137
/// <param name="count">Amount of catalog items to receive. Use null to simply get the default amount.</param>
51165138
/// <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>
51175139
/// <param name="onComplete">onComplete Action for handling the response</param>
5118-
public static void ListCatalogItems(string catalogKey, int count, string after, Action<LootLockerListCatalogItemsResponse> onComplete)
5140+
public static void ListCatalogItems(string catalogKey, int count, string after, Action<LootLockerListCatalogPricesResponse> onComplete)
51195141
{
51205142
if (!CheckInitialized())
51215143
{
5122-
onComplete?.Invoke(LootLockerResponseFactory.SDKNotInitializedError<LootLockerListCatalogItemsResponse>());
5144+
onComplete?.Invoke(LootLockerResponseFactory.SDKNotInitializedError<LootLockerListCatalogPricesResponse>());
51235145
return;
51245146
}
5125-
var endpoint = string.Format(LootLockerEndPoints.listCatalogItems.endPoint, catalogKey);
5147+
var endpoint = string.Format(LootLockerEndPoints.listCatalogItemsByKey.endPoint, catalogKey);
51265148

51275149
endpoint += "?";
51285150
if (count > 0)
@@ -5131,7 +5153,7 @@ public static void ListCatalogItems(string catalogKey, int count, string after,
51315153
if (!string.IsNullOrEmpty(after))
51325154
endpoint += $"cursor={after}&";
51335155

5134-
LootLockerServerRequest.CallAPI(endpoint, LootLockerEndPoints.listCatalogItems.httpMethod, onComplete: (serverResponse) => { LootLockerCatalogRequestUtils.ParseLootLockerListCatalogItemsResponse(onComplete, serverResponse); });
5156+
LootLockerServerRequest.CallAPI(endpoint, LootLockerEndPoints.listCatalogItemsByKey.httpMethod, onComplete: (serverResponse) => { onComplete?.Invoke(new LootLockerListCatalogPricesResponse(serverResponse)); });
51355157
}
51365158
#endregion
51375159

Runtime/Game/Requests/BalanceRequests.cs

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,52 @@ public class LootLockerBalance
3535
* The id of the wallet holding this balance
3636
*/
3737
public string wallet_id { get; set; }
38+
/*
39+
* The time that this balance was created
40+
*/
41+
public string created_at { get; set; }
42+
};
43+
44+
//==================================================
45+
// Request Definitions
46+
//==================================================
47+
48+
/*
49+
*
50+
*/
51+
public class LootLockerCreditRequest
52+
{
53+
/*
54+
* Amount of the given currency to debit/credit to/from the given wallet
55+
*/
56+
public string amount { get; set; }
57+
/*
58+
* The id of the currency that the amount is given in
59+
*/
60+
public string currency_id { get; set; }
61+
/*
62+
* The id of the wallet to credit/debit to/from
63+
*/
64+
public string wallet_id { get; set; }
65+
};
66+
67+
/*
68+
*
69+
*/
70+
public class LootLockerDebitRequest
71+
{
72+
/*
73+
* Amount of the given currency to debit/credit to/from the given wallet
74+
*/
75+
public string amount { get; set; }
76+
/*
77+
* The id of the currency that the amount is given in
78+
*/
79+
public string currency_id { get; set; }
80+
/*
81+
* The id of the wallet to credit/debit to/from
82+
*/
83+
public string wallet_id { get; set; }
3884
};
3985

4086
//==================================================
@@ -52,6 +98,17 @@ public class LootLockerListBalancesForWalletResponse : LootLockerResponse
5298
public LootLockerBalance[] balances { get; set; }
5399
};
54100

101+
/*
102+
*
103+
*/
104+
public class LootLockerBalanceForWalletResponse : LootLockerResponse
105+
{
106+
/*
107+
* The balance of the wallet
108+
*/
109+
public LootLockerBalance balance { get; set; }
110+
};
111+
55112
/*
56113
*
57114
*/

0 commit comments

Comments
 (0)