Skip to content

Commit bd0657a

Browse files
committed
fix: Upgrade to index based pagination in catalogs
1 parent 0cc33d1 commit bd0657a

File tree

3 files changed

+348
-3
lines changed

3 files changed

+348
-3
lines changed

Runtime/Client/LootLockerEndPoints.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,8 @@ public class LootLockerEndPoints
273273
// Catalogs
274274
[Header("Catalogs")]
275275
public static EndPointClass listCatalogs = new EndPointClass("catalogs", LootLockerHTTPMethod.GET);
276-
public static EndPointClass listCatalogItemsByKey = new EndPointClass("catalog/key/{0}/prices", LootLockerHTTPMethod.GET);
276+
public static EndPointClass deprecatedListCatalogItemsByKey = new EndPointClass("catalog/key/{0}/prices", LootLockerHTTPMethod.GET);
277+
public static EndPointClass listCatalogItemsByKey = new EndPointClass("catalogs/inspired-ibex/v1/catalog/key/{key}/list", LootLockerHTTPMethod.GET);
277278

278279
// Misc
279280
[Header("Misc")]

Runtime/Game/LootLockerSDKManager.cs

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8012,14 +8012,15 @@ public static void ListCatalogs(Action<LootLockerListCatalogsResponse> onComplet
80128012
/// <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>
80138013
/// <param name="onComplete">onComplete Action for handling the response</param>
80148014
/// <param name="forPlayerWithUlid">Optional : Execute the request for the specified player. If not supplied, the default player will be used.</param>
8015+
[Obsolete("This method is deprecated, please use ListCatalogItems(string catalogKey, int PerPage, int Page, Action<LootLockerListCatalogPricesV2Response> onComplete, string forPlayerWithUlid = null) instead.")] // Deprecation date 20251016
80158016
public static void ListCatalogItems(string catalogKey, int count, string after, Action<LootLockerListCatalogPricesResponse> onComplete, string forPlayerWithUlid = null)
80168017
{
80178018
if (!CheckInitialized(false, forPlayerWithUlid))
80188019
{
80198020
onComplete?.Invoke(LootLockerResponseFactory.SDKNotInitializedError<LootLockerListCatalogPricesResponse>(forPlayerWithUlid));
80208021
return;
80218022
}
8022-
var endpoint = LootLockerEndPoints.listCatalogItemsByKey.WithPathParameter(catalogKey);
8023+
var endpoint = LootLockerEndPoints.deprecatedListCatalogItemsByKey.WithPathParameter(catalogKey);
80238024

80248025
var queryParams = new LootLocker.Utilities.HTTP.QueryParamaterBuilder();
80258026
if (count > 0)
@@ -8029,7 +8030,35 @@ public static void ListCatalogItems(string catalogKey, int count, string after,
80298030

80308031
endpoint += queryParams.Build();
80318032

8032-
LootLockerServerRequest.CallAPI(forPlayerWithUlid, endpoint, LootLockerEndPoints.listCatalogItemsByKey.httpMethod, onComplete: (serverResponse) => { onComplete?.Invoke(new LootLockerListCatalogPricesResponse(serverResponse)); });
8033+
LootLockerServerRequest.CallAPI(forPlayerWithUlid, endpoint, LootLockerEndPoints.deprecatedListCatalogItemsByKey.httpMethod, onComplete: (serverResponse) => { onComplete?.Invoke(new LootLockerListCatalogPricesResponse(serverResponse)); });
8034+
}
8035+
8036+
/// <summary>
8037+
/// List the items available in a specific catalog
8038+
/// </summary>
8039+
/// <param name="catalogKey">Unique Key of the catalog that you want to get items for</param>
8040+
/// <param name="PerPage">The number of results to return per page</param>
8041+
/// <param name="Page">The page number to retrieve</param>
8042+
/// <param name="onComplete">onComplete Action for handling the response</param>
8043+
/// <param name="forPlayerWithUlid">Optional : Execute the request for the specified player. If not supplied, the default player will be used.</param>
8044+
public static void ListCatalogItems(string catalogKey, int PerPage, int Page, Action<LootLockerListCatalogPricesV2Response> onComplete, string forPlayerWithUlid = null)
8045+
{
8046+
if (!CheckInitialized(false, forPlayerWithUlid))
8047+
{
8048+
onComplete?.Invoke(LootLockerResponseFactory.SDKNotInitializedError<LootLockerListCatalogPricesV2Response>(forPlayerWithUlid));
8049+
return;
8050+
}
8051+
var endpoint = LootLockerEndPoints.listCatalogItemsByKey.WithPathParameter(catalogKey);
8052+
8053+
var queryParams = new LootLocker.Utilities.HTTP.QueryParamaterBuilder();
8054+
if (PerPage > 0)
8055+
queryParams.Add("per_page", PerPage);
8056+
if (Page > 0)
8057+
queryParams.Add("page", Page);
8058+
8059+
endpoint += queryParams.Build();
8060+
8061+
LootLockerServerRequest.CallAPI(forPlayerWithUlid, endpoint, LootLockerEndPoints.listCatalogItemsByKey.httpMethod, onComplete: (serverResponse) => { onComplete?.Invoke(new LootLockerListCatalogPricesV2Response(serverResponse)); });
80338062
}
80348063
#endregion
80358064

Runtime/Game/Requests/CatalogRequests.cs

Lines changed: 315 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -772,4 +772,319 @@ public LootLockerInlinedCatalogEntry[] GetLootLockerInlinedCatalogEntries()
772772
return inlinedEntries.ToArray();
773773
}
774774
}
775+
776+
/// <summary>
777+
/// </summary>
778+
public class LootLockerListCatalogPricesV2Response : LootLockerResponse
779+
{
780+
/// <summary>
781+
/// Details about the catalog that the prices is in
782+
/// </summary>
783+
public LootLockerCatalog catalog { get; set; }
784+
785+
/// <summary>
786+
/// A list of entries available in this catalog
787+
/// </summary>
788+
public LootLockerCatalogEntry[] entries { get; set; }
789+
790+
/// <summary>
791+
/// Lookup map for details about entities of entity type assets
792+
/// </summary>
793+
public Dictionary<LootLockerItemDetailsKey, LootLockerAssetDetails> asset_details { get; set; }
794+
795+
/// <summary>
796+
/// Lookup map for details about entities of entity type progression_points
797+
/// </summary>
798+
public Dictionary<LootLockerItemDetailsKey, LootLockerProgressionPointDetails> progression_points_details
799+
{
800+
get;
801+
set;
802+
}
803+
804+
/// <summary>
805+
/// Lookup map for details about entities of entity type progression_reset
806+
/// </summary>
807+
public Dictionary<LootLockerItemDetailsKey, LootLockerProgressionResetDetails> progression_resets_details
808+
{
809+
get;
810+
set;
811+
}
812+
813+
/// <summary>
814+
/// Lookup map for details about entities of entity type currency
815+
/// </summary>
816+
public Dictionary<LootLockerItemDetailsKey, LootLockerCurrencyDetails> currency_details { get; set; }
817+
818+
/// <summary>
819+
/// Lookup map for details about entities of entity type group
820+
/// </summary>
821+
public Dictionary<LootLockerItemDetailsKey, LootLockerGroupDetails> group_details { get; set; }
822+
823+
/// <summary>
824+
/// Pagination data to use for subsequent requests
825+
/// </summary>
826+
public LootLockerExtendedPagination pagination { get; set; }
827+
828+
public void AppendCatalogItems(LootLockerListCatalogPricesV2Response catalogPrices)
829+
{
830+
var concatenatedArray = new LootLockerCatalogEntry[entries.Length + catalogPrices.entries.Length];
831+
entries.CopyTo(concatenatedArray, 0);
832+
catalogPrices.entries.CopyTo(concatenatedArray, entries.Length);
833+
pagination.total = catalogPrices.pagination.total;
834+
pagination.offset = catalogPrices.pagination.offset;
835+
pagination.per_page = catalogPrices.pagination.per_page;
836+
pagination.last_page = catalogPrices.pagination.last_page;
837+
pagination.current_page = catalogPrices.pagination.current_page;
838+
pagination.next_page = catalogPrices.pagination.next_page;
839+
pagination.prev_page = catalogPrices.pagination.prev_page;
840+
pagination.errors = catalogPrices.pagination.errors;
841+
842+
foreach (var assetDetail in catalogPrices.asset_details)
843+
{
844+
asset_details.Add(assetDetail.Key, assetDetail.Value);
845+
}
846+
847+
foreach (var progressionPointDetail in catalogPrices.progression_points_details)
848+
{
849+
progression_points_details.Add(progressionPointDetail.Key, progressionPointDetail.Value);
850+
}
851+
852+
foreach (var progressionResetDetail in catalogPrices.progression_resets_details)
853+
{
854+
progression_resets_details.Add(progressionResetDetail.Key, progressionResetDetail.Value);
855+
}
856+
857+
foreach (var currencyDetail in catalogPrices.currency_details)
858+
{
859+
currency_details.Add(currencyDetail.Key, currencyDetail.Value);
860+
}
861+
862+
foreach (var groupDetail in catalogPrices.group_details)
863+
{
864+
group_details.Add(groupDetail.Key, groupDetail.Value);
865+
}
866+
867+
}
868+
869+
public LootLockerListCatalogPricesV2Response() { }
870+
871+
/// This is the way that the response actually looks, but we don't want to expose it, hence the conversion
872+
private class LootLockerListCatalogItemsWithArraysResponse : LootLockerResponse
873+
{
874+
public LootLockerCatalog catalog { get; set; }
875+
public LootLockerCatalogEntry[] entries { get; set; }
876+
public LootLockerAssetDetails[] assets_details { get; set; }
877+
public LootLockerProgressionPointDetails[] progression_points_details { get; set; }
878+
public LootLockerProgressionResetDetails[] progression_resets_details { get; set; }
879+
public LootLockerCurrencyDetails[] currency_details { get; set; }
880+
public LootLockerGroupDetails[] group_details { get; set; }
881+
public LootLockerExtendedPagination pagination { get; set; }
882+
}
883+
884+
public LootLockerListCatalogPricesV2Response(LootLockerResponse serverResponse)
885+
{
886+
LootLockerListCatalogItemsWithArraysResponse parsedResponse =
887+
Deserialize<LootLockerListCatalogItemsWithArraysResponse>(serverResponse);
888+
success = parsedResponse.success;
889+
statusCode = parsedResponse.statusCode;
890+
text = parsedResponse.text;
891+
errorData = parsedResponse.errorData;
892+
if (!success)
893+
{
894+
return;
895+
}
896+
897+
catalog = parsedResponse.catalog;
898+
entries = parsedResponse.entries;
899+
pagination = parsedResponse.pagination;
900+
901+
if (parsedResponse.assets_details != null && parsedResponse.assets_details.Length > 0)
902+
{
903+
asset_details = new Dictionary<LootLockerItemDetailsKey, LootLockerAssetDetails>();
904+
foreach (var detail in parsedResponse.assets_details)
905+
{
906+
asset_details[detail.GetItemDetailsKey()] = detail;
907+
}
908+
}
909+
910+
if (parsedResponse.progression_points_details != null &&
911+
parsedResponse.progression_points_details.Length > 0)
912+
{
913+
progression_points_details = new Dictionary<LootLockerItemDetailsKey, LootLockerProgressionPointDetails>();
914+
foreach (var detail in parsedResponse.progression_points_details)
915+
{
916+
progression_points_details[detail.GetItemDetailsKey()] = detail;
917+
}
918+
}
919+
920+
if (parsedResponse.progression_resets_details != null &&
921+
parsedResponse.progression_resets_details.Length > 0)
922+
{
923+
progression_resets_details = new Dictionary<LootLockerItemDetailsKey, LootLockerProgressionResetDetails>();
924+
foreach (var detail in parsedResponse.progression_resets_details)
925+
{
926+
progression_resets_details[detail.GetItemDetailsKey()] = detail;
927+
}
928+
}
929+
930+
if (parsedResponse.currency_details != null && parsedResponse.currency_details.Length > 0)
931+
{
932+
currency_details = new Dictionary<LootLockerItemDetailsKey, LootLockerCurrencyDetails>();
933+
foreach (var detail in parsedResponse.currency_details)
934+
{
935+
currency_details[detail.GetItemDetailsKey()] = detail;
936+
}
937+
}
938+
939+
if (parsedResponse.group_details != null && parsedResponse.group_details.Length > 0)
940+
{
941+
group_details = new Dictionary<LootLockerItemDetailsKey, LootLockerGroupDetails>();
942+
foreach (var detail in parsedResponse.group_details)
943+
{
944+
group_details[detail.GetItemDetailsKey()] = detail;
945+
}
946+
}
947+
}
948+
949+
/// <summary>
950+
/// </summary>
951+
public class LootLockerInlinedCatalogEntry : LootLockerCatalogEntry
952+
{
953+
954+
/// <summary>
955+
/// Asset details inlined for this catalog entry, will be null if the entity_kind is not asset
956+
/// </summary>
957+
public LootLockerAssetDetails asset_details { get; set; }
958+
959+
/// <summary>
960+
/// Progression point details inlined for this catalog entry, will be null if the entity_kind is not progression_points
961+
/// </summary>
962+
public LootLockerProgressionPointDetails progression_point_details { get; set; }
963+
964+
/// <summary>
965+
/// Progression reset details inlined for this catalog entry, will be null if the entity_kind is not progression_reset
966+
/// </summary>
967+
public LootLockerProgressionResetDetails progression_reset_details { get; set; }
968+
969+
/// <summary>
970+
/// Currency details inlined for this catalog entry, will be null if the entity_kind is not currency
971+
/// </summary>
972+
public LootLockerCurrencyDetails currency_details { get; set; }
973+
974+
/// <summary>
975+
/// Group details inlined for this catalog entry, will be null if the entity_kind is not group
976+
/// </summary>
977+
public LootLockerInlinedGroupDetails group_details { get; set; }
978+
979+
public LootLockerInlinedCatalogEntry(LootLockerCatalogEntry entry, LootLockerListCatalogPricesV2Response catalogListing)
980+
{
981+
created_at = entry.created_at;
982+
entity_kind = entry.entity_kind;
983+
entity_name = entry.entity_name;
984+
entity_id = entry.entity_id;
985+
listings = entry.listings;
986+
prices = entry.prices;
987+
catalog_listing_id = entry.catalog_listing_id;
988+
purchasable = entry.purchasable;
989+
990+
switch (entity_kind)
991+
{
992+
case LootLockerCatalogEntryEntityKind.asset:
993+
if (catalogListing.asset_details.ContainsKey(entry.GetItemDetailsKey()))
994+
{
995+
asset_details = catalogListing.asset_details[entry.GetItemDetailsKey()];
996+
}
997+
break;
998+
case LootLockerCatalogEntryEntityKind.currency:
999+
if (catalogListing.currency_details.ContainsKey(entry.GetItemDetailsKey()))
1000+
{
1001+
currency_details = catalogListing.currency_details[entry.GetItemDetailsKey()];
1002+
}
1003+
break;
1004+
case LootLockerCatalogEntryEntityKind.progression_points:
1005+
if (catalogListing.progression_points_details.ContainsKey(entry.GetItemDetailsKey()))
1006+
{
1007+
progression_point_details = catalogListing.progression_points_details[entry.GetItemDetailsKey()];
1008+
}
1009+
break;
1010+
case LootLockerCatalogEntryEntityKind.progression_reset:
1011+
if (catalogListing.progression_resets_details.ContainsKey(entry.GetItemDetailsKey()))
1012+
{
1013+
progression_reset_details = catalogListing.progression_resets_details[entry.GetItemDetailsKey()];
1014+
}
1015+
break;
1016+
case LootLockerCatalogEntryEntityKind.group:
1017+
if (!catalogListing.group_details.ContainsKey(entry.GetItemDetailsKey()))
1018+
break;
1019+
1020+
var catalogLevelGroup = catalogListing.group_details[entry.GetItemDetailsKey()];
1021+
1022+
LootLockerInlinedGroupDetails inlinedGroupDetails = new LootLockerInlinedGroupDetails();
1023+
1024+
inlinedGroupDetails.name = catalogLevelGroup.name;
1025+
inlinedGroupDetails.description = catalogLevelGroup.description;
1026+
inlinedGroupDetails.metadata = catalogLevelGroup.metadata;
1027+
inlinedGroupDetails.id = catalogLevelGroup.id;
1028+
inlinedGroupDetails.associations = catalogLevelGroup.associations;
1029+
1030+
foreach (var association in catalogLevelGroup.associations)
1031+
{
1032+
switch (association.kind)
1033+
{
1034+
case LootLockerCatalogEntryEntityKind.asset:
1035+
if (catalogListing.asset_details.ContainsKey(association.GetItemDetailsKey()))
1036+
{
1037+
inlinedGroupDetails.assetDetails.Add(catalogListing.asset_details[association.GetItemDetailsKey()]);
1038+
}
1039+
break;
1040+
case LootLockerCatalogEntryEntityKind.progression_points:
1041+
if (catalogListing.progression_points_details.ContainsKey(association.GetItemDetailsKey()))
1042+
{
1043+
inlinedGroupDetails.progressionPointDetails.Add(catalogListing.progression_points_details[association.GetItemDetailsKey()]);
1044+
}
1045+
break;
1046+
case LootLockerCatalogEntryEntityKind.progression_reset:
1047+
if (catalogListing.progression_resets_details.ContainsKey(association.GetItemDetailsKey()))
1048+
{
1049+
inlinedGroupDetails.progressionResetDetails.Add(catalogListing.progression_resets_details[association.GetItemDetailsKey()]);
1050+
}
1051+
break;
1052+
case LootLockerCatalogEntryEntityKind.currency:
1053+
if (catalogListing.currency_details.ContainsKey(association.GetItemDetailsKey()))
1054+
{
1055+
inlinedGroupDetails.currencyDetails.Add(catalogListing.currency_details[association.GetItemDetailsKey()]);
1056+
}
1057+
break;
1058+
case LootLockerCatalogEntryEntityKind.group:
1059+
default:
1060+
break;
1061+
}
1062+
}
1063+
1064+
group_details = inlinedGroupDetails;
1065+
1066+
break;
1067+
default:
1068+
break;
1069+
}
1070+
1071+
}
1072+
}
1073+
1074+
/// <summary>
1075+
/// Get all the entries with details inlined into the entries themselves
1076+
/// </summary>
1077+
public LootLockerInlinedCatalogEntry[] GetLootLockerInlinedCatalogEntries()
1078+
{
1079+
List<LootLockerInlinedCatalogEntry> inlinedEntries = new List<LootLockerInlinedCatalogEntry>();
1080+
foreach (var lootLockerCatalogEntry in entries)
1081+
{
1082+
inlinedEntries.Add(new LootLockerInlinedCatalogEntry(
1083+
lootLockerCatalogEntry,
1084+
this
1085+
));
1086+
}
1087+
return inlinedEntries.ToArray();
1088+
}
1089+
}
7751090
}

0 commit comments

Comments
 (0)