Skip to content

Commit f2691f4

Browse files
Erik Bylundkirre-bylund
authored andcommitted
Add support for currencies
1 parent 589b497 commit f2691f4

File tree

4 files changed

+199
-0
lines changed

4 files changed

+199
-0
lines changed

Runtime/Client/LootLockerEndPoints.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,12 @@ public class LootLockerEndPoints
234234
public static EndPointClass ComputeAndLockDropTable = new EndPointClass("v1/player/droptables/{0}/compute?asset_details={1}", LootLockerHTTPMethod.POST);
235235
public static EndPointClass PickDropsFromDropTable = new EndPointClass("v1/player/droptables/{0}/pick", LootLockerHTTPMethod.POST);
236236

237+
// Currencies
238+
[Header("Currencies")]
239+
public static EndPointClass listCurrencies = new EndPointClass("v1/currency", LootLockerHTTPMethod.GET);
240+
public static EndPointClass getCurrencyByCode = new EndPointClass("v1/currency/{0]", LootLockerHTTPMethod.GET);
241+
public static EndPointClass getCurrencyDenominations = new EndPointClass("v1/currency/{0}/denominations", LootLockerHTTPMethod.GET);
242+
237243
// Misc
238244
[Header("Misc")]
239245
public static EndPointClass ping = new EndPointClass("ping", LootLockerHTTPMethod.GET);

