Skip to content

Commit 1967297

Browse files
Implement asset instance progressions methods
1 parent 6dc6b09 commit 1967297

File tree

3 files changed

+197
-0
lines changed

3 files changed

+197
-0
lines changed

Runtime/Client/LootLockerEndPoints.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,15 @@ public class LootLockerEndPoints
124124
public static EndPointClass inspectALootBox = new EndPointClass("v1/asset/instance/{0}/inspect", LootLockerHTTPMethod.GET);
125125
public static EndPointClass openALootBox = new EndPointClass("v1/asset/instance/{0}/open", LootLockerHTTPMethod.PUT);
126126

127+
// Asset instance progressions
128+
[Header("Asset instance progressions")]
129+
public static EndPointClass getAllAssetInstanceProgressions = new EndPointClass("player/assets/instances/{0}/progressions", LootLockerHTTPMethod.GET);
130+
public static EndPointClass getSingleAssetInstanceProgression = new EndPointClass("player/assets/instances/{0}/progressions/{1}", LootLockerHTTPMethod.GET);
131+
public static EndPointClass addPointsToAssetInstanceProgression = new EndPointClass("player/assets/instances/{0}/progressions/{1}/points/add", LootLockerHTTPMethod.POST);
132+
public static EndPointClass subtractPointsFromAssetInstanceProgression = new EndPointClass("player/assets/instances/{0}/progressions/{1}/points/subtract", LootLockerHTTPMethod.POST);
133+
public static EndPointClass resetAssetInstanceProgression = new EndPointClass("player/assets/instances/{0}/progressions/{1}/reset", LootLockerHTTPMethod.POST);
134+
public static EndPointClass deleteAssetInstanceProgression = new EndPointClass("player/assets/instances/{0}/progressions/{1}", LootLockerHTTPMethod.DELETE);
135+
127136
// UGC
128137
[Header("UGC")]
129138
public static EndPointClass creatingAnAssetCandidate = new EndPointClass("v1/player/assets/candidates", LootLockerHTTPMethod.POST);

