All Downloads are FREE. Search and download functionalities are using the official Maven repository.
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.PlayFabDataAPI 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.PlayFabDataModels.*;
import com.playfab.PlayFabErrors.*;
import com.playfab.PlayFabSettings;
import java.util.concurrent.*;
import java.util.*;
import com.google.gson.*;
import com.google.gson.reflect.*;
/**
* Store arbitrary data associated with an entity. Objects are small (~1KB) JSON-compatible objects which are stored
* directly on the entity profile. Objects are made available for use in other PlayFab contexts, such as PlayStream events
* and CloudScript functions. Files can efficiently store data of any size or format. Both objects and files support a
* flexible permissions system to control read and write access by other entities.
*/
public class PlayFabDataAPI {
private static Gson gson = new GsonBuilder().setDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").create();
/**
* Abort pending file uploads to an entity's profile.
* @param request AbortFileUploadsRequest
* @return Async Task will return AbortFileUploadsResponse
*/
@SuppressWarnings("unchecked")
public static FutureTask> AbortFileUploadsAsync(final AbortFileUploadsRequest request) {
return new FutureTask(new Callable>() {
public PlayFabResult call() throws Exception {
return privateAbortFileUploadsAsync(request);
}
});
}
/**
* Abort pending file uploads to an entity's profile.
* @param request AbortFileUploadsRequest
* @return AbortFileUploadsResponse
*/
@SuppressWarnings("unchecked")
public static PlayFabResult AbortFileUploads(final AbortFileUploadsRequest request) {
FutureTask> task = new FutureTask(new Callable>() {
public PlayFabResult call() throws Exception {
return privateAbortFileUploadsAsync(request);
}
});
try {
task.run();
return task.get();
} catch(Exception e) {
return null;
}
}
/** Abort pending file uploads to an entity's profile. */
@SuppressWarnings("unchecked")
private static PlayFabResult privateAbortFileUploadsAsync(final AbortFileUploadsRequest request) throws Exception {
if (PlayFabSettings.EntityToken == null) throw new Exception ("Must call GetEntityToken before you can use the Entity API");
FutureTask task = PlayFabHTTP.doPost(PlayFabSettings.GetURL("/File/AbortFileUploads"), request, "X-EntityToken", PlayFabSettings.EntityToken);
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());
AbortFileUploadsResponse result = resultData.data;
PlayFabResult pfResult = new PlayFabResult();
pfResult.Result = result;
return pfResult;
}
/**
* Delete files on an entity's profile.
* @param request DeleteFilesRequest
* @return Async Task will return DeleteFilesResponse
*/
@SuppressWarnings("unchecked")
public static FutureTask> DeleteFilesAsync(final DeleteFilesRequest request) {
return new FutureTask(new Callable>() {
public PlayFabResult call() throws Exception {
return privateDeleteFilesAsync(request);
}
});
}
/**
* Delete files on an entity's profile.
* @param request DeleteFilesRequest
* @return DeleteFilesResponse
*/
@SuppressWarnings("unchecked")
public static PlayFabResult DeleteFiles(final DeleteFilesRequest request) {
FutureTask> task = new FutureTask(new Callable>() {
public PlayFabResult call() throws Exception {
return privateDeleteFilesAsync(request);
}
});
try {
task.run();
return task.get();
} catch(Exception e) {
return null;
}
}
/** Delete files on an entity's profile. */
@SuppressWarnings("unchecked")
private static PlayFabResult privateDeleteFilesAsync(final DeleteFilesRequest request) throws Exception {
if (PlayFabSettings.EntityToken == null) throw new Exception ("Must call GetEntityToken before you can use the Entity API");
FutureTask task = PlayFabHTTP.doPost(PlayFabSettings.GetURL("/File/DeleteFiles"), request, "X-EntityToken", PlayFabSettings.EntityToken);
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());
DeleteFilesResponse result = resultData.data;
PlayFabResult pfResult = new PlayFabResult();
pfResult.Result = result;
return pfResult;
}
/**
* Finalize file uploads to an entity's profile.
* @param request FinalizeFileUploadsRequest
* @return Async Task will return FinalizeFileUploadsResponse
*/
@SuppressWarnings("unchecked")
public static FutureTask> FinalizeFileUploadsAsync(final FinalizeFileUploadsRequest request) {
return new FutureTask(new Callable>() {
public PlayFabResult call() throws Exception {
return privateFinalizeFileUploadsAsync(request);
}
});
}
/**
* Finalize file uploads to an entity's profile.
* @param request FinalizeFileUploadsRequest
* @return FinalizeFileUploadsResponse
*/
@SuppressWarnings("unchecked")
public static PlayFabResult FinalizeFileUploads(final FinalizeFileUploadsRequest request) {
FutureTask> task = new FutureTask(new Callable>() {
public PlayFabResult call() throws Exception {
return privateFinalizeFileUploadsAsync(request);
}
});
try {
task.run();
return task.get();
} catch(Exception e) {
return null;
}
}
/** Finalize file uploads to an entity's profile. */
@SuppressWarnings("unchecked")
private static PlayFabResult privateFinalizeFileUploadsAsync(final FinalizeFileUploadsRequest request) throws Exception {
if (PlayFabSettings.EntityToken == null) throw new Exception ("Must call GetEntityToken before you can use the Entity API");
FutureTask task = PlayFabHTTP.doPost(PlayFabSettings.GetURL("/File/FinalizeFileUploads"), request, "X-EntityToken", PlayFabSettings.EntityToken);
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());
FinalizeFileUploadsResponse result = resultData.data;
PlayFabResult pfResult = new PlayFabResult();
pfResult.Result = result;
return pfResult;
}
/**
* Retrieves file metadata from an entity's profile.
* @param request GetFilesRequest
* @return Async Task will return GetFilesResponse
*/
@SuppressWarnings("unchecked")
public static FutureTask> GetFilesAsync(final GetFilesRequest request) {
return new FutureTask(new Callable>() {
public PlayFabResult call() throws Exception {
return privateGetFilesAsync(request);
}
});
}
/**
* Retrieves file metadata from an entity's profile.
* @param request GetFilesRequest
* @return GetFilesResponse
*/
@SuppressWarnings("unchecked")
public static PlayFabResult GetFiles(final GetFilesRequest request) {
FutureTask> task = new FutureTask(new Callable>() {
public PlayFabResult call() throws Exception {
return privateGetFilesAsync(request);
}
});
try {
task.run();
return task.get();
} catch(Exception e) {
return null;
}
}
/** Retrieves file metadata from an entity's profile. */
@SuppressWarnings("unchecked")
private static PlayFabResult privateGetFilesAsync(final GetFilesRequest request) throws Exception {
if (PlayFabSettings.EntityToken == null) throw new Exception ("Must call GetEntityToken before you can use the Entity API");
FutureTask task = PlayFabHTTP.doPost(PlayFabSettings.GetURL("/File/GetFiles"), request, "X-EntityToken", PlayFabSettings.EntityToken);
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());
GetFilesResponse result = resultData.data;
PlayFabResult pfResult = new PlayFabResult();
pfResult.Result = result;
return pfResult;
}
/**
* Retrieves objects from an entity's profile.
* @param request GetObjectsRequest
* @return Async Task will return GetObjectsResponse
*/
@SuppressWarnings("unchecked")
public static FutureTask> GetObjectsAsync(final GetObjectsRequest request) {
return new FutureTask(new Callable>() {
public PlayFabResult call() throws Exception {
return privateGetObjectsAsync(request);
}
});
}
/**
* Retrieves objects from an entity's profile.
* @param request GetObjectsRequest
* @return GetObjectsResponse
*/
@SuppressWarnings("unchecked")
public static PlayFabResult GetObjects(final GetObjectsRequest request) {
FutureTask> task = new FutureTask(new Callable>() {
public PlayFabResult call() throws Exception {
return privateGetObjectsAsync(request);
}
});
try {
task.run();
return task.get();
} catch(Exception e) {
return null;
}
}
/** Retrieves objects from an entity's profile. */
@SuppressWarnings("unchecked")
private static PlayFabResult privateGetObjectsAsync(final GetObjectsRequest request) throws Exception {
if (PlayFabSettings.EntityToken == null) throw new Exception ("Must call GetEntityToken before you can use the Entity API");
FutureTask task = PlayFabHTTP.doPost(PlayFabSettings.GetURL("/Object/GetObjects"), request, "X-EntityToken", PlayFabSettings.EntityToken);
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());
GetObjectsResponse result = resultData.data;
PlayFabResult pfResult = new PlayFabResult();
pfResult.Result = result;
return pfResult;
}
/**
* Initiates file uploads to an entity's profile.
* @param request InitiateFileUploadsRequest
* @return Async Task will return InitiateFileUploadsResponse
*/
@SuppressWarnings("unchecked")
public static FutureTask> InitiateFileUploadsAsync(final InitiateFileUploadsRequest request) {
return new FutureTask(new Callable>() {
public PlayFabResult call() throws Exception {
return privateInitiateFileUploadsAsync(request);
}
});
}
/**
* Initiates file uploads to an entity's profile.
* @param request InitiateFileUploadsRequest
* @return InitiateFileUploadsResponse
*/
@SuppressWarnings("unchecked")
public static PlayFabResult InitiateFileUploads(final InitiateFileUploadsRequest request) {
FutureTask> task = new FutureTask(new Callable>() {
public PlayFabResult call() throws Exception {
return privateInitiateFileUploadsAsync(request);
}
});
try {
task.run();
return task.get();
} catch(Exception e) {
return null;
}
}
/** Initiates file uploads to an entity's profile. */
@SuppressWarnings("unchecked")
private static PlayFabResult privateInitiateFileUploadsAsync(final InitiateFileUploadsRequest request) throws Exception {
if (PlayFabSettings.EntityToken == null) throw new Exception ("Must call GetEntityToken before you can use the Entity API");
FutureTask task = PlayFabHTTP.doPost(PlayFabSettings.GetURL("/File/InitiateFileUploads"), request, "X-EntityToken", PlayFabSettings.EntityToken);
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());
InitiateFileUploadsResponse result = resultData.data;
PlayFabResult pfResult = new PlayFabResult();
pfResult.Result = result;
return pfResult;
}
/**
* Sets objects on an entity's profile.
* @param request SetObjectsRequest
* @return Async Task will return SetObjectsResponse
*/
@SuppressWarnings("unchecked")
public static FutureTask> SetObjectsAsync(final SetObjectsRequest request) {
return new FutureTask(new Callable>() {
public PlayFabResult call() throws Exception {
return privateSetObjectsAsync(request);
}
});
}
/**
* Sets objects on an entity's profile.
* @param request SetObjectsRequest
* @return SetObjectsResponse
*/
@SuppressWarnings("unchecked")
public static PlayFabResult SetObjects(final SetObjectsRequest request) {
FutureTask> task = new FutureTask(new Callable>() {
public PlayFabResult call() throws Exception {
return privateSetObjectsAsync(request);
}
});
try {
task.run();
return task.get();
} catch(Exception e) {
return null;
}
}
/** Sets objects on an entity's profile. */
@SuppressWarnings("unchecked")
private static PlayFabResult privateSetObjectsAsync(final SetObjectsRequest request) throws Exception {
if (PlayFabSettings.EntityToken == null) throw new Exception ("Must call GetEntityToken before you can use the Entity API");
FutureTask task = PlayFabHTTP.doPost(PlayFabSettings.GetURL("/Object/SetObjects"), request, "X-EntityToken", PlayFabSettings.EntityToken);
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());
SetObjectsResponse result = resultData.data;
PlayFabResult pfResult = new PlayFabResult();
pfResult.Result = result;
return pfResult;
}
}