Runtime/Game/LootLockerSDKManager.cs

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
using static LootLocker.LootLockerConfig;
99
using System.Linq;
1010
using File = System.IO.File;
11+
using System.Net;
1112
#if UNITY_EDITOR
1213
using UnityEditor;
1314
#endif
@@ -4960,6 +4961,60 @@ public static void GetRemovedUGCForPlayer(GetRemovedUGCForPlayerInput input, Act
49604961

49614962
#endregion
49624963

4964+
#region Currency
4965+
/// <summary>
4966+
/// Get a list of available currencies for the game
4967+
/// </summary>
4968+
/// <param name="onComplete">onComplete Action for handling the response</param>
4969+
public static void ListCurrencies(Action<LootLockerListCurrenciesResponse> onComplete)
4970+
{
4971+
if (!CheckInitialized())
4972+
{
4973+
onComplete?.Invoke(LootLockerResponseFactory.SDKNotInitializedError<LootLockerListCurrenciesResponse>());
4974+
return;
4975+
}
4976+
4977+
LootLockerServerRequest.CallAPI(LootLockerEndPoints.listCurrencies.endPoint, LootLockerEndPoints.listCurrencies.httpMethod, onComplete: (serverResponse) => { LootLockerResponse.Deserialize(onComplete, serverResponse); });
4978+
}
4979+
4980+
/// <summary>
4981+
/// Get a specific currency by code
4982+
/// </summary>
4983+
/// <param name="currencyCode">The short code for the currency to fetch information for</param>
4984+
/// <param name="onComplete">onComplete Action for handling the response</param>
4985+
public static void GetCurrencyByCode(string currencyCode, Action<LootLockerGetCurrencyByCodeResponse> onComplete)
4986+
{
4987+
if (!CheckInitialized())
4988+
{
4989+
onComplete?.Invoke(LootLockerResponseFactory.SDKNotInitializedError<LootLockerGetCurrencyByCodeResponse>());
4990+
return;
4991+
}
4992+
4993+
var endpoint = string.Format(LootLockerEndPoints.getCurrencyByCode.endPoint, currencyCode);
4994+
4995+
LootLockerServerRequest.CallAPI(endpoint, LootLockerEndPoints.getCurrencyByCode.httpMethod, onComplete: (serverResponse) => { LootLockerResponse.Deserialize(onComplete, serverResponse); });
4996+
}
4997+
4998+
/// <summary>
4999+
/// Get a list of the denominations available for a specific currency
5000+
/// </summary>
5001+
/// <param name="currencyCode">The short code for the currency to fetch denominations for</param>
5002+
/// <param name="onComplete">onComplete Action for handling the response</param>
5003+
public static void GetCurrencyDenominations(string currencyCode, Action<LootLockerListDenominationsResponse> onComplete)
5004+
{
5005+
if (!CheckInitialized())
5006+
{
5007+
onComplete?.Invoke(LootLockerResponseFactory.SDKNotInitializedError<LootLockerListDenominationsResponse>());
5008+
return;
5009+
}
5010+
5011+
var endpoint = string.Format(LootLockerEndPoints.getCurrencyDenominations.endPoint, currencyCode);
5012+
5013+
LootLockerServerRequest.CallAPI(endpoint, LootLockerEndPoints.getCurrencyDenominations.httpMethod, onComplete: (serverResponse) => { LootLockerResponse.Deserialize(onComplete, serverResponse); });
5014+
}
5015+
5016+
#endregion
5017+
49635018
#region Misc
49645019

49655020
/// <summary>
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
using LootLocker.LootLockerEnums;
2+
using System.Collections;
3+
using System.Collections.Generic;
4+
using UnityEngine;
5+
6+
namespace LootLocker.Requests
7+
{
8+
//==================================================
9+
// Data Definitions
10+
//==================================================
11+
12+
/*
13+
* Information about a particular currency
14+
*/
15+
public class LootLockerCurrency : LootLockerResponse
16+
{
17+
/*
18+
* The time when this currency was created
19+
*/
20+
public string created_at { get; set; }
21+
/*
22+
* The unique id of the currency
23+
*/
24+
public string id { get; set; }
25+
/*
26+
* The name of the currency
27+
*/
28+
public string name { get; set; }
29+
/*
30+
* The unique short code of the currency
31+
*/
32+
public string code { get; set; }
33+
/*
34+
* Whether this currency is published or not
35+
*/
36+
public bool published { get; set; }
37+
/*
38+
* The time when this currency was published (if it was)
39+
*/
40+
public string published_at { get; set; }
41+
};
42+
43+
/*
44+
* Represents a denomination of a currency
45+
*/
46+
public class LootLockerDenomination : LootLockerResponse
47+
{
48+
/*
49+
* The time when this denomination was created
50+
*/
51+
public string created_at { get; set; }
52+
/*
53+
* The unique id of the denomination
54+
*/
55+
public string id { get; set; }
56+
/*
57+
* The id of the currency this is a denomination of
58+
*/
59+
public string currency { get; set; }
60+
/*
61+
* The name of this denomination
62+
*/
63+
public string name { get; set; }
64+
/*
65+
* The value of this denomination in units of the currency
66+
*/
67+
public int value { get; set; }
68+
};
69+
70+
//==================================================
71+
// Response Definitions
72+
//==================================================
73+
74+
/*
75+
*
76+
*/
77+
public class LootLockerGetCurrencyByCodeResponse : LootLockerResponse
78+
{
79+
/*
80+
* The time when this currency was created
81+
*/
82+
public string created_at { get; set; }
83+
/*
84+
* The unique id of the currency
85+
*/
86+
public string id { get; set; }
87+
/*
88+
* The name of the currency
89+
*/
90+
public string name { get; set; }
91+
/*
92+
* The unique short code of the currency
93+
*/
94+
public string code { get; set; }
95+
/*
96+
* Whether this currency is published or not
97+
*/
98+
public bool published { get; set; }
99+
/*
100+
* The time when this currency was published (if it was)
101+
*/
102+
public string published_at { get; set; }
103+
};
104+
105+
/*
106+
*
107+
*/
108+
public class LootLockerListCurrenciesResponse : LootLockerResponse
109+
{
110+
/*
111+
* List of available currencies
112+
*/
113+
public LootLockerCurrency[] currencies { get; set; }
114+
};
115+
116+
/*
117+
*
118+
*/
119+
public class LootLockerListDenominationsResponse : LootLockerResponse
120+
{
121+
/*
122+
* List of available denominations
123+
*/
124+
public LootLockerDenomination[] denominations { get; set; }
125+
};
126+
127+
}

Runtime/Game/Requests/CurrencyRequests.cs.meta

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