diff --git a/AndroidStudioExample/app/src/main/java/com/playfab/PlayFabClientAPI.java b/AndroidStudioExample/app/src/main/java/com/playfab/PlayFabClientAPI.java index 9a263163..4ade7593 100644 --- a/AndroidStudioExample/app/src/main/java/com/playfab/PlayFabClientAPI.java +++ b/AndroidStudioExample/app/src/main/java/com/playfab/PlayFabClientAPI.java @@ -4406,7 +4406,65 @@ private static PlayFabResult privateSubtractUse } /** - * Unlocks a container item in the user's inventory and consumes a key item of the type indicated by the container item + * Opens the specified container, with the specified key (when required), and returns the contents of the opened container. If the container (and key when relevant) are consumable (RemainingUses > 0), their RemainingUses will be decremented, consistent with the operation of ConsumeItem. + */ + @SuppressWarnings("unchecked") + public static FutureTask> UnlockContainerInstanceAsync(final UnlockContainerInstanceRequest request) { + return new FutureTask(new Callable>() { + public PlayFabResult call() throws Exception { + return privateUnlockContainerInstanceAsync(request); + } + }); + } + + /** + * Opens the specified container, with the specified key (when required), and returns the contents of the opened container. If the container (and key when relevant) are consumable (RemainingUses > 0), their RemainingUses will be decremented, consistent with the operation of ConsumeItem. + */ + @SuppressWarnings("unchecked") + public static PlayFabResult UnlockContainerInstance(final UnlockContainerInstanceRequest request) { + FutureTask> task = new FutureTask(new Callable>() { + public PlayFabResult call() throws Exception { + return privateUnlockContainerInstanceAsync(request); + } + }); + try { + task.run(); + return task.get(); + } catch(Exception e) { + return null; + } + } + + /** + * Opens the specified container, with the specified key (when required), and returns the contents of the opened container. If the container (and key when relevant) are consumable (RemainingUses > 0), their RemainingUses will be decremented, consistent with the operation of ConsumeItem. + */ + @SuppressWarnings("unchecked") + private static PlayFabResult privateUnlockContainerInstanceAsync(final UnlockContainerInstanceRequest request) throws Exception { + if (_authKey == null) throw new Exception ("Must be logged in to call this method"); + + FutureTask task = PlayFabHTTP.doPost(PlayFabSettings.GetURL() + "/Client/UnlockContainerInstance", request, "X-Authorization", _authKey); + task.run(); + Object httpResult = task.get(); + if(httpResult instanceof PlayFabError) { + PlayFabError error = (PlayFabError)httpResult; + if (PlayFabSettings.GlobalErrorHandler != null) + PlayFabSettings.GlobalErrorHandler.callback(error); + PlayFabResult result = new PlayFabResult(); + result.Error = error; + return result; + } + String resultRawJson = (String) httpResult; + + PlayFabJsonSuccess resultData = gson.fromJson(resultRawJson, new TypeToken>(){}.getType()); + UnlockContainerItemResult result = resultData.data; + + PlayFabResult pfResult = new PlayFabResult(); + pfResult.Result = result; + return pfResult; + } + + /** + * Searches target inventory for an ItemInstance matching the given CatalogItemId, if necessary unlocks it using an appropriate key, and returns the contents of the opened container. If the container (and key when relevant) are consumable (RemainingUses > 0), their RemainingUses will be decremented, consistent with the operation of ConsumeItem. */ @SuppressWarnings("unchecked") public static FutureTask> UnlockContainerItemAsync(final UnlockContainerItemRequest request) { @@ -4418,7 +4476,7 @@ public PlayFabResult call() throws Exception { } /** - * Unlocks a container item in the user's inventory and consumes a key item of the type indicated by the container item + * Searches target inventory for an ItemInstance matching the given CatalogItemId, if necessary unlocks it using an appropriate key, and returns the contents of the opened container. If the container (and key when relevant) are consumable (RemainingUses > 0), their RemainingUses will be decremented, consistent with the operation of ConsumeItem. */ @SuppressWarnings("unchecked") public static PlayFabResult UnlockContainerItem(final UnlockContainerItemRequest request) { @@ -4436,7 +4494,7 @@ public PlayFabResult call() throws Exception { } /** - * Unlocks a container item in the user's inventory and consumes a key item of the type indicated by the container item + * Searches target inventory for an ItemInstance matching the given CatalogItemId, if necessary unlocks it using an appropriate key, and returns the contents of the opened container. If the container (and key when relevant) are consumable (RemainingUses > 0), their RemainingUses will be decremented, consistent with the operation of ConsumeItem. */ @SuppressWarnings("unchecked") private static PlayFabResult privateUnlockContainerItemAsync(final UnlockContainerItemRequest request) throws Exception { diff --git a/AndroidStudioExample/app/src/main/java/com/playfab/PlayFabClientModels.java b/AndroidStudioExample/app/src/main/java/com/playfab/PlayFabClientModels.java index 0d353dbc..cb925cb7 100644 --- a/AndroidStudioExample/app/src/main/java/com/playfab/PlayFabClientModels.java +++ b/AndroidStudioExample/app/src/main/java/com/playfab/PlayFabClientModels.java @@ -3220,13 +3220,33 @@ public static class UnlinkXboxAccountResult { } + public static class UnlockContainerInstanceRequest { + /** + * Unique PlayFab assigned ID for a specific character owned by a user + */ + public String CharacterId; + /** + * ItemInstanceId of the container to unlock. + */ + public String ContainerItemInstanceId; + /** + * ItemInstanceId of the key that will be consumed by unlocking this container. If the container requires a key, this parameter is required. + */ + public String KeyItemInstanceId; + /** + * Specifies the catalog version that should be used to determine container contents. If unspecified, uses catalog associated with the item instance. + */ + public String CatalogVersion; + + } + public static class UnlockContainerItemRequest { /** - * Category ItemId of the container type to unlock. + * Catalog ItemId of the container type to unlock. */ public String ContainerItemId; /** - * Catalog version of the container. + * Specifies the catalog version that should be used to determine container contents. If unspecified, uses default/primary catalog. */ public String CatalogVersion; /** diff --git a/AndroidStudioExample/app/src/main/java/com/playfab/PlayFabErrors.java b/AndroidStudioExample/app/src/main/java/com/playfab/PlayFabErrors.java index cf8d5471..428536c1 100644 --- a/AndroidStudioExample/app/src/main/java/com/playfab/PlayFabErrors.java +++ b/AndroidStudioExample/app/src/main/java/com/playfab/PlayFabErrors.java @@ -205,7 +205,8 @@ public static enum PlayFabErrorCode { InvalidDropTable(1201), StatisticVersionAlreadyIncrementedForScheduledInterval(1202), StatisticCountLimitExceeded(1203), - StatisticVersionIncrementRateExceeded(1204); + StatisticVersionIncrementRateExceeded(1204), + ContainerKeyInvalid(1205); public int id; diff --git a/AndroidStudioExample/app/src/main/java/com/playfab/internal/PlayFabVersion.java b/AndroidStudioExample/app/src/main/java/com/playfab/internal/PlayFabVersion.java index 6d0c98fe..09c3f9c0 100644 --- a/AndroidStudioExample/app/src/main/java/com/playfab/internal/PlayFabVersion.java +++ b/AndroidStudioExample/app/src/main/java/com/playfab/internal/PlayFabVersion.java @@ -1,7 +1,7 @@ package com.playfab.internal; public class PlayFabVersion { - public static String SdkRevision = "0.15.160208"; + public static String SdkRevision = "0.16.160208"; public static String getVersionString() { return "JavaSDK-" + SdkRevision; } diff --git a/PlayFabClientSDK/src/com/playfab/PlayFabClientAPI.java b/PlayFabClientSDK/src/com/playfab/PlayFabClientAPI.java index b7915071..4d81f546 100644 --- a/PlayFabClientSDK/src/com/playfab/PlayFabClientAPI.java +++ b/PlayFabClientSDK/src/com/playfab/PlayFabClientAPI.java @@ -4405,7 +4405,65 @@ private static PlayFabResult privateSubtractUse } /** - * Unlocks a container item in the user's inventory and consumes a key item of the type indicated by the container item + * Opens the specified container, with the specified key (when required), and returns the contents of the opened container. If the container (and key when relevant) are consumable (RemainingUses > 0), their RemainingUses will be decremented, consistent with the operation of ConsumeItem. + */ + @SuppressWarnings("unchecked") + public static FutureTask> UnlockContainerInstanceAsync(final UnlockContainerInstanceRequest request) { + return new FutureTask(new Callable>() { + public PlayFabResult call() throws Exception { + return privateUnlockContainerInstanceAsync(request); + } + }); + } + + /** + * Opens the specified container, with the specified key (when required), and returns the contents of the opened container. If the container (and key when relevant) are consumable (RemainingUses > 0), their RemainingUses will be decremented, consistent with the operation of ConsumeItem. + */ + @SuppressWarnings("unchecked") + public static PlayFabResult UnlockContainerInstance(final UnlockContainerInstanceRequest request) { + FutureTask> task = new FutureTask(new Callable>() { + public PlayFabResult call() throws Exception { + return privateUnlockContainerInstanceAsync(request); + } + }); + try { + task.run(); + return task.get(); + } catch(Exception e) { + return null; + } + } + + /** + * Opens the specified container, with the specified key (when required), and returns the contents of the opened container. If the container (and key when relevant) are consumable (RemainingUses > 0), their RemainingUses will be decremented, consistent with the operation of ConsumeItem. + */ + @SuppressWarnings("unchecked") + private static PlayFabResult privateUnlockContainerInstanceAsync(final UnlockContainerInstanceRequest request) throws Exception { + if (_authKey == null) throw new Exception ("Must be logged in to call this method"); + + FutureTask task = PlayFabHTTP.doPost(PlayFabSettings.GetURL() + "/Client/UnlockContainerInstance", request, "X-Authorization", _authKey); + task.run(); + Object httpResult = task.get(); + if(httpResult instanceof PlayFabError) { + PlayFabError error = (PlayFabError)httpResult; + if (PlayFabSettings.GlobalErrorHandler != null) + PlayFabSettings.GlobalErrorHandler.callback(error); + PlayFabResult result = new PlayFabResult(); + result.Error = error; + return result; + } + String resultRawJson = (String) httpResult; + + PlayFabJsonSuccess resultData = gson.fromJson(resultRawJson, new TypeToken>(){}.getType()); + UnlockContainerItemResult result = resultData.data; + + PlayFabResult pfResult = new PlayFabResult(); + pfResult.Result = result; + return pfResult; + } + + /** + * Searches target inventory for an ItemInstance matching the given CatalogItemId, if necessary unlocks it using an appropriate key, and returns the contents of the opened container. If the container (and key when relevant) are consumable (RemainingUses > 0), their RemainingUses will be decremented, consistent with the operation of ConsumeItem. */ @SuppressWarnings("unchecked") public static FutureTask> UnlockContainerItemAsync(final UnlockContainerItemRequest request) { @@ -4417,7 +4475,7 @@ public PlayFabResult call() throws Exception { } /** - * Unlocks a container item in the user's inventory and consumes a key item of the type indicated by the container item + * Searches target inventory for an ItemInstance matching the given CatalogItemId, if necessary unlocks it using an appropriate key, and returns the contents of the opened container. If the container (and key when relevant) are consumable (RemainingUses > 0), their RemainingUses will be decremented, consistent with the operation of ConsumeItem. */ @SuppressWarnings("unchecked") public static PlayFabResult UnlockContainerItem(final UnlockContainerItemRequest request) { @@ -4435,7 +4493,7 @@ public PlayFabResult call() throws Exception { } /** - * Unlocks a container item in the user's inventory and consumes a key item of the type indicated by the container item + * Searches target inventory for an ItemInstance matching the given CatalogItemId, if necessary unlocks it using an appropriate key, and returns the contents of the opened container. If the container (and key when relevant) are consumable (RemainingUses > 0), their RemainingUses will be decremented, consistent with the operation of ConsumeItem. */ @SuppressWarnings("unchecked") private static PlayFabResult privateUnlockContainerItemAsync(final UnlockContainerItemRequest request) throws Exception { diff --git a/PlayFabClientSDK/src/com/playfab/PlayFabClientModels.java b/PlayFabClientSDK/src/com/playfab/PlayFabClientModels.java index 0d353dbc..cb925cb7 100644 --- a/PlayFabClientSDK/src/com/playfab/PlayFabClientModels.java +++ b/PlayFabClientSDK/src/com/playfab/PlayFabClientModels.java @@ -3220,13 +3220,33 @@ public static class UnlinkXboxAccountResult { } + public static class UnlockContainerInstanceRequest { + /** + * Unique PlayFab assigned ID for a specific character owned by a user + */ + public String CharacterId; + /** + * ItemInstanceId of the container to unlock. + */ + public String ContainerItemInstanceId; + /** + * ItemInstanceId of the key that will be consumed by unlocking this container. If the container requires a key, this parameter is required. + */ + public String KeyItemInstanceId; + /** + * Specifies the catalog version that should be used to determine container contents. If unspecified, uses catalog associated with the item instance. + */ + public String CatalogVersion; + + } + public static class UnlockContainerItemRequest { /** - * Category ItemId of the container type to unlock. + * Catalog ItemId of the container type to unlock. */ public String ContainerItemId; /** - * Catalog version of the container. + * Specifies the catalog version that should be used to determine container contents. If unspecified, uses default/primary catalog. */ public String CatalogVersion; /** diff --git a/PlayFabClientSDK/src/com/playfab/PlayFabErrors.java b/PlayFabClientSDK/src/com/playfab/PlayFabErrors.java index cf8d5471..428536c1 100644 --- a/PlayFabClientSDK/src/com/playfab/PlayFabErrors.java +++ b/PlayFabClientSDK/src/com/playfab/PlayFabErrors.java @@ -205,7 +205,8 @@ public static enum PlayFabErrorCode { InvalidDropTable(1201), StatisticVersionAlreadyIncrementedForScheduledInterval(1202), StatisticCountLimitExceeded(1203), - StatisticVersionIncrementRateExceeded(1204); + StatisticVersionIncrementRateExceeded(1204), + ContainerKeyInvalid(1205); public int id; diff --git a/PlayFabClientSDK/src/com/playfab/internal/PlayFabVersion.java b/PlayFabClientSDK/src/com/playfab/internal/PlayFabVersion.java index 6d0c98fe..09c3f9c0 100644 --- a/PlayFabClientSDK/src/com/playfab/internal/PlayFabVersion.java +++ b/PlayFabClientSDK/src/com/playfab/internal/PlayFabVersion.java @@ -1,7 +1,7 @@ package com.playfab.internal; public class PlayFabVersion { - public static String SdkRevision = "0.15.160208"; + public static String SdkRevision = "0.16.160208"; public static String getVersionString() { return "JavaSDK-" + SdkRevision; } diff --git a/PlayFabSDK/src/com/playfab/PlayFabClientAPI.java b/PlayFabSDK/src/com/playfab/PlayFabClientAPI.java index b7915071..4d81f546 100644 --- a/PlayFabSDK/src/com/playfab/PlayFabClientAPI.java +++ b/PlayFabSDK/src/com/playfab/PlayFabClientAPI.java @@ -4405,7 +4405,65 @@ private static PlayFabResult privateSubtractUse } /** - * Unlocks a container item in the user's inventory and consumes a key item of the type indicated by the container item + * Opens the specified container, with the specified key (when required), and returns the contents of the opened container. If the container (and key when relevant) are consumable (RemainingUses > 0), their RemainingUses will be decremented, consistent with the operation of ConsumeItem. + */ + @SuppressWarnings("unchecked") + public static FutureTask> UnlockContainerInstanceAsync(final UnlockContainerInstanceRequest request) { + return new FutureTask(new Callable>() { + public PlayFabResult call() throws Exception { + return privateUnlockContainerInstanceAsync(request); + } + }); + } + + /** + * Opens the specified container, with the specified key (when required), and returns the contents of the opened container. If the container (and key when relevant) are consumable (RemainingUses > 0), their RemainingUses will be decremented, consistent with the operation of ConsumeItem. + */ + @SuppressWarnings("unchecked") + public static PlayFabResult UnlockContainerInstance(final UnlockContainerInstanceRequest request) { + FutureTask> task = new FutureTask(new Callable>() { + public PlayFabResult call() throws Exception { + return privateUnlockContainerInstanceAsync(request); + } + }); + try { + task.run(); + return task.get(); + } catch(Exception e) { + return null; + } + } + + /** + * Opens the specified container, with the specified key (when required), and returns the contents of the opened container. If the container (and key when relevant) are consumable (RemainingUses > 0), their RemainingUses will be decremented, consistent with the operation of ConsumeItem. + */ + @SuppressWarnings("unchecked") + private static PlayFabResult privateUnlockContainerInstanceAsync(final UnlockContainerInstanceRequest request) throws Exception { + if (_authKey == null) throw new Exception ("Must be logged in to call this method"); + + FutureTask task = PlayFabHTTP.doPost(PlayFabSettings.GetURL() + "/Client/UnlockContainerInstance", request, "X-Authorization", _authKey); + task.run(); + Object httpResult = task.get(); + if(httpResult instanceof PlayFabError) { + PlayFabError error = (PlayFabError)httpResult; + if (PlayFabSettings.GlobalErrorHandler != null) + PlayFabSettings.GlobalErrorHandler.callback(error); + PlayFabResult result = new PlayFabResult(); + result.Error = error; + return result; + } + String resultRawJson = (String) httpResult; + + PlayFabJsonSuccess resultData = gson.fromJson(resultRawJson, new TypeToken>(){}.getType()); + UnlockContainerItemResult result = resultData.data; + + PlayFabResult pfResult = new PlayFabResult(); + pfResult.Result = result; + return pfResult; + } + + /** + * Searches target inventory for an ItemInstance matching the given CatalogItemId, if necessary unlocks it using an appropriate key, and returns the contents of the opened container. If the container (and key when relevant) are consumable (RemainingUses > 0), their RemainingUses will be decremented, consistent with the operation of ConsumeItem. */ @SuppressWarnings("unchecked") public static FutureTask> UnlockContainerItemAsync(final UnlockContainerItemRequest request) { @@ -4417,7 +4475,7 @@ public PlayFabResult call() throws Exception { } /** - * Unlocks a container item in the user's inventory and consumes a key item of the type indicated by the container item + * Searches target inventory for an ItemInstance matching the given CatalogItemId, if necessary unlocks it using an appropriate key, and returns the contents of the opened container. If the container (and key when relevant) are consumable (RemainingUses > 0), their RemainingUses will be decremented, consistent with the operation of ConsumeItem. */ @SuppressWarnings("unchecked") public static PlayFabResult UnlockContainerItem(final UnlockContainerItemRequest request) { @@ -4435,7 +4493,7 @@ public PlayFabResult call() throws Exception { } /** - * Unlocks a container item in the user's inventory and consumes a key item of the type indicated by the container item + * Searches target inventory for an ItemInstance matching the given CatalogItemId, if necessary unlocks it using an appropriate key, and returns the contents of the opened container. If the container (and key when relevant) are consumable (RemainingUses > 0), their RemainingUses will be decremented, consistent with the operation of ConsumeItem. */ @SuppressWarnings("unchecked") private static PlayFabResult privateUnlockContainerItemAsync(final UnlockContainerItemRequest request) throws Exception { diff --git a/PlayFabSDK/src/com/playfab/PlayFabClientModels.java b/PlayFabSDK/src/com/playfab/PlayFabClientModels.java index 0d353dbc..cb925cb7 100644 --- a/PlayFabSDK/src/com/playfab/PlayFabClientModels.java +++ b/PlayFabSDK/src/com/playfab/PlayFabClientModels.java @@ -3220,13 +3220,33 @@ public static class UnlinkXboxAccountResult { } + public static class UnlockContainerInstanceRequest { + /** + * Unique PlayFab assigned ID for a specific character owned by a user + */ + public String CharacterId; + /** + * ItemInstanceId of the container to unlock. + */ + public String ContainerItemInstanceId; + /** + * ItemInstanceId of the key that will be consumed by unlocking this container. If the container requires a key, this parameter is required. + */ + public String KeyItemInstanceId; + /** + * Specifies the catalog version that should be used to determine container contents. If unspecified, uses catalog associated with the item instance. + */ + public String CatalogVersion; + + } + public static class UnlockContainerItemRequest { /** - * Category ItemId of the container type to unlock. + * Catalog ItemId of the container type to unlock. */ public String ContainerItemId; /** - * Catalog version of the container. + * Specifies the catalog version that should be used to determine container contents. If unspecified, uses default/primary catalog. */ public String CatalogVersion; /** diff --git a/PlayFabSDK/src/com/playfab/PlayFabErrors.java b/PlayFabSDK/src/com/playfab/PlayFabErrors.java index cf8d5471..428536c1 100644 --- a/PlayFabSDK/src/com/playfab/PlayFabErrors.java +++ b/PlayFabSDK/src/com/playfab/PlayFabErrors.java @@ -205,7 +205,8 @@ public static enum PlayFabErrorCode { InvalidDropTable(1201), StatisticVersionAlreadyIncrementedForScheduledInterval(1202), StatisticCountLimitExceeded(1203), - StatisticVersionIncrementRateExceeded(1204); + StatisticVersionIncrementRateExceeded(1204), + ContainerKeyInvalid(1205); public int id; diff --git a/PlayFabSDK/src/com/playfab/PlayFabServerAPI.java b/PlayFabSDK/src/com/playfab/PlayFabServerAPI.java index a3cba96d..25440f56 100644 --- a/PlayFabSDK/src/com/playfab/PlayFabServerAPI.java +++ b/PlayFabSDK/src/com/playfab/PlayFabServerAPI.java @@ -2568,6 +2568,122 @@ private static PlayFabResult privateSubtractUse return pfResult; } + /** + * Opens a specific container (ContainerItemInstanceId), with a specific key (KeyItemInstanceId, when required), and returns the contents of the opened container. If the container (and key when relevant) are consumable (RemainingUses > 0), their RemainingUses will be decremented, consistent with the operation of ConsumeItem. + */ + @SuppressWarnings("unchecked") + public static FutureTask> UnlockContainerInstanceAsync(final UnlockContainerInstanceRequest request) { + return new FutureTask(new Callable>() { + public PlayFabResult call() throws Exception { + return privateUnlockContainerInstanceAsync(request); + } + }); + } + + /** + * Opens a specific container (ContainerItemInstanceId), with a specific key (KeyItemInstanceId, when required), and returns the contents of the opened container. If the container (and key when relevant) are consumable (RemainingUses > 0), their RemainingUses will be decremented, consistent with the operation of ConsumeItem. + */ + @SuppressWarnings("unchecked") + public static PlayFabResult UnlockContainerInstance(final UnlockContainerInstanceRequest request) { + FutureTask> task = new FutureTask(new Callable>() { + public PlayFabResult call() throws Exception { + return privateUnlockContainerInstanceAsync(request); + } + }); + try { + task.run(); + return task.get(); + } catch(Exception e) { + return null; + } + } + + /** + * Opens a specific container (ContainerItemInstanceId), with a specific key (KeyItemInstanceId, when required), and returns the contents of the opened container. If the container (and key when relevant) are consumable (RemainingUses > 0), their RemainingUses will be decremented, consistent with the operation of ConsumeItem. + */ + @SuppressWarnings("unchecked") + private static PlayFabResult privateUnlockContainerInstanceAsync(final UnlockContainerInstanceRequest request) throws Exception { + if (PlayFabSettings.DeveloperSecretKey == null) throw new Exception ("Must have PlayFabSettings.DeveloperSecretKey set to call this method"); + + FutureTask task = PlayFabHTTP.doPost(PlayFabSettings.GetURL() + "/Server/UnlockContainerInstance", request, "X-SecretKey", PlayFabSettings.DeveloperSecretKey); + task.run(); + Object httpResult = task.get(); + if(httpResult instanceof PlayFabError) { + PlayFabError error = (PlayFabError)httpResult; + if (PlayFabSettings.GlobalErrorHandler != null) + PlayFabSettings.GlobalErrorHandler.callback(error); + PlayFabResult result = new PlayFabResult(); + result.Error = error; + return result; + } + String resultRawJson = (String) httpResult; + + PlayFabJsonSuccess resultData = gson.fromJson(resultRawJson, new TypeToken>(){}.getType()); + UnlockContainerItemResult result = resultData.data; + + PlayFabResult pfResult = new PlayFabResult(); + pfResult.Result = result; + return pfResult; + } + + /** + * Searches Player or Character inventory for any ItemInstance matching the given CatalogItemId, if necessary unlocks it using any appropriate key, and returns the contents of the opened container. If the container (and key when relevant) are consumable (RemainingUses > 0), their RemainingUses will be decremented, consistent with the operation of ConsumeItem. + */ + @SuppressWarnings("unchecked") + public static FutureTask> UnlockContainerItemAsync(final UnlockContainerItemRequest request) { + return new FutureTask(new Callable>() { + public PlayFabResult call() throws Exception { + return privateUnlockContainerItemAsync(request); + } + }); + } + + /** + * Searches Player or Character inventory for any ItemInstance matching the given CatalogItemId, if necessary unlocks it using any appropriate key, and returns the contents of the opened container. If the container (and key when relevant) are consumable (RemainingUses > 0), their RemainingUses will be decremented, consistent with the operation of ConsumeItem. + */ + @SuppressWarnings("unchecked") + public static PlayFabResult UnlockContainerItem(final UnlockContainerItemRequest request) { + FutureTask> task = new FutureTask(new Callable>() { + public PlayFabResult call() throws Exception { + return privateUnlockContainerItemAsync(request); + } + }); + try { + task.run(); + return task.get(); + } catch(Exception e) { + return null; + } + } + + /** + * Searches Player or Character inventory for any ItemInstance matching the given CatalogItemId, if necessary unlocks it using any appropriate key, and returns the contents of the opened container. If the container (and key when relevant) are consumable (RemainingUses > 0), their RemainingUses will be decremented, consistent with the operation of ConsumeItem. + */ + @SuppressWarnings("unchecked") + private static PlayFabResult privateUnlockContainerItemAsync(final UnlockContainerItemRequest request) throws Exception { + if (PlayFabSettings.DeveloperSecretKey == null) throw new Exception ("Must have PlayFabSettings.DeveloperSecretKey set to call this method"); + + FutureTask task = PlayFabHTTP.doPost(PlayFabSettings.GetURL() + "/Server/UnlockContainerItem", request, "X-SecretKey", PlayFabSettings.DeveloperSecretKey); + task.run(); + Object httpResult = task.get(); + if(httpResult instanceof PlayFabError) { + PlayFabError error = (PlayFabError)httpResult; + if (PlayFabSettings.GlobalErrorHandler != null) + PlayFabSettings.GlobalErrorHandler.callback(error); + PlayFabResult result = new PlayFabResult(); + result.Error = error; + return result; + } + String resultRawJson = (String) httpResult; + + PlayFabJsonSuccess resultData = gson.fromJson(resultRawJson, new TypeToken>(){}.getType()); + UnlockContainerItemResult result = resultData.data; + + PlayFabResult pfResult = new PlayFabResult(); + pfResult.Result = result; + return pfResult; + } + /** * Updates the key-value pair data tagged to the specified item, which is read-only from the client. */ diff --git a/PlayFabSDK/src/com/playfab/PlayFabServerModels.java b/PlayFabSDK/src/com/playfab/PlayFabServerModels.java index ef0ebccf..84341d8f 100644 --- a/PlayFabSDK/src/com/playfab/PlayFabServerModels.java +++ b/PlayFabSDK/src/com/playfab/PlayFabServerModels.java @@ -1977,6 +1977,70 @@ public static class TitleNewsItem { } + public static class UnlockContainerInstanceRequest { + /** + * Unique PlayFab assigned ID of the user on whom the operation will be performed. + */ + public String PlayFabId; + /** + * Unique PlayFab assigned ID for a specific character owned by a user + */ + public String CharacterId; + /** + * ItemInstanceId of the container to unlock. + */ + public String ContainerItemInstanceId; + /** + * ItemInstanceId of the key that will be consumed by unlocking this container. If the container requires a key, this parameter is required. + */ + public String KeyItemInstanceId; + /** + * Specifies the catalog version that should be used to determine container contents. If unspecified, uses catalog associated with the item instance. + */ + public String CatalogVersion; + + } + + public static class UnlockContainerItemRequest { + /** + * Unique PlayFab assigned ID of the user on whom the operation will be performed. + */ + public String PlayFabId; + /** + * Unique PlayFab assigned ID for a specific character owned by a user + */ + public String CharacterId; + /** + * Catalog ItemId of the container type to unlock. + */ + public String ContainerItemId; + /** + * Specifies the catalog version that should be used to determine container contents. If unspecified, uses default/primary catalog. + */ + public String CatalogVersion; + + } + + public static class UnlockContainerItemResult { + /** + * Unique instance identifier of the container unlocked. + */ + public String UnlockedItemInstanceId; + /** + * Unique instance identifier of the key used to unlock the container, if applicable. + */ + public String UnlockedWithItemInstanceId; + /** + * Items granted to the player as a result of unlocking the container. + */ + public ArrayList GrantedItems; + /** + * Virtual currency granted to the player as a result of unlocking the container. + */ + public Map VirtualCurrency; + + } + public static class UpdateCharacterDataRequest { /** * Unique PlayFab assigned ID of the user on whom the operation will be performed. diff --git a/PlayFabSDK/src/com/playfab/internal/PlayFabVersion.java b/PlayFabSDK/src/com/playfab/internal/PlayFabVersion.java index 6d0c98fe..09c3f9c0 100644 --- a/PlayFabSDK/src/com/playfab/internal/PlayFabVersion.java +++ b/PlayFabSDK/src/com/playfab/internal/PlayFabVersion.java @@ -1,7 +1,7 @@ package com.playfab.internal; public class PlayFabVersion { - public static String SdkRevision = "0.15.160208"; + public static String SdkRevision = "0.16.160208"; public static String getVersionString() { return "JavaSDK-" + SdkRevision; } diff --git a/PlayFabServerSDK/src/com/playfab/PlayFabErrors.java b/PlayFabServerSDK/src/com/playfab/PlayFabErrors.java index cf8d5471..428536c1 100644 --- a/PlayFabServerSDK/src/com/playfab/PlayFabErrors.java +++ b/PlayFabServerSDK/src/com/playfab/PlayFabErrors.java @@ -205,7 +205,8 @@ public static enum PlayFabErrorCode { InvalidDropTable(1201), StatisticVersionAlreadyIncrementedForScheduledInterval(1202), StatisticCountLimitExceeded(1203), - StatisticVersionIncrementRateExceeded(1204); + StatisticVersionIncrementRateExceeded(1204), + ContainerKeyInvalid(1205); public int id; diff --git a/PlayFabServerSDK/src/com/playfab/PlayFabServerAPI.java b/PlayFabServerSDK/src/com/playfab/PlayFabServerAPI.java index a3cba96d..25440f56 100644 --- a/PlayFabServerSDK/src/com/playfab/PlayFabServerAPI.java +++ b/PlayFabServerSDK/src/com/playfab/PlayFabServerAPI.java @@ -2568,6 +2568,122 @@ private static PlayFabResult privateSubtractUse return pfResult; } + /** + * Opens a specific container (ContainerItemInstanceId), with a specific key (KeyItemInstanceId, when required), and returns the contents of the opened container. If the container (and key when relevant) are consumable (RemainingUses > 0), their RemainingUses will be decremented, consistent with the operation of ConsumeItem. + */ + @SuppressWarnings("unchecked") + public static FutureTask> UnlockContainerInstanceAsync(final UnlockContainerInstanceRequest request) { + return new FutureTask(new Callable>() { + public PlayFabResult call() throws Exception { + return privateUnlockContainerInstanceAsync(request); + } + }); + } + + /** + * Opens a specific container (ContainerItemInstanceId), with a specific key (KeyItemInstanceId, when required), and returns the contents of the opened container. If the container (and key when relevant) are consumable (RemainingUses > 0), their RemainingUses will be decremented, consistent with the operation of ConsumeItem. + */ + @SuppressWarnings("unchecked") + public static PlayFabResult UnlockContainerInstance(final UnlockContainerInstanceRequest request) { + FutureTask> task = new FutureTask(new Callable>() { + public PlayFabResult call() throws Exception { + return privateUnlockContainerInstanceAsync(request); + } + }); + try { + task.run(); + return task.get(); + } catch(Exception e) { + return null; + } + } + + /** + * Opens a specific container (ContainerItemInstanceId), with a specific key (KeyItemInstanceId, when required), and returns the contents of the opened container. If the container (and key when relevant) are consumable (RemainingUses > 0), their RemainingUses will be decremented, consistent with the operation of ConsumeItem. + */ + @SuppressWarnings("unchecked") + private static PlayFabResult privateUnlockContainerInstanceAsync(final UnlockContainerInstanceRequest request) throws Exception { + if (PlayFabSettings.DeveloperSecretKey == null) throw new Exception ("Must have PlayFabSettings.DeveloperSecretKey set to call this method"); + + FutureTask task = PlayFabHTTP.doPost(PlayFabSettings.GetURL() + "/Server/UnlockContainerInstance", request, "X-SecretKey", PlayFabSettings.DeveloperSecretKey); + task.run(); + Object httpResult = task.get(); + if(httpResult instanceof PlayFabError) { + PlayFabError error = (PlayFabError)httpResult; + if (PlayFabSettings.GlobalErrorHandler != null) + PlayFabSettings.GlobalErrorHandler.callback(error); + PlayFabResult result = new PlayFabResult(); + result.Error = error; + return result; + } + String resultRawJson = (String) httpResult; + + PlayFabJsonSuccess resultData = gson.fromJson(resultRawJson, new TypeToken>(){}.getType()); + UnlockContainerItemResult result = resultData.data; + + PlayFabResult pfResult = new PlayFabResult(); + pfResult.Result = result; + return pfResult; + } + + /** + * Searches Player or Character inventory for any ItemInstance matching the given CatalogItemId, if necessary unlocks it using any appropriate key, and returns the contents of the opened container. If the container (and key when relevant) are consumable (RemainingUses > 0), their RemainingUses will be decremented, consistent with the operation of ConsumeItem. + */ + @SuppressWarnings("unchecked") + public static FutureTask> UnlockContainerItemAsync(final UnlockContainerItemRequest request) { + return new FutureTask(new Callable>() { + public PlayFabResult call() throws Exception { + return privateUnlockContainerItemAsync(request); + } + }); + } + + /** + * Searches Player or Character inventory for any ItemInstance matching the given CatalogItemId, if necessary unlocks it using any appropriate key, and returns the contents of the opened container. If the container (and key when relevant) are consumable (RemainingUses > 0), their RemainingUses will be decremented, consistent with the operation of ConsumeItem. + */ + @SuppressWarnings("unchecked") + public static PlayFabResult UnlockContainerItem(final UnlockContainerItemRequest request) { + FutureTask> task = new FutureTask(new Callable>() { + public PlayFabResult call() throws Exception { + return privateUnlockContainerItemAsync(request); + } + }); + try { + task.run(); + return task.get(); + } catch(Exception e) { + return null; + } + } + + /** + * Searches Player or Character inventory for any ItemInstance matching the given CatalogItemId, if necessary unlocks it using any appropriate key, and returns the contents of the opened container. If the container (and key when relevant) are consumable (RemainingUses > 0), their RemainingUses will be decremented, consistent with the operation of ConsumeItem. + */ + @SuppressWarnings("unchecked") + private static PlayFabResult privateUnlockContainerItemAsync(final UnlockContainerItemRequest request) throws Exception { + if (PlayFabSettings.DeveloperSecretKey == null) throw new Exception ("Must have PlayFabSettings.DeveloperSecretKey set to call this method"); + + FutureTask task = PlayFabHTTP.doPost(PlayFabSettings.GetURL() + "/Server/UnlockContainerItem", request, "X-SecretKey", PlayFabSettings.DeveloperSecretKey); + task.run(); + Object httpResult = task.get(); + if(httpResult instanceof PlayFabError) { + PlayFabError error = (PlayFabError)httpResult; + if (PlayFabSettings.GlobalErrorHandler != null) + PlayFabSettings.GlobalErrorHandler.callback(error); + PlayFabResult result = new PlayFabResult(); + result.Error = error; + return result; + } + String resultRawJson = (String) httpResult; + + PlayFabJsonSuccess resultData = gson.fromJson(resultRawJson, new TypeToken>(){}.getType()); + UnlockContainerItemResult result = resultData.data; + + PlayFabResult pfResult = new PlayFabResult(); + pfResult.Result = result; + return pfResult; + } + /** * Updates the key-value pair data tagged to the specified item, which is read-only from the client. */ diff --git a/PlayFabServerSDK/src/com/playfab/PlayFabServerModels.java b/PlayFabServerSDK/src/com/playfab/PlayFabServerModels.java index ef0ebccf..84341d8f 100644 --- a/PlayFabServerSDK/src/com/playfab/PlayFabServerModels.java +++ b/PlayFabServerSDK/src/com/playfab/PlayFabServerModels.java @@ -1977,6 +1977,70 @@ public static class TitleNewsItem { } + public static class UnlockContainerInstanceRequest { + /** + * Unique PlayFab assigned ID of the user on whom the operation will be performed. + */ + public String PlayFabId; + /** + * Unique PlayFab assigned ID for a specific character owned by a user + */ + public String CharacterId; + /** + * ItemInstanceId of the container to unlock. + */ + public String ContainerItemInstanceId; + /** + * ItemInstanceId of the key that will be consumed by unlocking this container. If the container requires a key, this parameter is required. + */ + public String KeyItemInstanceId; + /** + * Specifies the catalog version that should be used to determine container contents. If unspecified, uses catalog associated with the item instance. + */ + public String CatalogVersion; + + } + + public static class UnlockContainerItemRequest { + /** + * Unique PlayFab assigned ID of the user on whom the operation will be performed. + */ + public String PlayFabId; + /** + * Unique PlayFab assigned ID for a specific character owned by a user + */ + public String CharacterId; + /** + * Catalog ItemId of the container type to unlock. + */ + public String ContainerItemId; + /** + * Specifies the catalog version that should be used to determine container contents. If unspecified, uses default/primary catalog. + */ + public String CatalogVersion; + + } + + public static class UnlockContainerItemResult { + /** + * Unique instance identifier of the container unlocked. + */ + public String UnlockedItemInstanceId; + /** + * Unique instance identifier of the key used to unlock the container, if applicable. + */ + public String UnlockedWithItemInstanceId; + /** + * Items granted to the player as a result of unlocking the container. + */ + public ArrayList GrantedItems; + /** + * Virtual currency granted to the player as a result of unlocking the container. + */ + public Map VirtualCurrency; + + } + public static class UpdateCharacterDataRequest { /** * Unique PlayFab assigned ID of the user on whom the operation will be performed. diff --git a/PlayFabServerSDK/src/com/playfab/internal/PlayFabVersion.java b/PlayFabServerSDK/src/com/playfab/internal/PlayFabVersion.java index 6d0c98fe..09c3f9c0 100644 --- a/PlayFabServerSDK/src/com/playfab/internal/PlayFabVersion.java +++ b/PlayFabServerSDK/src/com/playfab/internal/PlayFabVersion.java @@ -1,7 +1,7 @@ package com.playfab.internal; public class PlayFabVersion { - public static String SdkRevision = "0.15.160208"; + public static String SdkRevision = "0.16.160208"; public static String getVersionString() { return "JavaSDK-" + SdkRevision; }