diff --git a/LootLockerSDK/Source/LootLockerSDK/Private/GameAPI/LootLockerPlayerRequestHandler.cpp b/LootLockerSDK/Source/LootLockerSDK/Private/GameAPI/LootLockerPlayerRequestHandler.cpp index e2535fe7..553e80b8 100644 --- a/LootLockerSDK/Source/LootLockerSDK/Private/GameAPI/LootLockerPlayerRequestHandler.cpp +++ b/LootLockerSDK/Source/LootLockerSDK/Private/GameAPI/LootLockerPlayerRequestHandler.cpp @@ -158,3 +158,25 @@ FString ULootLockerPlayerRequestHandler::DeletePlayer(const FLootLockerPlayerDat return LLAPI::CallAPI(LootLockerEmptyRequest, ULootLockerGameEndpoints::DeletePlayer, {}, EmptyQueryParams, PlayerData, OnCompletedRequest); } +FString ULootLockerPlayerRequestHandler::ListPlayerInventory(const FLootLockerPlayerData& PlayerData, const FLootLockerListSimplifiedInventoryRequest& Request, int32 PerPage, int32 Page, const FLootLockerSimpleInventoryResponseDelegate& OnCompletedRequest) +{ + TMultiMap QueryParams; + QueryParams.Add("per_page", FString::FromInt(PerPage > 0 ? PerPage : 100)); + QueryParams.Add("page", FString::FromInt(Page > 0 ? Page : 1)); + + return LLAPI::CallAPI(Request, ULootLockerGameEndpoints::ListPlayerSimpleInventoryEndPoint, {}, QueryParams, PlayerData, OnCompletedRequest); +} + +FString ULootLockerPlayerRequestHandler::ListCharacterInventory(const FLootLockerPlayerData& PlayerData, const FLootLockerListSimplifiedInventoryRequest& Request, int32 CharacterId, int32 PerPage, int32 Page, const FLootLockerSimpleInventoryResponseDelegate& OnCompletedRequest) +{ + TMultiMap QueryParams; + if (CharacterId > 0) + { + QueryParams.Add("character_id", FString::FromInt(CharacterId)); + } + QueryParams.Add("per_page", FString::FromInt(PerPage > 0 ? PerPage : 100)); + QueryParams.Add("page", FString::FromInt(Page > 0 ? Page : 1)); + + return LLAPI::CallAPI(Request, ULootLockerGameEndpoints::ListPlayerSimpleInventoryEndPoint, {}, QueryParams, PlayerData, OnCompletedRequest); +} + diff --git a/LootLockerSDK/Source/LootLockerSDK/Private/LootLockerGameEndpoints.cpp b/LootLockerSDK/Source/LootLockerSDK/Private/LootLockerGameEndpoints.cpp index 87d0d2f8..a06deb98 100644 --- a/LootLockerSDK/Source/LootLockerSDK/Private/LootLockerGameEndpoints.cpp +++ b/LootLockerSDK/Source/LootLockerSDK/Private/LootLockerGameEndpoints.cpp @@ -85,6 +85,7 @@ FLootLockerEndPoints ULootLockerGameEndpoints::ListOtherPlayersFilesEndpoint = I FLootLockerEndPoints ULootLockerGameEndpoints::GetInfoFromSession = InitEndpoint("player/hazy-hammock/v1/info", ELootLockerHTTPMethod::GET); FLootLockerEndPoints ULootLockerGameEndpoints::ListPlayerInfo = InitEndpoint("player/hazy-hammock/v1/info", ELootLockerHTTPMethod::POST); FLootLockerEndPoints ULootLockerGameEndpoints::GetPlayerInventoryEndPoint = InitEndpoint("v1/player/inventory/list", ELootLockerHTTPMethod::GET); +FLootLockerEndPoints ULootLockerGameEndpoints::ListPlayerSimpleInventoryEndPoint = InitEndpoint("player/inventories/v1", ELootLockerHTTPMethod::POST); FLootLockerEndPoints ULootLockerGameEndpoints::GetCurrencyBalance = InitEndpoint("v1/player/balance", ELootLockerHTTPMethod::GET); FLootLockerEndPoints ULootLockerGameEndpoints::CheckPlayerAssetActivationEndpoint = InitEndpoint("v1/player/notification/assets", ELootLockerHTTPMethod::GET); FLootLockerEndPoints ULootLockerGameEndpoints::InitiateDLCMigration = InitEndpoint("v1/player/dlcs", ELootLockerHTTPMethod::POST); diff --git a/LootLockerSDK/Source/LootLockerSDK/Private/LootLockerManager.cpp b/LootLockerSDK/Source/LootLockerSDK/Private/LootLockerManager.cpp index da86623e..6610d804 100644 --- a/LootLockerSDK/Source/LootLockerSDK/Private/LootLockerManager.cpp +++ b/LootLockerSDK/Source/LootLockerSDK/Private/LootLockerManager.cpp @@ -476,6 +476,22 @@ FString ULootLockerManager::GetFullInventory(const FString ForPlayerWithUlid, in }), StartIndex, ForPlayerWithUlid); } +FString ULootLockerManager::ListPlayerInventory(const FString& ForPlayerWithUlid, const FLootLockerListSimplifiedInventoryRequest& Request, int PerPage, const int& Page, const FLootLockerSimpleInventoryResponseBP& OnCompletedRequest) +{ + return ULootLockerSDKManager::ListPlayerInventory(Request, PerPage, Page, FLootLockerSimpleInventoryResponseDelegate::CreateLambda([OnCompletedRequest](FLootLockerSimpleInventoryResponse Response) + { + OnCompletedRequest.ExecuteIfBound(Response); + }), ForPlayerWithUlid); +} + +FString ULootLockerManager::ListCharacterInventory(const FString& ForPlayerWithUlid, int CharacterId, const FLootLockerListSimplifiedInventoryRequest& Request, int PerPage, const int& Page, const FLootLockerSimpleInventoryResponseBP& OnCompletedRequest) +{ + return ULootLockerSDKManager::ListCharacterInventory(CharacterId, Request, PerPage, Page, FLootLockerSimpleInventoryResponseDelegate::CreateLambda([OnCompletedRequest](FLootLockerSimpleInventoryResponse Response) + { + OnCompletedRequest.ExecuteIfBound(Response); + }), ForPlayerWithUlid); +} + FString ULootLockerManager::CheckPlayerAssetActivationNotification(const FString& ForPlayerWithUlid, const FPAssetNotificationResponseBP& OnCheckPlayerAssetDeactivationNotificationRequestCompleted) { return ULootLockerSDKManager::CheckPlayerAssetActivationNotification(FLootLockerAssetNotificationResponse::CreateLambda([OnCheckPlayerAssetDeactivationNotificationRequestCompleted](FLootLockerPlayerAssetNotificationResponse Response) diff --git a/LootLockerSDK/Source/LootLockerSDK/Private/LootLockerSDKManager.cpp b/LootLockerSDK/Source/LootLockerSDK/Private/LootLockerSDKManager.cpp index ad3ca6b9..3d0d4f27 100644 --- a/LootLockerSDK/Source/LootLockerSDK/Private/LootLockerSDKManager.cpp +++ b/LootLockerSDK/Source/LootLockerSDK/Private/LootLockerSDKManager.cpp @@ -372,6 +372,26 @@ FString ULootLockerSDKManager::GetFullInventory(const FInventoryResponse& OnComp return ULootLockerPlayerRequestHandler::GetFullInventory(GetSavedStateOrDefaultOrEmptyForPlayer(ForPlayerWithUlid), OnCompletedRequest, StartIndex); } +FString ULootLockerSDKManager::ListPlayerInventoryWithDefaultParameters(const FLootLockerSimpleInventoryResponseDelegate& OnCompletedRequest, const FString& ForPlayerWithUlid /* = "" */) +{ + return ListPlayerInventory(FLootLockerListSimplifiedInventoryRequest(), 0, 0, OnCompletedRequest, ForPlayerWithUlid); +} + +FString ULootLockerSDKManager::ListPlayerInventory(const FLootLockerListSimplifiedInventoryRequest& Request, int PerPage, int Page, const FLootLockerSimpleInventoryResponseDelegate& OnCompletedRequest, const FString& ForPlayerWithUlid /* = "" */) +{ + return ULootLockerPlayerRequestHandler::ListPlayerInventory(GetSavedStateOrDefaultOrEmptyForPlayer(ForPlayerWithUlid), Request, PerPage, Page, OnCompletedRequest); +} + +FString ULootLockerSDKManager::ListCharacterInventoryWithDefaultParameters(int CharacterId, const FLootLockerSimpleInventoryResponseDelegate& OnCompletedRequest, const FString& ForPlayerWithUlid /* = "" */) +{ + return ListCharacterInventory(CharacterId, FLootLockerListSimplifiedInventoryRequest(), 0, 0, OnCompletedRequest, ForPlayerWithUlid); +} + +FString ULootLockerSDKManager::ListCharacterInventory(int CharacterId, const FLootLockerListSimplifiedInventoryRequest& Request, int PerPage, int Page, const FLootLockerSimpleInventoryResponseDelegate& OnCompletedRequest, const FString& ForPlayerWithUlid /* = "" */) +{ + return ULootLockerPlayerRequestHandler::ListCharacterInventory(GetSavedStateOrDefaultOrEmptyForPlayer(ForPlayerWithUlid), Request, CharacterId, PerPage, Page, OnCompletedRequest); +} + FString ULootLockerSDKManager::CheckPlayerAssetActivationNotification(const FLootLockerAssetNotificationResponse& OnCompletedRequest, const FString& ForPlayerWithUlid /* = "" */) { return ULootLockerPlayerRequestHandler::CheckPlayerAssetNotification(GetSavedStateOrDefaultOrEmptyForPlayer(ForPlayerWithUlid), OnCompletedRequest); diff --git a/LootLockerSDK/Source/LootLockerSDK/Public/GameAPI/LootLockerPlayerRequestHandler.h b/LootLockerSDK/Source/LootLockerSDK/Public/GameAPI/LootLockerPlayerRequestHandler.h index 35c21ec2..0879c2af 100644 --- a/LootLockerSDK/Source/LootLockerSDK/Public/GameAPI/LootLockerPlayerRequestHandler.h +++ b/LootLockerSDK/Source/LootLockerSDK/Public/GameAPI/LootLockerPlayerRequestHandler.h @@ -349,6 +349,73 @@ struct FLootLockerMultiplePlayerNamesAndPlatformsRequest { TArray player_public_uids; }; +/** + * A simplified inventory item for optimized inventory listing + */ +USTRUCT(BlueprintType) +struct FLootLockerSimpleInventoryItem +{ + GENERATED_BODY() + /** + * The ID of the asset + */ + UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "LootLocker") + int32 Asset_id = 0; + /** + * The instance ID of this specific asset instance + */ + UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "LootLocker") + int32 Instance_id = 0; + /** + * How this asset was acquired (e.g., purchase, loot_box, etc.) + */ + UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "LootLocker") + FString Acquisition_source = ""; + /** + * When this asset was acquired + */ + UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "LootLocker") + FString Acquisition_date = ""; +}; + +/** + * Request filters for simplified inventory listing + */ +USTRUCT(BlueprintType) +struct FLootLockerListSimplifiedInventoryRequest +{ + GENERATED_BODY() + /** + * A list of asset ids to filter the inventory items by + */ + UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "LootLocker") + TArray Asset_ids; + /** + * A list of context ids to filter the inventory items by + */ + UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "LootLocker") + TArray Context_ids; +}; + +/** + * Response for simplified inventory listing + */ +USTRUCT(BlueprintType) +struct FLootLockerSimpleInventoryResponse : public FLootLockerResponse +{ + GENERATED_BODY() + /** + * List of simplified inventory items according to the requested filters + */ + UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "LootLocker") + TArray Items; + /** + * Pagination information for the inventory items returned + */ + UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "LootLocker") + FLootLockerIndexBasedPagination Pagination; +}; + DECLARE_DELEGATE_OneParam(FLootLockerGetCurrentPlayerInfoResponseDelegate, FLootLockerGetCurrentPlayerInfoResponse); DECLARE_DELEGATE_OneParam(FLootLockerListPlayerInfoResponseDelegate, FLootLockerListPlayerInfoResponse); @@ -367,6 +434,8 @@ DECLARE_DELEGATE_OneParam(FPMultiplePlayerNames, FLootLockerMultiplePlayersNames DECLARE_DELEGATE_OneParam(FPMultiplePlayersPlatformIdsNames, FLootLockerMultiplePlayersPlatformIdsResponse); +DECLARE_DELEGATE_OneParam(FLootLockerSimpleInventoryResponseDelegate, FLootLockerSimpleInventoryResponse); + UCLASS() class LOOTLOCKERSDK_API ULootLockerPlayerRequestHandler : public UObject { @@ -391,4 +460,8 @@ class LOOTLOCKERSDK_API ULootLockerPlayerRequestHandler : public UObject static FString LookupMultiplePlayersDataUsingIDs(const FLootLockerPlayerData& PlayerData, FLootLockerLookupMultiplePlayersDataRequest Request, const FPMultiplePlayerNames& OnCompletedRequest); static FString LookupMultiplePlayerNames1stPlatformIDs(const FLootLockerPlayerData& PlayerData, const FLootLockerMultiplePlayerNamesAndPlatformsRequest& Request, const FPMultiplePlayersPlatformIdsNames& OnCompletedRequest); static FString DeletePlayer(const FLootLockerPlayerData& PlayerData, const FLootLockerDefaultDelegate OnCompletedRequest); + + // Simple inventory listing methods + static FString ListPlayerInventory(const FLootLockerPlayerData& PlayerData, const FLootLockerListSimplifiedInventoryRequest& Request, int32 PerPage, int32 Page, const FLootLockerSimpleInventoryResponseDelegate& OnCompletedRequest); + static FString ListCharacterInventory(const FLootLockerPlayerData& PlayerData, const FLootLockerListSimplifiedInventoryRequest& Request, int32 CharacterId, int32 PerPage, int32 Page, const FLootLockerSimpleInventoryResponseDelegate& OnCompletedRequest); }; diff --git a/LootLockerSDK/Source/LootLockerSDK/Public/LootLockerGameEndpoints.h b/LootLockerSDK/Source/LootLockerSDK/Public/LootLockerGameEndpoints.h index 3904e83c..207b6331 100644 --- a/LootLockerSDK/Source/LootLockerSDK/Public/LootLockerGameEndpoints.h +++ b/LootLockerSDK/Source/LootLockerSDK/Public/LootLockerGameEndpoints.h @@ -117,6 +117,7 @@ class LOOTLOCKERSDK_API ULootLockerGameEndpoints : public UObject static FLootLockerEndPoints GetInfoFromSession; static FLootLockerEndPoints ListPlayerInfo; static FLootLockerEndPoints GetPlayerInventoryEndPoint; + static FLootLockerEndPoints ListPlayerSimpleInventoryEndPoint; static FLootLockerEndPoints GetCurrencyBalance; static FLootLockerEndPoints CheckPlayerAssetActivationEndpoint; static FLootLockerEndPoints CheckPlayerAssetDeactivationEndpoint; diff --git a/LootLockerSDK/Source/LootLockerSDK/Public/LootLockerManager.h b/LootLockerSDK/Source/LootLockerSDK/Public/LootLockerManager.h index d62c5d0c..b3f9d9df 100644 --- a/LootLockerSDK/Source/LootLockerSDK/Public/LootLockerManager.h +++ b/LootLockerSDK/Source/LootLockerSDK/Public/LootLockerManager.h @@ -117,6 +117,8 @@ DECLARE_DYNAMIC_DELEGATE_OneParam(FLootLockerGetCurrentPlayerInfoResponseBP, FLo DECLARE_DYNAMIC_DELEGATE_OneParam(FLootLockerListPlayerInfoResponseBP, FLootLockerListPlayerInfoResponse, Value); /** Blueprint response delegate for player inventory responses */ DECLARE_DYNAMIC_DELEGATE_OneParam(FPInventoryResponseBP, FLootLockerInventoryResponse, Value); +/** Blueprint response delegate for simple player inventory responses */ +DECLARE_DYNAMIC_DELEGATE_OneParam(FLootLockerSimpleInventoryResponseBP, FLootLockerSimpleInventoryResponse, Value); /** Blueprint response delegate for player asset notification responses */ DECLARE_DYNAMIC_DELEGATE_OneParam(FPAssetNotificationResponseBP, FLootLockerPlayerAssetNotificationResponse, Value); /** Blueprint response delegate for player balance responses */ @@ -1226,6 +1228,33 @@ class LOOTLOCKERSDK_API ULootLockerManager : public UObject UFUNCTION(BlueprintCallable, Category = "LootLocker Methods | Players", meta = (AdvancedDisplay = "ForPlayerWithUlid", ForPlayerWithUlid="")) static UPARAM(DisplayName = "RequestId") FString GetFullInventory(const FString ForPlayerWithUlid, int32 StartIndex, const FPInventoryResponseBP& OnGetInventoryRequestCompleted); + /** + Get a simplified list of the player's inventory. + + @param ForPlayerWithUlid Optional: Execute for the specified player ULID (default player if empty) + @param Request Request object containing any filters to apply to the inventory listing + @param PerPage Number of items to return per page + @param Page Page number to retrieve + @param OnCompletedRequest Delegate for handling the server response + @return A unique id for this request, use this to match callbacks to requests when you have multiple simultaneous requests outbound + */ + UFUNCTION(BlueprintCallable, Category = "LootLocker Methods | Players", meta = (AdvancedDisplay = "ForPlayerWithUlid,Request,PerPage,Page", ForPlayerWithUlid="", PerPage="100", Page="1", AutoCreateRefTerm = "Request")) + static UPARAM(DisplayName = "RequestId") FString ListPlayerInventory(const FString& ForPlayerWithUlid, const FLootLockerListSimplifiedInventoryRequest& Request, int PerPage, const int& Page, const FLootLockerSimpleInventoryResponseBP& OnCompletedRequest); + + /** + Get a simplified list of the character's inventory. + + @param ForPlayerWithUlid Optional: Execute for the specified player ULID (default player if empty) + @param CharacterId Identifier of the character whose inventory is being requested + @param Request Request object containing any filters to apply to the inventory listing + @param PerPage Number of items to return per page + @param Page Page number to retrieve + @param OnCompletedRequest Delegate for handling the server response + @return A unique id for this request, use this to match callbacks to requests when you have multiple simultaneous requests outbound + */ + UFUNCTION(BlueprintCallable, Category = "LootLocker Methods | Players", meta = (AdvancedDisplay = "ForPlayerWithUlid,Request,PerPage,Page", ForPlayerWithUlid="", PerPage="100", Page="1", AutoCreateRefTerm = "Request")) + static UPARAM(DisplayName = "RequestId") FString ListCharacterInventory(const FString& ForPlayerWithUlid, int CharacterId, const FLootLockerListSimplifiedInventoryRequest& Request, int PerPage, const int& Page, const FLootLockerSimpleInventoryResponseBP& OnCompletedRequest); + /** Get recently granted player assets since the last activation notification check. diff --git a/LootLockerSDK/Source/LootLockerSDK/Public/LootLockerSDKManager.h b/LootLockerSDK/Source/LootLockerSDK/Public/LootLockerSDKManager.h index 9517c12e..011ebc67 100644 --- a/LootLockerSDK/Source/LootLockerSDK/Public/LootLockerSDKManager.h +++ b/LootLockerSDK/Source/LootLockerSDK/Public/LootLockerSDKManager.h @@ -876,6 +876,50 @@ class LOOTLOCKERSDK_API ULootLockerSDKManager : public UObject */ static FString CheckPlayerAssetActivationNotification(const FLootLockerAssetNotificationResponse & OnCompletedRequest, const FString& ForPlayerWithUlid = ""); + /** + Get a simplified list of the player's inventory with default parameters. + + @param OnCompletedRequest Delegate for handling the server response + @param ForPlayerWithUlid Optional: Execute for the specified player ULID (default player if empty) + @return A unique id for this request, use this to match callbacks to requests when you have multiple simultaneous requests outbound + */ + static FString ListPlayerInventoryWithDefaultParameters(const FLootLockerSimpleInventoryResponseDelegate& OnCompletedRequest, const FString& ForPlayerWithUlid = ""); + + /** + Get a simplified list of the player's inventory. + + @param Request Request object containing any filters to apply to the inventory listing + @param PerPage Number of items to return per page + @param Page Page number to retrieve + @param OnCompletedRequest Delegate for handling the server response + @param ForPlayerWithUlid Optional: Execute for the specified player ULID (default player if empty) + @return A unique id for this request, use this to match callbacks to requests when you have multiple simultaneous requests outbound + */ + static FString ListPlayerInventory(const FLootLockerListSimplifiedInventoryRequest& Request, int PerPage, int Page, const FLootLockerSimpleInventoryResponseDelegate& OnCompletedRequest, const FString& ForPlayerWithUlid = ""); + + /** + Get a simplified list of the character's inventory with default parameters. + + @param CharacterId ID of the character to retrieve inventory for + @param OnCompletedRequest Delegate for handling the server response + @param ForPlayerWithUlid Optional: Execute for the specified player ULID (default player if empty) + @return A unique id for this request, use this to match callbacks to requests when you have multiple simultaneous requests outbound + */ + static FString ListCharacterInventoryWithDefaultParameters(int CharacterId, const FLootLockerSimpleInventoryResponseDelegate& OnCompletedRequest, const FString& ForPlayerWithUlid = ""); + + /** + Get a simplified list of a character's inventory. + + @param CharacterId ID of the character to retrieve inventory for + @param Request Request object containing any filters to apply to the inventory listing + @param PerPage Number of items to return per page + @param Page Page number to retrieve + @param OnCompletedRequest Delegate for handling the server response + @param ForPlayerWithUlid Optional: Execute for the specified player ULID (default player if empty) + @return A unique id for this request, use this to match callbacks to requests when you have multiple simultaneous requests outbound + */ + static FString ListCharacterInventory(int CharacterId, const FLootLockerListSimplifiedInventoryRequest& Request, int PerPage, int Page, const FLootLockerSimpleInventoryResponseDelegate& OnCompletedRequest, const FString& ForPlayerWithUlid = ""); + /** Get the player's current credit / currency balance.