Runtime/Game/LootLockerSDKManager.cs

Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2900,6 +2900,159 @@ public static void OpenALootBoxForAssetInstances(int assetInstanceID, Action<Loo
29002900
LootLockerAPIManager.OpenALootBox(data, onComplete);
29012901
}
29022902
#endregion
2903+
2904+
#region AssetInstance progressions
2905+
2906+
/// <summary>
2907+
/// Returns multiple progressions for an asset instance.
2908+
/// </summary>
2909+
/// <param name="assetInstanceId">ID of the asset instance</param>
2910+
/// <param name="count">Amount of entries to receive</param>
2911+
/// <param name="after">Used for pagination, ID of the asset instance progression from which the pagination starts from, use the next_cursor and previous_cursor values</param>
2912+
/// <param name="onComplete">onComplete Action for handling the response of type LootLockerPaginatedAssetInstanceProgressions</param>
2913+
public static void GetAssetInstanceProgressions(int assetInstanceId, int count, string after, Action<LootLockerPaginatedAssetInstanceProgressionsResponse> onComplete)
2914+
{
2915+
if (!CheckInitialized())
2916+
{
2917+
onComplete?.Invoke(LootLockerResponseFactory.SDKNotInitializedError<LootLockerPaginatedAssetInstanceProgressionsResponse>());
2918+
return;
2919+
}
2920+
2921+
var endpoint = string.Format(LootLockerEndPoints.getAllAssetInstanceProgressions.endPoint, assetInstanceId);
2922+
2923+
endpoint += "?";
2924+
if (count > 0)
2925+
endpoint += $"count={count}&";
2926+
2927+
if (!string.IsNullOrEmpty(after))
2928+
endpoint += $"after={after}&";
2929+
2930+
LootLockerServerRequest.CallAPI(endpoint, LootLockerHTTPMethod.GET, onComplete: (serverResponse) => { LootLockerResponse.Deserialize(onComplete, serverResponse); });
2931+
}
2932+
2933+
/// <summary>
2934+
/// Returns multiple progressions for an asset instance.
2935+
/// </summary>
2936+
/// <param name="assetInstanceId">ID of the asset instance</param>
2937+
/// <param name="count">Amount of entries to receive</param>
2938+
/// <param name="onComplete">onComplete Action for handling the response of type LootLockerPaginatedAssetInstanceProgressions</param>
2939+
public static void GetAssetInstanceProgressions(int assetInstanceId, int count, Action<LootLockerPaginatedAssetInstanceProgressionsResponse> onComplete)
2940+
{
2941+
GetAssetInstanceProgressions(assetInstanceId, count, null, onComplete);
2942+
}
2943+
2944+
/// <summary>
2945+
/// Returns multiple progressions for an asset instance.
2946+
/// </summary>
2947+
/// <param name="assetInstanceId">ID of the asset instance</param>
2948+
/// <param name="onComplete">onComplete Action for handling the response of type LootLockerPaginatedAssetInstanceProgressions</param>
2949+
public static void GetAssetInstanceProgressions(int assetInstanceId, Action<LootLockerPaginatedAssetInstanceProgressionsResponse> onComplete)
2950+
{
2951+
GetAssetInstanceProgressions(assetInstanceId, -1, null, onComplete);
2952+
}
2953+
2954+
/// <summary>
2955+
/// Returns multiple progressions for an asset instance.
2956+
/// </summary>
2957+
/// <param name="assetInstanceId">ID of the asset instance</param>
2958+
/// <param name="progressionKey">Progression key</param>
2959+
/// <param name="onComplete">onComplete Action for handling the response of type LootLockerAssetInstanceProgression</param>
2960+
public static void GetAssetInstanceProgression(int assetInstanceId, string progressionKey, Action<LootLockerAssetInstanceProgressionResponse> onComplete)
2961+
{
2962+
if (!CheckInitialized())
2963+
{
2964+
onComplete?.Invoke(LootLockerResponseFactory.SDKNotInitializedError<LootLockerAssetInstanceProgressionResponse>());
2965+
return;
2966+
}
2967+
2968+
var endpoint = string.Format(LootLockerEndPoints.getSingleAssetInstanceProgression.endPoint, assetInstanceId, progressionKey);
2969+
2970+
LootLockerServerRequest.CallAPI(endpoint, LootLockerHTTPMethod.GET, onComplete: (serverResponse) => { LootLockerResponse.Deserialize(onComplete, serverResponse); });
2971+
}
2972+
2973+
/// <summary>
2974+
/// Adds points to an asset instance progression.
2975+
/// </summary>
2976+
/// <param name="assetInstanceId">ID of the asset instance</param>
2977+
/// <param name="progressionKey">Progression key</param>
2978+
/// <param name="amount">Amount of points to add</param>
2979+
/// <param name="onComplete">onComplete Action for handling the response of type LootLockerAssetInstanceProgressionWithRewards</param>
2980+
public static void AddPointsToAssetInstanceProgression(int assetInstanceId, string progressionKey, ulong amount, Action<LootLockerAssetInstanceProgressionWithRewardsResponse> onComplete)
2981+
{
2982+
if (!CheckInitialized())
2983+
{
2984+
onComplete?.Invoke(LootLockerResponseFactory.SDKNotInitializedError<LootLockerAssetInstanceProgressionWithRewardsResponse>());
2985+
return;
2986+
}
2987+
2988+
var endpoint = string.Format(LootLockerEndPoints.addPointsToAssetInstanceProgression.endPoint, assetInstanceId, progressionKey);
2989+
2990+
var body = LootLockerJson.SerializeObject(new { amount });
2991+
2992+
LootLockerServerRequest.CallAPI(endpoint, LootLockerHTTPMethod.POST, body, onComplete: (serverResponse) => { LootLockerResponse.Deserialize(onComplete, serverResponse); });
2993+
}
2994+
2995+
/// <summary>
2996+
/// Subtracts points from an asset instance progression.
2997+
/// </summary>
2998+
/// <param name="assetInstanceId">ID of the asset instance</param>
2999+
/// <param name="progressionKey">Progression key</param>
3000+
/// <param name="amount">Amount of points to subtract</param>
3001+
/// <param name="onComplete">onComplete Action for handling the response of type LootLockerAssetInstanceProgressionWithRewards</param>
3002+
public static void SubtractPointsFromAssetInstanceProgression(int assetInstanceId, string progressionKey, ulong amount, Action<LootLockerAssetInstanceProgressionWithRewardsResponse> onComplete)
3003+
{
3004+
if (!CheckInitialized())
3005+
{
3006+
onComplete?.Invoke(LootLockerResponseFactory.SDKNotInitializedError<LootLockerAssetInstanceProgressionWithRewardsResponse>());
3007+
return;
3008+
}
3009+
3010+
var endpoint = string.Format(LootLockerEndPoints.subtractPointsFromAssetInstanceProgression.endPoint, assetInstanceId, progressionKey);
3011+
3012+
var body = LootLockerJson.SerializeObject(new { amount });
3013+
3014+
LootLockerServerRequest.CallAPI(endpoint, LootLockerHTTPMethod.POST, body, onComplete: (serverResponse) => { LootLockerResponse.Deserialize(onComplete, serverResponse); });
3015+
}
3016+
3017+
/// <summary>
3018+
/// Resets an asset instance progression.
3019+
/// </summary>
3020+
/// <param name="assetInstanceId">ID of the asset instance</param>
3021+
/// <param name="progressionKey">Progression key</param>
3022+
/// <param name="onComplete">onComplete Action for handling the response of type LootLockerAssetInstanceProgressionWithRewards</param>
3023+
public static void ResetAssetInstanceProgression(int assetInstanceId, string progressionKey, Action<LootLockerAssetInstanceProgressionWithRewardsResponse> onComplete)
3024+
{
3025+
if (!CheckInitialized())
3026+
{
3027+
onComplete?.Invoke(LootLockerResponseFactory.SDKNotInitializedError<LootLockerAssetInstanceProgressionWithRewardsResponse>());
3028+
return;
3029+
}
3030+
3031+
var endpoint = string.Format(LootLockerEndPoints.resetAssetInstanceProgression.endPoint, assetInstanceId, progressionKey);
3032+
3033+
LootLockerServerRequest.CallAPI(endpoint, LootLockerHTTPMethod.POST, onComplete: (serverResponse) => { LootLockerResponse.Deserialize(onComplete, serverResponse); });
3034+
}
3035+
3036+
/// <summary>
3037+
/// Deletes an asset instance progression.
3038+
/// </summary>
3039+
/// <param name="assetInstanceId">ID of the asset instance</param>
3040+
/// <param name="progressionKey">Progression key</param>
3041+
/// <param name="onComplete">onComplete Action for handling the response of type LootLockerResponse</param>
3042+
public static void DeleteAssetInstanceProgression(int assetInstanceId, string progressionKey, Action<LootLockerResponse> onComplete)
3043+
{
3044+
if (!CheckInitialized())
3045+
{
3046+
onComplete?.Invoke(LootLockerResponseFactory.SDKNotInitializedError<LootLockerResponse>());
3047+
return;
3048+
}
3049+
3050+
var endpoint = string.Format(LootLockerEndPoints.deleteAssetInstanceProgression.endPoint, assetInstanceId, progressionKey);
3051+
3052+
LootLockerServerRequest.CallAPI(endpoint, LootLockerHTTPMethod.DELETE, onComplete: (serverResponse) => { LootLockerResponse.Deserialize(onComplete, serverResponse); });
3053+
}
3054+
3055+
#endregion
29033056

