Skip to content

Commit 2d45198

Browse files
Erik Bylundkirre-bylund
authored andcommitted
feature: Add support for getting multisource metadata
1 parent 79ce5a9 commit 2d45198

File tree

3 files changed

+104
-3
lines changed

3 files changed

+104
-3
lines changed

Runtime/Client/LootLockerEndPoints.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,7 @@ public class LootLockerEndPoints
295295
// Metadata
296296
[Header("Metadata")]
297297
public static EndPointClass listMetadata = new EndPointClass("metadata/source/{0}/id/{1}", LootLockerHTTPMethod.GET);
298+
public static EndPointClass getMultisourceMetadata = new EndPointClass("metadata/multisource", LootLockerHTTPMethod.POST);
298299

299300
}
300301
}

Runtime/Game/LootLockerSDKManager.cs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5854,8 +5854,25 @@ public static void GetMetadata(LootLockerMetadataSources Source, string SourceID
58545854
});
58555855
});
58565856
}
5857+
5858+
/// <summary>
5859+
/// List the requested page of Metadata for the specified source that has all of the provided tags and paginate according to the supplied pagination settings
5860+
/// </summary>
5861+
/// <param name="SourcesAndKeysToGet> The combination of sources to get keys for, and the keys to get for those sources </param>
5862+
/// <param name="OnComplete> delegate for handling the server response</param>
5863+
/// <param name="IgnoreFiles> Optional: Base64 values will be set to content_type "application/x-redacted" and the content will be an empty String. Use this to avoid accidentally fetching large data files.</param>
5864+
public static void GetMultisourceMetadata(LootLockerMetadataSourceAndKeys[] SourcesAndKeysToGet, Action<LootLockerGetMultisourceMetadataResponse> onComplete, bool ignoreFiles = false)
5865+
{
5866+
if (!CheckInitialized())
5867+
{
5868+
onComplete?.Invoke(LootLockerResponseFactory.SDKNotInitializedError<LootLockerGetMultisourceMetadataResponse>());
5869+
return;
5870+
}
5871+
5872+
LootLockerAPIManager.GetMultisourceMetadata(SourcesAndKeysToGet, ignoreFiles, onComplete);
5873+
}
58575874
#endif
5858-
#endregion
5875+
#endregion
58595876

58605877
#region Misc
58615878

Runtime/Game/Requests/MetadataRequests.cs

Lines changed: 85 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
using LootLocker.LootLockerEnums;
1+
using System;
2+
using LootLocker.LootLockerEnums;
23
using LootLocker.Requests;
3-
using System;
44

55
#if LOOTLOCKER_USE_NEWTONSOFTJSON
66
using Newtonsoft.Json.Linq;
@@ -192,10 +192,56 @@ public bool TryGetValueAsBase64(out LootLockerMetadataBase64Value output)
192192
}
193193
}
194194

195+
/// <summary>
196+
/// </summary>
197+
public class LootLockerMetadataSourceAndKeys
198+
{
199+
/// <summary>
200+
/// The type of source that the source id refers to
201+
/// </summary>
202+
public LootLockerMetadataSources source { get; set; }
203+
/// <summary>
204+
/// The id of the specific source that the set operation was taken on
205+
/// </summary>
206+
public string id { get; set; }
207+
/// <summary>
208+
/// A list of keys existing on the specified source
209+
/// </summary>
210+
public string[] keys { get; set; }
211+
}
212+
213+
/// <summary>
214+
/// </summary>
215+
public class LootLockerMetadataSourceAndEntries
216+
{
217+
/// <summary>
218+
/// The type of source that the source id refers to
219+
/// </summary>
220+
public LootLockerMetadataSources source { get; set; }
221+
/// <summary>
222+
/// The id of the specific source that the set operation was taken on
223+
/// </summary>
224+
public string source_id { get; set; }
225+
/// <summary>
226+
/// A list of keys existing on the specified source
227+
/// </summary>
228+
public LootLockerMetadataEntry[] entries { get; set; }
229+
}
230+
195231
//==================================================
196232
// Request Definitions
197233
//==================================================
198234

235+
/// <summary>
236+
/// </summary>
237+
public class LootLockerGetMultisourceMetadataRequest
238+
{
239+
/// <summary>
240+
/// The source & key combos to get
241+
/// </summary>
242+
public LootLockerMetadataSourceAndKeys[] sources { get; set; }
243+
}
244+
199245
//==================================================
200246
// Response Definitions
201247
//==================================================
@@ -222,6 +268,16 @@ public class LootLockerGetMetadataResponse : LootLockerResponse
222268
/// </summary>
223269
public LootLockerMetadataEntry entry { get; set; }
224270
};
271+
272+
/// <summary>
273+
/// </summary>
274+
public class LootLockerGetMultisourceMetadataResponse : LootLockerResponse
275+
{
276+
/// <summary>
277+
/// The requested sources with the requested entries for each source
278+
/// </summary>
279+
public LootLockerMetadataSourceAndEntries[] Metadata { get; set; }
280+
};
225281
}
226282

227283
//==================================================
@@ -260,5 +316,32 @@ public static void ListMetadata(LootLockerMetadataSources Source, string SourceI
260316
LootLockerResponse.Deserialize<LootLockerListMetadataResponse>(onComplete, serverResponse);
261317
});
262318
}
319+
public static void GetMultisourceMetadata(LootLockerMetadataSourceAndKeys[] SourcesAndKeysToGet, bool ignoreFiles, Action<LootLockerGetMultisourceMetadataResponse> onComplete)
320+
{
321+
if (SourcesAndKeysToGet == null)
322+
{
323+
onComplete?.Invoke(LootLockerResponseFactory.InputUnserializableError<LootLockerGetMultisourceMetadataResponse>());
324+
return;
325+
}
326+
string endpoint = LootLockerEndPoints.getMultisourceMetadata.endPoint;
327+
328+
string queryParams = "";
329+
if (ignoreFiles) { queryParams += $"ignore_files=true"; } else { queryParams += $"ignore_files=false"; }
330+
331+
if (!string.IsNullOrEmpty(queryParams))
332+
{
333+
queryParams = $"?{queryParams}";
334+
endpoint += queryParams;
335+
}
336+
337+
LootLockerGetMultisourceMetadataRequest request = new LootLockerGetMultisourceMetadataRequest { sources = SourcesAndKeysToGet };
338+
339+
string json = LootLockerJson.SerializeObject(request);
340+
LootLockerServerRequest.CallAPI(endpoint, LootLockerEndPoints.getMultisourceMetadata.httpMethod, json, onComplete:
341+
(serverResponse) =>
342+
{
343+
LootLockerResponse.Deserialize<LootLockerGetMultisourceMetadataResponse>(onComplete, serverResponse);
344+
});
345+
}
263346
}
264347
}

0 commit comments

Comments
 (0)