Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
com.playfab.PlayFabClientAPI Maven / Gradle / Ivy
Go to download
PlayFab is the unified backend platform for games — everything you need to build and operate your game, all in one place, so you can focus on creating and delivering a great player experience.
package com.playfab;
import com.playfab.internal.*;
import com.playfab.PlayFabClientModels.*;
import com.playfab.PlayFabErrors.*;
import com.playfab.PlayFabSettings;
import java.util.concurrent.*;
import java.util.*;
import com.google.gson.*;
import com.google.gson.reflect.*;
/**
* APIs which provide the full range of PlayFab features available to the client - authentication, account and data
* management, inventory, friends, matchmaking, reporting, and platform-specific functionality
*/
public class PlayFabClientAPI {
private static Gson gson = new GsonBuilder().setDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").create();
/**
* Accepts an open trade (one that has not yet been accepted or cancelled), if the locally signed-in player is in the
* allowed player list for the trade, or it is open to all players. If the call is successful, the offered and accepted
* items will be swapped between the two players' inventories.
* @param request AcceptTradeRequest
* @return Async Task will return AcceptTradeResponse
*/
@SuppressWarnings("unchecked")
public static FutureTask> AcceptTradeAsync(final AcceptTradeRequest request) {
return new FutureTask(new Callable>() {
public PlayFabResult call() throws Exception {
return privateAcceptTradeAsync(request);
}
});
}
/**
* Accepts an open trade (one that has not yet been accepted or cancelled), if the locally signed-in player is in the
* allowed player list for the trade, or it is open to all players. If the call is successful, the offered and accepted
* items will be swapped between the two players' inventories.
* @param request AcceptTradeRequest
* @return AcceptTradeResponse
*/
@SuppressWarnings("unchecked")
public static PlayFabResult AcceptTrade(final AcceptTradeRequest request) {
FutureTask> task = new FutureTask(new Callable>() {
public PlayFabResult call() throws Exception {
return privateAcceptTradeAsync(request);
}
});
try {
task.run();
return task.get();
} catch(Exception e) {
return null;
}
}
/**
* Accepts an open trade (one that has not yet been accepted or cancelled), if the locally signed-in player is in the
* allowed player list for the trade, or it is open to all players. If the call is successful, the offered and accepted
* items will be swapped between the two players' inventories.
*/
@SuppressWarnings("unchecked")
private static PlayFabResult privateAcceptTradeAsync(final AcceptTradeRequest request) throws Exception {
if (PlayFabSettings.ClientSessionTicket == null) throw new Exception ("Must be logged in to call this method");
FutureTask task = PlayFabHTTP.doPost(PlayFabSettings.GetURL("/Client/AcceptTrade"), request, "X-Authorization", PlayFabSettings.ClientSessionTicket);
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());
AcceptTradeResponse result = resultData.data;
PlayFabResult pfResult = new PlayFabResult();
pfResult.Result = result;
return pfResult;
}
/**
* Adds the PlayFab user, based upon a match against a supplied unique identifier, to the friend list of the local user. At
* least one of FriendPlayFabId,FriendUsername,FriendEmail, or FriendTitleDisplayName should be initialized.
* @param request AddFriendRequest
* @return Async Task will return AddFriendResult
*/
@SuppressWarnings("unchecked")
public static FutureTask> AddFriendAsync(final AddFriendRequest request) {
return new FutureTask(new Callable>() {
public PlayFabResult call() throws Exception {
return privateAddFriendAsync(request);
}
});
}
/**
* Adds the PlayFab user, based upon a match against a supplied unique identifier, to the friend list of the local user. At
* least one of FriendPlayFabId,FriendUsername,FriendEmail, or FriendTitleDisplayName should be initialized.
* @param request AddFriendRequest
* @return AddFriendResult
*/
@SuppressWarnings("unchecked")
public static PlayFabResult AddFriend(final AddFriendRequest request) {
FutureTask> task = new FutureTask(new Callable>() {
public PlayFabResult call() throws Exception {
return privateAddFriendAsync(request);
}
});
try {
task.run();
return task.get();
} catch(Exception e) {
return null;
}
}
/**
* Adds the PlayFab user, based upon a match against a supplied unique identifier, to the friend list of the local user. At
* least one of FriendPlayFabId,FriendUsername,FriendEmail, or FriendTitleDisplayName should be initialized.
*/
@SuppressWarnings("unchecked")
private static PlayFabResult privateAddFriendAsync(final AddFriendRequest request) throws Exception {
if (PlayFabSettings.ClientSessionTicket == null) throw new Exception ("Must be logged in to call this method");
FutureTask task = PlayFabHTTP.doPost(PlayFabSettings.GetURL("/Client/AddFriend"), request, "X-Authorization", PlayFabSettings.ClientSessionTicket);
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());
AddFriendResult result = resultData.data;
PlayFabResult pfResult = new PlayFabResult();
pfResult.Result = result;
return pfResult;
}
/**
* Adds the specified generic service identifier to the player's PlayFab account. This is designed to allow for a PlayFab
* ID lookup of any arbitrary service identifier a title wants to add. This identifier should never be used as
* authentication credentials, as the intent is that it is easily accessible by other players.
* @param request AddGenericIDRequest
* @return Async Task will return AddGenericIDResult
*/
@SuppressWarnings("unchecked")
public static FutureTask> AddGenericIDAsync(final AddGenericIDRequest request) {
return new FutureTask(new Callable>() {
public PlayFabResult call() throws Exception {
return privateAddGenericIDAsync(request);
}
});
}
/**
* Adds the specified generic service identifier to the player's PlayFab account. This is designed to allow for a PlayFab
* ID lookup of any arbitrary service identifier a title wants to add. This identifier should never be used as
* authentication credentials, as the intent is that it is easily accessible by other players.
* @param request AddGenericIDRequest
* @return AddGenericIDResult
*/
@SuppressWarnings("unchecked")
public static PlayFabResult AddGenericID(final AddGenericIDRequest request) {
FutureTask> task = new FutureTask(new Callable>() {
public PlayFabResult call() throws Exception {
return privateAddGenericIDAsync(request);
}
});
try {
task.run();
return task.get();
} catch(Exception e) {
return null;
}
}
/**
* Adds the specified generic service identifier to the player's PlayFab account. This is designed to allow for a PlayFab
* ID lookup of any arbitrary service identifier a title wants to add. This identifier should never be used as
* authentication credentials, as the intent is that it is easily accessible by other players.
*/
@SuppressWarnings("unchecked")
private static PlayFabResult privateAddGenericIDAsync(final AddGenericIDRequest request) throws Exception {
if (PlayFabSettings.ClientSessionTicket == null) throw new Exception ("Must be logged in to call this method");
FutureTask task = PlayFabHTTP.doPost(PlayFabSettings.GetURL("/Client/AddGenericID"), request, "X-Authorization", PlayFabSettings.ClientSessionTicket);
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());
AddGenericIDResult result = resultData.data;
PlayFabResult pfResult = new PlayFabResult();
pfResult.Result = result;
return pfResult;
}
/**
* Adds or updates a contact email to the player's profile.
* @param request AddOrUpdateContactEmailRequest
* @return Async Task will return AddOrUpdateContactEmailResult
*/
@SuppressWarnings("unchecked")
public static FutureTask> AddOrUpdateContactEmailAsync(final AddOrUpdateContactEmailRequest request) {
return new FutureTask(new Callable>() {
public PlayFabResult call() throws Exception {
return privateAddOrUpdateContactEmailAsync(request);
}
});
}
/**
* Adds or updates a contact email to the player's profile.
* @param request AddOrUpdateContactEmailRequest
* @return AddOrUpdateContactEmailResult
*/
@SuppressWarnings("unchecked")
public static PlayFabResult AddOrUpdateContactEmail(final AddOrUpdateContactEmailRequest request) {
FutureTask> task = new FutureTask(new Callable>() {
public PlayFabResult call() throws Exception {
return privateAddOrUpdateContactEmailAsync(request);
}
});
try {
task.run();
return task.get();
} catch(Exception e) {
return null;
}
}
/** Adds or updates a contact email to the player's profile. */
@SuppressWarnings("unchecked")
private static PlayFabResult privateAddOrUpdateContactEmailAsync(final AddOrUpdateContactEmailRequest request) throws Exception {
if (PlayFabSettings.ClientSessionTicket == null) throw new Exception ("Must be logged in to call this method");
FutureTask task = PlayFabHTTP.doPost(PlayFabSettings.GetURL("/Client/AddOrUpdateContactEmail"), request, "X-Authorization", PlayFabSettings.ClientSessionTicket);
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());
AddOrUpdateContactEmailResult result = resultData.data;
PlayFabResult pfResult = new PlayFabResult();
pfResult.Result = result;
return pfResult;
}
/**
* Adds users to the set of those able to update both the shared data, as well as the set of users in the group. Only users
* in the group can add new members. Shared Groups are designed for sharing data between a very small number of players,
* please see our guide: https://api.playfab.com/docs/tutorials/landing-players/shared-groups
* @param request AddSharedGroupMembersRequest
* @return Async Task will return AddSharedGroupMembersResult
*/
@SuppressWarnings("unchecked")
public static FutureTask> AddSharedGroupMembersAsync(final AddSharedGroupMembersRequest request) {
return new FutureTask(new Callable>() {
public PlayFabResult call() throws Exception {
return privateAddSharedGroupMembersAsync(request);
}
});
}
/**
* Adds users to the set of those able to update both the shared data, as well as the set of users in the group. Only users
* in the group can add new members. Shared Groups are designed for sharing data between a very small number of players,
* please see our guide: https://api.playfab.com/docs/tutorials/landing-players/shared-groups
* @param request AddSharedGroupMembersRequest
* @return AddSharedGroupMembersResult
*/
@SuppressWarnings("unchecked")
public static PlayFabResult AddSharedGroupMembers(final AddSharedGroupMembersRequest request) {
FutureTask> task = new FutureTask(new Callable>() {
public PlayFabResult call() throws Exception {
return privateAddSharedGroupMembersAsync(request);
}
});
try {
task.run();
return task.get();
} catch(Exception e) {
return null;
}
}
/**
* Adds users to the set of those able to update both the shared data, as well as the set of users in the group. Only users
* in the group can add new members. Shared Groups are designed for sharing data between a very small number of players,
* please see our guide: https://api.playfab.com/docs/tutorials/landing-players/shared-groups
*/
@SuppressWarnings("unchecked")
private static PlayFabResult privateAddSharedGroupMembersAsync(final AddSharedGroupMembersRequest request) throws Exception {
if (PlayFabSettings.ClientSessionTicket == null) throw new Exception ("Must be logged in to call this method");
FutureTask task = PlayFabHTTP.doPost(PlayFabSettings.GetURL("/Client/AddSharedGroupMembers"), request, "X-Authorization", PlayFabSettings.ClientSessionTicket);
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());
AddSharedGroupMembersResult result = resultData.data;
PlayFabResult pfResult = new PlayFabResult();
pfResult.Result = result;
return pfResult;
}
/**
* Adds playfab username/password auth to an existing account created via an anonymous auth method, e.g. automatic device
* ID login.
* @param request AddUsernamePasswordRequest
* @return Async Task will return AddUsernamePasswordResult
*/
@SuppressWarnings("unchecked")
public static FutureTask> AddUsernamePasswordAsync(final AddUsernamePasswordRequest request) {
return new FutureTask(new Callable>() {
public PlayFabResult call() throws Exception {
return privateAddUsernamePasswordAsync(request);
}
});
}
/**
* Adds playfab username/password auth to an existing account created via an anonymous auth method, e.g. automatic device
* ID login.
* @param request AddUsernamePasswordRequest
* @return AddUsernamePasswordResult
*/
@SuppressWarnings("unchecked")
public static PlayFabResult AddUsernamePassword(final AddUsernamePasswordRequest request) {
FutureTask> task = new FutureTask(new Callable>() {
public PlayFabResult call() throws Exception {
return privateAddUsernamePasswordAsync(request);
}
});
try {
task.run();
return task.get();
} catch(Exception e) {
return null;
}
}
/**
* Adds playfab username/password auth to an existing account created via an anonymous auth method, e.g. automatic device
* ID login.
*/
@SuppressWarnings("unchecked")
private static PlayFabResult privateAddUsernamePasswordAsync(final AddUsernamePasswordRequest request) throws Exception {
if (PlayFabSettings.ClientSessionTicket == null) throw new Exception ("Must be logged in to call this method");
FutureTask task = PlayFabHTTP.doPost(PlayFabSettings.GetURL("/Client/AddUsernamePassword"), request, "X-Authorization", PlayFabSettings.ClientSessionTicket);
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());
AddUsernamePasswordResult result = resultData.data;
PlayFabResult pfResult = new PlayFabResult();
pfResult.Result = result;
return pfResult;
}
/**
* Increments the user's balance of the specified virtual currency by the stated amount
* @param request AddUserVirtualCurrencyRequest
* @return Async Task will return ModifyUserVirtualCurrencyResult
*/
@SuppressWarnings("unchecked")
public static FutureTask> AddUserVirtualCurrencyAsync(final AddUserVirtualCurrencyRequest request) {
return new FutureTask(new Callable>() {
public PlayFabResult call() throws Exception {
return privateAddUserVirtualCurrencyAsync(request);
}
});
}
/**
* Increments the user's balance of the specified virtual currency by the stated amount
* @param request AddUserVirtualCurrencyRequest
* @return ModifyUserVirtualCurrencyResult
*/
@SuppressWarnings("unchecked")
public static PlayFabResult AddUserVirtualCurrency(final AddUserVirtualCurrencyRequest request) {
FutureTask> task = new FutureTask(new Callable>() {
public PlayFabResult call() throws Exception {
return privateAddUserVirtualCurrencyAsync(request);
}
});
try {
task.run();
return task.get();
} catch(Exception e) {
return null;
}
}
/** Increments the user's balance of the specified virtual currency by the stated amount */
@SuppressWarnings("unchecked")
private static PlayFabResult privateAddUserVirtualCurrencyAsync(final AddUserVirtualCurrencyRequest request) throws Exception {
if (PlayFabSettings.ClientSessionTicket == null) throw new Exception ("Must be logged in to call this method");
FutureTask task = PlayFabHTTP.doPost(PlayFabSettings.GetURL("/Client/AddUserVirtualCurrency"), request, "X-Authorization", PlayFabSettings.ClientSessionTicket);
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());
ModifyUserVirtualCurrencyResult result = resultData.data;
PlayFabResult pfResult = new PlayFabResult();
pfResult.Result = result;
return pfResult;
}
/**
* Registers the Android device to receive push notifications
* @param request AndroidDevicePushNotificationRegistrationRequest
* @return Async Task will return AndroidDevicePushNotificationRegistrationResult
*/
@SuppressWarnings("unchecked")
public static FutureTask> AndroidDevicePushNotificationRegistrationAsync(final AndroidDevicePushNotificationRegistrationRequest request) {
return new FutureTask(new Callable>() {
public PlayFabResult call() throws Exception {
return privateAndroidDevicePushNotificationRegistrationAsync(request);
}
});
}
/**
* Registers the Android device to receive push notifications
* @param request AndroidDevicePushNotificationRegistrationRequest
* @return AndroidDevicePushNotificationRegistrationResult
*/
@SuppressWarnings("unchecked")
public static PlayFabResult AndroidDevicePushNotificationRegistration(final AndroidDevicePushNotificationRegistrationRequest request) {
FutureTask> task = new FutureTask(new Callable>() {
public PlayFabResult call() throws Exception {
return privateAndroidDevicePushNotificationRegistrationAsync(request);
}
});
try {
task.run();
return task.get();
} catch(Exception e) {
return null;
}
}
/** Registers the Android device to receive push notifications */
@SuppressWarnings("unchecked")
private static PlayFabResult privateAndroidDevicePushNotificationRegistrationAsync(final AndroidDevicePushNotificationRegistrationRequest request) throws Exception {
if (PlayFabSettings.ClientSessionTicket == null) throw new Exception ("Must be logged in to call this method");
FutureTask task = PlayFabHTTP.doPost(PlayFabSettings.GetURL("/Client/AndroidDevicePushNotificationRegistration"), request, "X-Authorization", PlayFabSettings.ClientSessionTicket);
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());
AndroidDevicePushNotificationRegistrationResult result = resultData.data;
PlayFabResult pfResult = new PlayFabResult();
pfResult.Result = result;
return pfResult;
}
/**
* Attributes an install for advertisment.
* @param request AttributeInstallRequest
* @return Async Task will return AttributeInstallResult
*/
@SuppressWarnings("unchecked")
public static FutureTask> AttributeInstallAsync(final AttributeInstallRequest request) {
return new FutureTask(new Callable>() {
public PlayFabResult call() throws Exception {
return privateAttributeInstallAsync(request);
}
});
}
/**
* Attributes an install for advertisment.
* @param request AttributeInstallRequest
* @return AttributeInstallResult
*/
@SuppressWarnings("unchecked")
public static PlayFabResult AttributeInstall(final AttributeInstallRequest request) {
FutureTask> task = new FutureTask(new Callable>() {
public PlayFabResult call() throws Exception {
return privateAttributeInstallAsync(request);
}
});
try {
task.run();
return task.get();
} catch(Exception e) {
return null;
}
}
/** Attributes an install for advertisment. */
@SuppressWarnings("unchecked")
private static PlayFabResult privateAttributeInstallAsync(final AttributeInstallRequest request) throws Exception {
if (PlayFabSettings.ClientSessionTicket == null) throw new Exception ("Must be logged in to call this method");
FutureTask task = PlayFabHTTP.doPost(PlayFabSettings.GetURL("/Client/AttributeInstall"), request, "X-Authorization", PlayFabSettings.ClientSessionTicket);
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());
AttributeInstallResult result = resultData.data;
// Modify AdvertisingIdType: Prevents us from sending the id multiple times, and allows automated tests to determine id was sent successfully
PlayFabSettings.AdvertisingIdType += "_Successful";
PlayFabResult pfResult = new PlayFabResult();
pfResult.Result = result;
return pfResult;
}
/**
* Cancels an open trade (one that has not yet been accepted or cancelled). Note that only the player who created the trade
* can cancel it via this API call, to prevent griefing of the trade system (cancelling trades in order to prevent other
* players from accepting them, for trades that can be claimed by more than one player).
* @param request CancelTradeRequest
* @return Async Task will return CancelTradeResponse
*/
@SuppressWarnings("unchecked")
public static FutureTask> CancelTradeAsync(final CancelTradeRequest request) {
return new FutureTask(new Callable>() {
public PlayFabResult call() throws Exception {
return privateCancelTradeAsync(request);
}
});
}
/**
* Cancels an open trade (one that has not yet been accepted or cancelled). Note that only the player who created the trade
* can cancel it via this API call, to prevent griefing of the trade system (cancelling trades in order to prevent other
* players from accepting them, for trades that can be claimed by more than one player).
* @param request CancelTradeRequest
* @return CancelTradeResponse
*/
@SuppressWarnings("unchecked")
public static PlayFabResult CancelTrade(final CancelTradeRequest request) {
FutureTask> task = new FutureTask(new Callable>() {
public PlayFabResult call() throws Exception {
return privateCancelTradeAsync(request);
}
});
try {
task.run();
return task.get();
} catch(Exception e) {
return null;
}
}
/**
* Cancels an open trade (one that has not yet been accepted or cancelled). Note that only the player who created the trade
* can cancel it via this API call, to prevent griefing of the trade system (cancelling trades in order to prevent other
* players from accepting them, for trades that can be claimed by more than one player).
*/
@SuppressWarnings("unchecked")
private static PlayFabResult privateCancelTradeAsync(final CancelTradeRequest request) throws Exception {
if (PlayFabSettings.ClientSessionTicket == null) throw new Exception ("Must be logged in to call this method");
FutureTask task = PlayFabHTTP.doPost(PlayFabSettings.GetURL("/Client/CancelTrade"), request, "X-Authorization", PlayFabSettings.ClientSessionTicket);
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());
CancelTradeResponse result = resultData.data;
PlayFabResult pfResult = new PlayFabResult();
pfResult.Result = result;
return pfResult;
}
/**
* Confirms with the payment provider that the purchase was approved (if applicable) and adjusts inventory and virtual
* currency balances as appropriate
* @param request ConfirmPurchaseRequest
* @return Async Task will return ConfirmPurchaseResult
*/
@SuppressWarnings("unchecked")
public static FutureTask> ConfirmPurchaseAsync(final ConfirmPurchaseRequest request) {
return new FutureTask(new Callable>() {
public PlayFabResult call() throws Exception {
return privateConfirmPurchaseAsync(request);
}
});
}
/**
* Confirms with the payment provider that the purchase was approved (if applicable) and adjusts inventory and virtual
* currency balances as appropriate
* @param request ConfirmPurchaseRequest
* @return ConfirmPurchaseResult
*/
@SuppressWarnings("unchecked")
public static PlayFabResult ConfirmPurchase(final ConfirmPurchaseRequest request) {
FutureTask> task = new FutureTask(new Callable>() {
public PlayFabResult call() throws Exception {
return privateConfirmPurchaseAsync(request);
}
});
try {
task.run();
return task.get();
} catch(Exception e) {
return null;
}
}
/**
* Confirms with the payment provider that the purchase was approved (if applicable) and adjusts inventory and virtual
* currency balances as appropriate
*/
@SuppressWarnings("unchecked")
private static PlayFabResult privateConfirmPurchaseAsync(final ConfirmPurchaseRequest request) throws Exception {
if (PlayFabSettings.ClientSessionTicket == null) throw new Exception ("Must be logged in to call this method");
FutureTask task = PlayFabHTTP.doPost(PlayFabSettings.GetURL("/Client/ConfirmPurchase"), request, "X-Authorization", PlayFabSettings.ClientSessionTicket);
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());
ConfirmPurchaseResult result = resultData.data;
PlayFabResult pfResult = new PlayFabResult();
pfResult.Result = result;
return pfResult;
}
/**
* Consume uses of a consumable item. When all uses are consumed, it will be removed from the player's inventory.
* @param request ConsumeItemRequest
* @return Async Task will return ConsumeItemResult
*/
@SuppressWarnings("unchecked")
public static FutureTask> ConsumeItemAsync(final ConsumeItemRequest request) {
return new FutureTask(new Callable>() {
public PlayFabResult call() throws Exception {
return privateConsumeItemAsync(request);
}
});
}
/**
* Consume uses of a consumable item. When all uses are consumed, it will be removed from the player's inventory.
* @param request ConsumeItemRequest
* @return ConsumeItemResult
*/
@SuppressWarnings("unchecked")
public static PlayFabResult ConsumeItem(final ConsumeItemRequest request) {
FutureTask> task = new FutureTask(new Callable>() {
public PlayFabResult call() throws Exception {
return privateConsumeItemAsync(request);
}
});
try {
task.run();
return task.get();
} catch(Exception e) {
return null;
}
}
/** Consume uses of a consumable item. When all uses are consumed, it will be removed from the player's inventory. */
@SuppressWarnings("unchecked")
private static PlayFabResult privateConsumeItemAsync(final ConsumeItemRequest request) throws Exception {
if (PlayFabSettings.ClientSessionTicket == null) throw new Exception ("Must be logged in to call this method");
FutureTask task = PlayFabHTTP.doPost(PlayFabSettings.GetURL("/Client/ConsumeItem"), request, "X-Authorization", PlayFabSettings.ClientSessionTicket);
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());
ConsumeItemResult result = resultData.data;
PlayFabResult pfResult = new PlayFabResult();
pfResult.Result = result;
return pfResult;
}
/**
* Checks for any new consumable entitlements. If any are found, they are consumed and added as PlayFab items
* @param request ConsumePSNEntitlementsRequest
* @return Async Task will return ConsumePSNEntitlementsResult
*/
@SuppressWarnings("unchecked")
public static FutureTask> ConsumePSNEntitlementsAsync(final ConsumePSNEntitlementsRequest request) {
return new FutureTask(new Callable>() {
public PlayFabResult call() throws Exception {
return privateConsumePSNEntitlementsAsync(request);
}
});
}
/**
* Checks for any new consumable entitlements. If any are found, they are consumed and added as PlayFab items
* @param request ConsumePSNEntitlementsRequest
* @return ConsumePSNEntitlementsResult
*/
@SuppressWarnings("unchecked")
public static PlayFabResult ConsumePSNEntitlements(final ConsumePSNEntitlementsRequest request) {
FutureTask> task = new FutureTask(new Callable>() {
public PlayFabResult call() throws Exception {
return privateConsumePSNEntitlementsAsync(request);
}
});
try {
task.run();
return task.get();
} catch(Exception e) {
return null;
}
}
/** Checks for any new consumable entitlements. If any are found, they are consumed and added as PlayFab items */
@SuppressWarnings("unchecked")
private static PlayFabResult privateConsumePSNEntitlementsAsync(final ConsumePSNEntitlementsRequest request) throws Exception {
if (PlayFabSettings.ClientSessionTicket == null) throw new Exception ("Must be logged in to call this method");
FutureTask task = PlayFabHTTP.doPost(PlayFabSettings.GetURL("/Client/ConsumePSNEntitlements"), request, "X-Authorization", PlayFabSettings.ClientSessionTicket);
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());
ConsumePSNEntitlementsResult result = resultData.data;
PlayFabResult pfResult = new PlayFabResult();
pfResult.Result = result;
return pfResult;
}
/**
* Grants the player's current entitlements from Xbox Live, consuming all availble items in Xbox and granting them to the
* player's PlayFab inventory. This call is idempotent and will not grant previously granted items to the player.
* @param request ConsumeXboxEntitlementsRequest
* @return Async Task will return ConsumeXboxEntitlementsResult
*/
@SuppressWarnings("unchecked")
public static FutureTask> ConsumeXboxEntitlementsAsync(final ConsumeXboxEntitlementsRequest request) {
return new FutureTask(new Callable>() {
public PlayFabResult call() throws Exception {
return privateConsumeXboxEntitlementsAsync(request);
}
});
}
/**
* Grants the player's current entitlements from Xbox Live, consuming all availble items in Xbox and granting them to the
* player's PlayFab inventory. This call is idempotent and will not grant previously granted items to the player.
* @param request ConsumeXboxEntitlementsRequest
* @return ConsumeXboxEntitlementsResult
*/
@SuppressWarnings("unchecked")
public static PlayFabResult ConsumeXboxEntitlements(final ConsumeXboxEntitlementsRequest request) {
FutureTask> task = new FutureTask(new Callable>() {
public PlayFabResult call() throws Exception {
return privateConsumeXboxEntitlementsAsync(request);
}
});
try {
task.run();
return task.get();
} catch(Exception e) {
return null;
}
}
/**
* Grants the player's current entitlements from Xbox Live, consuming all availble items in Xbox and granting them to the
* player's PlayFab inventory. This call is idempotent and will not grant previously granted items to the player.
*/
@SuppressWarnings("unchecked")
private static PlayFabResult privateConsumeXboxEntitlementsAsync(final ConsumeXboxEntitlementsRequest request) throws Exception {
if (PlayFabSettings.ClientSessionTicket == null) throw new Exception ("Must be logged in to call this method");
FutureTask task = PlayFabHTTP.doPost(PlayFabSettings.GetURL("/Client/ConsumeXboxEntitlements"), request, "X-Authorization", PlayFabSettings.ClientSessionTicket);
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());
ConsumeXboxEntitlementsResult result = resultData.data;
PlayFabResult pfResult = new PlayFabResult();
pfResult.Result = result;
return pfResult;
}
/**
* Requests the creation of a shared group object, containing key/value pairs which may be updated by all members of the
* group. Upon creation, the current user will be the only member of the group. Shared Groups are designed for sharing data
* between a very small number of players, please see our guide:
* https://api.playfab.com/docs/tutorials/landing-players/shared-groups
* @param request CreateSharedGroupRequest
* @return Async Task will return CreateSharedGroupResult
*/
@SuppressWarnings("unchecked")
public static FutureTask> CreateSharedGroupAsync(final CreateSharedGroupRequest request) {
return new FutureTask(new Callable>() {
public PlayFabResult call() throws Exception {
return privateCreateSharedGroupAsync(request);
}
});
}
/**
* Requests the creation of a shared group object, containing key/value pairs which may be updated by all members of the
* group. Upon creation, the current user will be the only member of the group. Shared Groups are designed for sharing data
* between a very small number of players, please see our guide:
* https://api.playfab.com/docs/tutorials/landing-players/shared-groups
* @param request CreateSharedGroupRequest
* @return CreateSharedGroupResult
*/
@SuppressWarnings("unchecked")
public static PlayFabResult CreateSharedGroup(final CreateSharedGroupRequest request) {
FutureTask> task = new FutureTask(new Callable>() {
public PlayFabResult call() throws Exception {
return privateCreateSharedGroupAsync(request);
}
});
try {
task.run();
return task.get();
} catch(Exception e) {
return null;
}
}
/**
* Requests the creation of a shared group object, containing key/value pairs which may be updated by all members of the
* group. Upon creation, the current user will be the only member of the group. Shared Groups are designed for sharing data
* between a very small number of players, please see our guide:
* https://api.playfab.com/docs/tutorials/landing-players/shared-groups
*/
@SuppressWarnings("unchecked")
private static PlayFabResult privateCreateSharedGroupAsync(final CreateSharedGroupRequest request) throws Exception {
if (PlayFabSettings.ClientSessionTicket == null) throw new Exception ("Must be logged in to call this method");
FutureTask task = PlayFabHTTP.doPost(PlayFabSettings.GetURL("/Client/CreateSharedGroup"), request, "X-Authorization", PlayFabSettings.ClientSessionTicket);
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());
CreateSharedGroupResult result = resultData.data;
PlayFabResult pfResult = new PlayFabResult();
pfResult.Result = result;
return pfResult;
}
/**
* Executes a CloudScript function, with the 'currentPlayerId' set to the PlayFab ID of the authenticated player.
* @param request ExecuteCloudScriptRequest
* @return Async Task will return ExecuteCloudScriptResult
*/
@SuppressWarnings("unchecked")
public static FutureTask> ExecuteCloudScriptAsync(final ExecuteCloudScriptRequest request) {
return new FutureTask(new Callable>() {
public PlayFabResult call() throws Exception {
return privateExecuteCloudScriptAsync(request);
}
});
}
/**
* Executes a CloudScript function, with the 'currentPlayerId' set to the PlayFab ID of the authenticated player.
* @param request ExecuteCloudScriptRequest
* @return ExecuteCloudScriptResult
*/
@SuppressWarnings("unchecked")
public static PlayFabResult ExecuteCloudScript(final ExecuteCloudScriptRequest request) {
FutureTask> task = new FutureTask(new Callable>() {
public PlayFabResult call() throws Exception {
return privateExecuteCloudScriptAsync(request);
}
});
try {
task.run();
return task.get();
} catch(Exception e) {
return null;
}
}
/** Executes a CloudScript function, with the 'currentPlayerId' set to the PlayFab ID of the authenticated player. */
@SuppressWarnings("unchecked")
private static PlayFabResult privateExecuteCloudScriptAsync(final ExecuteCloudScriptRequest request) throws Exception {
if (PlayFabSettings.ClientSessionTicket == null) throw new Exception ("Must be logged in to call this method");
FutureTask task = PlayFabHTTP.doPost(PlayFabSettings.GetURL("/Client/ExecuteCloudScript"), request, "X-Authorization", PlayFabSettings.ClientSessionTicket);
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());
ExecuteCloudScriptResult result = resultData.data;
PlayFabResult pfResult = new PlayFabResult();
pfResult.Result = result;
return pfResult;
}
/**
* Retrieves the user's PlayFab account details
* @param request GetAccountInfoRequest
* @return Async Task will return GetAccountInfoResult
*/
@SuppressWarnings("unchecked")
public static FutureTask> GetAccountInfoAsync(final GetAccountInfoRequest request) {
return new FutureTask(new Callable>() {
public PlayFabResult call() throws Exception {
return privateGetAccountInfoAsync(request);
}
});
}
/**
* Retrieves the user's PlayFab account details
* @param request GetAccountInfoRequest
* @return GetAccountInfoResult
*/
@SuppressWarnings("unchecked")
public static PlayFabResult GetAccountInfo(final GetAccountInfoRequest request) {
FutureTask> task = new FutureTask(new Callable>() {
public PlayFabResult call() throws Exception {
return privateGetAccountInfoAsync(request);
}
});
try {
task.run();
return task.get();
} catch(Exception e) {
return null;
}
}
/** Retrieves the user's PlayFab account details */
@SuppressWarnings("unchecked")
private static PlayFabResult privateGetAccountInfoAsync(final GetAccountInfoRequest request) throws Exception {
if (PlayFabSettings.ClientSessionTicket == null) throw new Exception ("Must be logged in to call this method");
FutureTask task = PlayFabHTTP.doPost(PlayFabSettings.GetURL("/Client/GetAccountInfo"), request, "X-Authorization", PlayFabSettings.ClientSessionTicket);
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());
GetAccountInfoResult result = resultData.data;
PlayFabResult pfResult = new PlayFabResult();
pfResult.Result = result;
return pfResult;
}
/**
* Lists all of the characters that belong to a specific user. CharacterIds are not globally unique; characterId must be
* evaluated with the parent PlayFabId to guarantee uniqueness.
* @param request ListUsersCharactersRequest
* @return Async Task will return ListUsersCharactersResult
*/
@SuppressWarnings("unchecked")
public static FutureTask> GetAllUsersCharactersAsync(final ListUsersCharactersRequest request) {
return new FutureTask(new Callable>() {
public PlayFabResult call() throws Exception {
return privateGetAllUsersCharactersAsync(request);
}
});
}
/**
* Lists all of the characters that belong to a specific user. CharacterIds are not globally unique; characterId must be
* evaluated with the parent PlayFabId to guarantee uniqueness.
* @param request ListUsersCharactersRequest
* @return ListUsersCharactersResult
*/
@SuppressWarnings("unchecked")
public static PlayFabResult GetAllUsersCharacters(final ListUsersCharactersRequest request) {
FutureTask> task = new FutureTask(new Callable>() {
public PlayFabResult call() throws Exception {
return privateGetAllUsersCharactersAsync(request);
}
});
try {
task.run();
return task.get();
} catch(Exception e) {
return null;
}
}
/**
* Lists all of the characters that belong to a specific user. CharacterIds are not globally unique; characterId must be
* evaluated with the parent PlayFabId to guarantee uniqueness.
*/
@SuppressWarnings("unchecked")
private static PlayFabResult privateGetAllUsersCharactersAsync(final ListUsersCharactersRequest request) throws Exception {
if (PlayFabSettings.ClientSessionTicket == null) throw new Exception ("Must be logged in to call this method");
FutureTask task = PlayFabHTTP.doPost(PlayFabSettings.GetURL("/Client/GetAllUsersCharacters"), request, "X-Authorization", PlayFabSettings.ClientSessionTicket);
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());
ListUsersCharactersResult result = resultData.data;
PlayFabResult pfResult = new PlayFabResult