29043057
#region UserGeneratedContent
29053058
/// <summary>

Runtime/Game/Requests/ProgressionsRequest.cs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,41 @@ public class LootLockerCharacterProgressionWithRewardsResponse : LootLockerChara
9494
{
9595
public List<LootLockerAwardedTier> awarded_tiers { get; set; }
9696
}
97+
98+
public class LootLockerAssetInstanceProgressionResponse : LootLockerResponse
99+
{
100+
public string id { get; set; }
101+
public string progression_key { get; set; }
102+
public string progression_name { get; set; }
103+
public ulong step { get; set; }
104+
public ulong points { get; set; }
105+
public ulong previous_threshold { get; set; }
106+
public ulong? next_threshold { get; set; }
107+
public DateTime? last_level_up { get; set; }
108+
}
109+
110+
public class LootLockerPaginatedAssetInstanceProgressionsResponse : LootLockerResponse
111+
{
112+
public LootLockerPaginationResponse<string> pagination { get; set; }
113+
public List<LootLockerAssetInstanceProgression> items { get; set; }
114+
115+
public class LootLockerAssetInstanceProgression
116+
{
117+
public string id { get; set; }
118+
public string progression_key { get; set; }
119+
public string progression_name { get; set; }
120+
public ulong step { get; set; }
121+
public ulong points { get; set; }
122+
public ulong previous_threshold { get; set; }
123+
public ulong? next_threshold { get; set; }
124+
public DateTime? last_level_up { get; set; }
125+
}
126+
}
127+
128+
public class LootLockerAssetInstanceProgressionWithRewardsResponse : LootLockerAssetInstanceProgressionResponse
129+
{
130+
public List<LootLockerAwardedTier> awarded_tiers { get; set; }
131+
}
97132

98133
public class LootLockerAwardedTier
99134
{

0 commit comments

Comments
 (0)