diff --git a/PlayFabSDK/source/PlayFabAdminModels.cs b/PlayFabSDK/source/PlayFabAdminModels.cs
index 0450e346..9b89e58b 100644
--- a/PlayFabSDK/source/PlayFabAdminModels.cs
+++ b/PlayFabSDK/source/PlayFabAdminModels.cs
@@ -2807,7 +2807,11 @@ public enum GenericErrorCodes
LinkedStatisticColumnNotFound,
LinkedStatisticColumnRequired,
MultipleLinkedStatisticsNotAllowed,
+ DuplicateLinkedStatisticColumnNameFound,
+ AggregationTypeNotAllowedForMultiColumnStatistic,
MaxQueryableVerionsValueNotAllowedForTier,
+ StatisticDefinitionHasNullOrEmptyVersionConfiguration,
+ StatisticColumnLengthMismatch,
MatchmakingEntityInvalid,
MatchmakingPlayerAttributesInvalid,
MatchmakingQueueNotFound,
diff --git a/PlayFabSDK/source/PlayFabErrors.cs b/PlayFabSDK/source/PlayFabErrors.cs
index 8a942e14..780309ee 100644
--- a/PlayFabSDK/source/PlayFabErrors.cs
+++ b/PlayFabSDK/source/PlayFabErrors.cs
@@ -589,7 +589,11 @@ public enum PlayFabErrorCode
LinkedStatisticColumnNotFound = 1586,
LinkedStatisticColumnRequired = 1587,
MultipleLinkedStatisticsNotAllowed = 1588,
- MaxQueryableVerionsValueNotAllowedForTier = 1589,
+ DuplicateLinkedStatisticColumnNameFound = 1589,
+ AggregationTypeNotAllowedForMultiColumnStatistic = 1590,
+ MaxQueryableVerionsValueNotAllowedForTier = 1591,
+ StatisticDefinitionHasNullOrEmptyVersionConfiguration = 1592,
+ StatisticColumnLengthMismatch = 1593,
MatchmakingEntityInvalid = 2001,
MatchmakingPlayerAttributesInvalid = 2002,
MatchmakingQueueNotFound = 2016,
diff --git a/PlayFabSDK/source/PlayFabLeaderboardsAPI.cs b/PlayFabSDK/source/PlayFabLeaderboardsAPI.cs
new file mode 100644
index 00000000..e4cc5a02
--- /dev/null
+++ b/PlayFabSDK/source/PlayFabLeaderboardsAPI.cs
@@ -0,0 +1,633 @@
+#if !DISABLE_PLAYFABENTITY_API && !DISABLE_PLAYFAB_STATIC_API
+
+using PlayFab.LeaderboardsModels;
+using PlayFab.Internal;
+#pragma warning disable 0649
+using System;
+// This is required for the Obsolete Attribute flag
+// which is not always present in all API's
+#pragma warning restore 0649
+using System.Collections.Generic;
+using System.Threading.Tasks;
+
+namespace PlayFab
+{
+ ///
+ /// Manage entity statistics Manage entity statistics
+ ///
+ public static class PlayFabLeaderboardsAPI
+ {
+ ///
+ /// Verify entity login.
+ ///
+ public static bool IsEntityLoggedIn()
+ {
+ return PlayFabSettings.staticPlayer.IsEntityLoggedIn();
+ }
+
+ ///
+ /// Clear the Client SessionToken which allows this Client to call API calls requiring login.
+ /// A new/fresh login will be required after calling this.
+ ///
+ public static void ForgetAllCredentials()
+ {
+ PlayFabSettings.staticPlayer.ForgetAllCredentials();
+ }
+
+ ///
+ /// Creates a new leaderboard definition.
+ ///
+ public static async Task> CreateLeaderboardDefinitionAsync(CreateLeaderboardDefinitionRequest request, object customData = null, Dictionary extraHeaders = null)
+ {
+ await new PlayFabUtil.SynchronizationContextRemover();
+
+ var requestContext = request?.AuthenticationContext ?? PlayFabSettings.staticPlayer;
+ var requestSettings = PlayFabSettings.staticSettings;
+ if (requestContext.EntityToken == null) throw new PlayFabException(PlayFabExceptionCode.EntityTokenNotSet, "Must call Client Login or GetEntityToken before calling this method");
+
+
+ var httpResult = await PlayFabHttp.DoPost("/Leaderboard/CreateLeaderboardDefinition", request, "X-EntityToken", requestContext.EntityToken, extraHeaders);
+ if (httpResult is PlayFabError)
+ {
+ var error = (PlayFabError)httpResult;
+ PlayFabSettings.GlobalErrorHandler?.Invoke(error);
+ return new PlayFabResult { Error = error, CustomData = customData };
+ }
+
+ var resultRawJson = (string)httpResult;
+ var resultData = PluginManager.GetPlugin(PluginContract.PlayFab_Serializer).DeserializeObject>(resultRawJson);
+ var result = resultData.data;
+
+ return new PlayFabResult { Result = result, CustomData = customData };
+ }
+
+ ///
+ /// Create a new entity statistic definition.
+ ///
+ public static async Task> CreateStatisticDefinitionAsync(CreateStatisticDefinitionRequest request, object customData = null, Dictionary extraHeaders = null)
+ {
+ await new PlayFabUtil.SynchronizationContextRemover();
+
+ var requestContext = request?.AuthenticationContext ?? PlayFabSettings.staticPlayer;
+ var requestSettings = PlayFabSettings.staticSettings;
+ if (requestContext.EntityToken == null) throw new PlayFabException(PlayFabExceptionCode.EntityTokenNotSet, "Must call Client Login or GetEntityToken before calling this method");
+
+
+ var httpResult = await PlayFabHttp.DoPost("/Statistic/CreateStatisticDefinition", request, "X-EntityToken", requestContext.EntityToken, extraHeaders);
+ if (httpResult is PlayFabError)
+ {
+ var error = (PlayFabError)httpResult;
+ PlayFabSettings.GlobalErrorHandler?.Invoke(error);
+ return new PlayFabResult { Error = error, CustomData = customData };
+ }
+
+ var resultRawJson = (string)httpResult;
+ var resultData = PluginManager.GetPlugin(PluginContract.PlayFab_Serializer).DeserializeObject>(resultRawJson);
+ var result = resultData.data;
+
+ return new PlayFabResult { Result = result, CustomData = customData };
+ }
+
+ ///
+ /// Deletes a leaderboard definition.
+ ///
+ public static async Task> DeleteLeaderboardDefinitionAsync(DeleteLeaderboardDefinitionRequest request, object customData = null, Dictionary extraHeaders = null)
+ {
+ await new PlayFabUtil.SynchronizationContextRemover();
+
+ var requestContext = request?.AuthenticationContext ?? PlayFabSettings.staticPlayer;
+ var requestSettings = PlayFabSettings.staticSettings;
+ if (requestContext.EntityToken == null) throw new PlayFabException(PlayFabExceptionCode.EntityTokenNotSet, "Must call Client Login or GetEntityToken before calling this method");
+
+
+ var httpResult = await PlayFabHttp.DoPost("/Leaderboard/DeleteLeaderboardDefinition", request, "X-EntityToken", requestContext.EntityToken, extraHeaders);
+ if (httpResult is PlayFabError)
+ {
+ var error = (PlayFabError)httpResult;
+ PlayFabSettings.GlobalErrorHandler?.Invoke(error);
+ return new PlayFabResult { Error = error, CustomData = customData };
+ }
+
+ var resultRawJson = (string)httpResult;
+ var resultData = PluginManager.GetPlugin(PluginContract.PlayFab_Serializer).DeserializeObject>(resultRawJson);
+ var result = resultData.data;
+
+ return new PlayFabResult { Result = result, CustomData = customData };
+ }
+
+ ///
+ /// Deletes the specified entries from the given leaderboard.
+ ///
+ public static async Task> DeleteLeaderboardEntriesAsync(DeleteLeaderboardEntriesRequest request, object customData = null, Dictionary extraHeaders = null)
+ {
+ await new PlayFabUtil.SynchronizationContextRemover();
+
+ var requestContext = request?.AuthenticationContext ?? PlayFabSettings.staticPlayer;
+ var requestSettings = PlayFabSettings.staticSettings;
+ if (requestContext.EntityToken == null) throw new PlayFabException(PlayFabExceptionCode.EntityTokenNotSet, "Must call Client Login or GetEntityToken before calling this method");
+
+
+ var httpResult = await PlayFabHttp.DoPost("/Leaderboard/DeleteLeaderboardEntries", request, "X-EntityToken", requestContext.EntityToken, extraHeaders);
+ if (httpResult is PlayFabError)
+ {
+ var error = (PlayFabError)httpResult;
+ PlayFabSettings.GlobalErrorHandler?.Invoke(error);
+ return new PlayFabResult { Error = error, CustomData = customData };
+ }
+
+ var resultRawJson = (string)httpResult;
+ var resultData = PluginManager.GetPlugin(PluginContract.PlayFab_Serializer).DeserializeObject>(resultRawJson);
+ var result = resultData.data;
+
+ return new PlayFabResult { Result = result, CustomData = customData };
+ }
+
+ ///
+ /// Delete an entity statistic definition. Will delete all statistics on entity profiles and leaderboards.
+ ///
+ public static async Task> DeleteStatisticDefinitionAsync(DeleteStatisticDefinitionRequest request, object customData = null, Dictionary extraHeaders = null)
+ {
+ await new PlayFabUtil.SynchronizationContextRemover();
+
+ var requestContext = request?.AuthenticationContext ?? PlayFabSettings.staticPlayer;
+ var requestSettings = PlayFabSettings.staticSettings;
+ if (requestContext.EntityToken == null) throw new PlayFabException(PlayFabExceptionCode.EntityTokenNotSet, "Must call Client Login or GetEntityToken before calling this method");
+
+
+ var httpResult = await PlayFabHttp.DoPost("/Statistic/DeleteStatisticDefinition", request, "X-EntityToken", requestContext.EntityToken, extraHeaders);
+ if (httpResult is PlayFabError)
+ {
+ var error = (PlayFabError)httpResult;
+ PlayFabSettings.GlobalErrorHandler?.Invoke(error);
+ return new PlayFabResult { Error = error, CustomData = customData };
+ }
+
+ var resultRawJson = (string)httpResult;
+ var resultData = PluginManager.GetPlugin(PluginContract.PlayFab_Serializer).DeserializeObject>(resultRawJson);
+ var result = resultData.data;
+
+ return new PlayFabResult { Result = result, CustomData = customData };
+ }
+
+ ///
+ /// Delete statistics on an entity profile. This will remove all rankings from associated leaderboards.
+ ///
+ public static async Task> DeleteStatisticsAsync(DeleteStatisticsRequest request, object customData = null, Dictionary extraHeaders = null)
+ {
+ await new PlayFabUtil.SynchronizationContextRemover();
+
+ var requestContext = request?.AuthenticationContext ?? PlayFabSettings.staticPlayer;
+ var requestSettings = PlayFabSettings.staticSettings;
+ if (requestContext.EntityToken == null) throw new PlayFabException(PlayFabExceptionCode.EntityTokenNotSet, "Must call Client Login or GetEntityToken before calling this method");
+
+
+ var httpResult = await PlayFabHttp.DoPost("/Statistic/DeleteStatistics", request, "X-EntityToken", requestContext.EntityToken, extraHeaders);
+ if (httpResult is PlayFabError)
+ {
+ var error = (PlayFabError)httpResult;
+ PlayFabSettings.GlobalErrorHandler?.Invoke(error);
+ return new PlayFabResult { Error = error, CustomData = customData };
+ }
+
+ var resultRawJson = (string)httpResult;
+ var resultData = PluginManager.GetPlugin(PluginContract.PlayFab_Serializer).DeserializeObject>(resultRawJson);
+ var result = resultData.data;
+
+ return new PlayFabResult { Result = result, CustomData = customData };
+ }
+
+ ///
+ /// Get the friend leaderboard for the specified entity. A maximum of 100 friend entries are listed in the leaderboard.
+ ///
+ public static async Task> GetFriendLeaderboardForEntityAsync(GetFriendLeaderboardForEntityRequest request, object customData = null, Dictionary extraHeaders = null)
+ {
+ await new PlayFabUtil.SynchronizationContextRemover();
+
+ var requestContext = request?.AuthenticationContext ?? PlayFabSettings.staticPlayer;
+ var requestSettings = PlayFabSettings.staticSettings;
+ if (requestContext.EntityToken == null) throw new PlayFabException(PlayFabExceptionCode.EntityTokenNotSet, "Must call Client Login or GetEntityToken before calling this method");
+
+
+ var httpResult = await PlayFabHttp.DoPost("/Leaderboard/GetFriendLeaderboardForEntity", request, "X-EntityToken", requestContext.EntityToken, extraHeaders);
+ if (httpResult is PlayFabError)
+ {
+ var error = (PlayFabError)httpResult;
+ PlayFabSettings.GlobalErrorHandler?.Invoke(error);
+ return new PlayFabResult { Error = error, CustomData = customData };
+ }
+
+ var resultRawJson = (string)httpResult;
+ var resultData = PluginManager.GetPlugin(PluginContract.PlayFab_Serializer).DeserializeObject>(resultRawJson);
+ var result = resultData.data;
+
+ return new PlayFabResult { Result = result, CustomData = customData };
+ }
+
+ ///
+ /// Get the leaderboard for a specific entity type and statistic.
+ ///
+ public static async Task> GetLeaderboardAsync(GetEntityLeaderboardRequest request, object customData = null, Dictionary extraHeaders = null)
+ {
+ await new PlayFabUtil.SynchronizationContextRemover();
+
+ var requestContext = request?.AuthenticationContext ?? PlayFabSettings.staticPlayer;
+ var requestSettings = PlayFabSettings.staticSettings;
+ if (requestContext.EntityToken == null) throw new PlayFabException(PlayFabExceptionCode.EntityTokenNotSet, "Must call Client Login or GetEntityToken before calling this method");
+
+
+ var httpResult = await PlayFabHttp.DoPost("/Leaderboard/GetLeaderboard", request, "X-EntityToken", requestContext.EntityToken, extraHeaders);
+ if (httpResult is PlayFabError)
+ {
+ var error = (PlayFabError)httpResult;
+ PlayFabSettings.GlobalErrorHandler?.Invoke(error);
+ return new PlayFabResult { Error = error, CustomData = customData };
+ }
+
+ var resultRawJson = (string)httpResult;
+ var resultData = PluginManager.GetPlugin(PluginContract.PlayFab_Serializer).DeserializeObject>(resultRawJson);
+ var result = resultData.data;
+
+ return new PlayFabResult { Result = result, CustomData = customData };
+ }
+
+ ///
+ /// Get the leaderboard around a specific entity.
+ ///
+ public static async Task> GetLeaderboardAroundEntityAsync(GetLeaderboardAroundEntityRequest request, object customData = null, Dictionary extraHeaders = null)
+ {
+ await new PlayFabUtil.SynchronizationContextRemover();
+
+ var requestContext = request?.AuthenticationContext ?? PlayFabSettings.staticPlayer;
+ var requestSettings = PlayFabSettings.staticSettings;
+ if (requestContext.EntityToken == null) throw new PlayFabException(PlayFabExceptionCode.EntityTokenNotSet, "Must call Client Login or GetEntityToken before calling this method");
+
+
+ var httpResult = await PlayFabHttp.DoPost("/Leaderboard/GetLeaderboardAroundEntity", request, "X-EntityToken", requestContext.EntityToken, extraHeaders);
+ if (httpResult is PlayFabError)
+ {
+ var error = (PlayFabError)httpResult;
+ PlayFabSettings.GlobalErrorHandler?.Invoke(error);
+ return new PlayFabResult { Error = error, CustomData = customData };
+ }
+
+ var resultRawJson = (string)httpResult;
+ var resultData = PluginManager.GetPlugin(PluginContract.PlayFab_Serializer).DeserializeObject>(resultRawJson);
+ var result = resultData.data;
+
+ return new PlayFabResult { Result = result, CustomData = customData };
+ }
+
+ ///
+ /// Gets the specified leaderboard definition.
+ ///
+ public static async Task> GetLeaderboardDefinitionAsync(GetLeaderboardDefinitionRequest request, object customData = null, Dictionary extraHeaders = null)
+ {
+ await new PlayFabUtil.SynchronizationContextRemover();
+
+ var requestContext = request?.AuthenticationContext ?? PlayFabSettings.staticPlayer;
+ var requestSettings = PlayFabSettings.staticSettings;
+ if (requestContext.EntityToken == null) throw new PlayFabException(PlayFabExceptionCode.EntityTokenNotSet, "Must call Client Login or GetEntityToken before calling this method");
+
+
+ var httpResult = await PlayFabHttp.DoPost("/Leaderboard/GetLeaderboardDefinition", request, "X-EntityToken", requestContext.EntityToken, extraHeaders);
+ if (httpResult is PlayFabError)
+ {
+ var error = (PlayFabError)httpResult;
+ PlayFabSettings.GlobalErrorHandler?.Invoke(error);
+ return new PlayFabResult { Error = error, CustomData = customData };
+ }
+
+ var resultRawJson = (string)httpResult;
+ var resultData = PluginManager.GetPlugin(PluginContract.PlayFab_Serializer).DeserializeObject>(resultRawJson);
+ var result = resultData.data;
+
+ return new PlayFabResult { Result = result, CustomData = customData };
+ }
+
+ ///
+ /// Get the leaderboard limited to a set of entities.
+ ///
+ public static async Task> GetLeaderboardForEntitiesAsync(GetLeaderboardForEntitiesRequest request, object customData = null, Dictionary extraHeaders = null)
+ {
+ await new PlayFabUtil.SynchronizationContextRemover();
+
+ var requestContext = request?.AuthenticationContext ?? PlayFabSettings.staticPlayer;
+ var requestSettings = PlayFabSettings.staticSettings;
+ if (requestContext.EntityToken == null) throw new PlayFabException(PlayFabExceptionCode.EntityTokenNotSet, "Must call Client Login or GetEntityToken before calling this method");
+
+
+ var httpResult = await PlayFabHttp.DoPost("/Leaderboard/GetLeaderboardForEntities", request, "X-EntityToken", requestContext.EntityToken, extraHeaders);
+ if (httpResult is PlayFabError)
+ {
+ var error = (PlayFabError)httpResult;
+ PlayFabSettings.GlobalErrorHandler?.Invoke(error);
+ return new PlayFabResult { Error = error, CustomData = customData };
+ }
+
+ var resultRawJson = (string)httpResult;
+ var resultData = PluginManager.GetPlugin(PluginContract.PlayFab_Serializer).DeserializeObject>(resultRawJson);
+ var result = resultData.data;
+
+ return new PlayFabResult { Result = result, CustomData = customData };
+ }
+
+ ///
+ /// Get current statistic definition information
+ ///
+ public static async Task> GetStatisticDefinitionAsync(GetStatisticDefinitionRequest request, object customData = null, Dictionary extraHeaders = null)
+ {
+ await new PlayFabUtil.SynchronizationContextRemover();
+
+ var requestContext = request?.AuthenticationContext ?? PlayFabSettings.staticPlayer;
+ var requestSettings = PlayFabSettings.staticSettings;
+ if (requestContext.EntityToken == null) throw new PlayFabException(PlayFabExceptionCode.EntityTokenNotSet, "Must call Client Login or GetEntityToken before calling this method");
+
+
+ var httpResult = await PlayFabHttp.DoPost("/Statistic/GetStatisticDefinition", request, "X-EntityToken", requestContext.EntityToken, extraHeaders);
+ if (httpResult is PlayFabError)
+ {
+ var error = (PlayFabError)httpResult;
+ PlayFabSettings.GlobalErrorHandler?.Invoke(error);
+ return new PlayFabResult { Error = error, CustomData = customData };
+ }
+
+ var resultRawJson = (string)httpResult;
+ var resultData = PluginManager.GetPlugin(PluginContract.PlayFab_Serializer).DeserializeObject>(resultRawJson);
+ var result = resultData.data;
+
+ return new PlayFabResult { Result = result, CustomData = customData };
+ }
+
+ ///
+ /// Get all current statistic definitions information
+ ///
+ public static async Task> GetStatisticDefinitionsAsync(GetStatisticDefinitionsRequest request, object customData = null, Dictionary extraHeaders = null)
+ {
+ await new PlayFabUtil.SynchronizationContextRemover();
+
+ var requestContext = request?.AuthenticationContext ?? PlayFabSettings.staticPlayer;
+ var requestSettings = PlayFabSettings.staticSettings;
+ if (requestContext.EntityToken == null) throw new PlayFabException(PlayFabExceptionCode.EntityTokenNotSet, "Must call Client Login or GetEntityToken before calling this method");
+
+
+ var httpResult = await PlayFabHttp.DoPost("/Statistic/GetStatisticDefinitions", request, "X-EntityToken", requestContext.EntityToken, extraHeaders);
+ if (httpResult is PlayFabError)
+ {
+ var error = (PlayFabError)httpResult;
+ PlayFabSettings.GlobalErrorHandler?.Invoke(error);
+ return new PlayFabResult { Error = error, CustomData = customData };
+ }
+
+ var resultRawJson = (string)httpResult;
+ var resultData = PluginManager.GetPlugin(PluginContract.PlayFab_Serializer).DeserializeObject>(resultRawJson);
+ var result = resultData.data;
+
+ return new PlayFabResult { Result = result, CustomData = customData };
+ }
+
+ ///
+ /// Gets statistics for the specified entity.
+ ///
+ public static async Task> GetStatisticsAsync(GetStatisticsRequest request, object customData = null, Dictionary extraHeaders = null)
+ {
+ await new PlayFabUtil.SynchronizationContextRemover();
+
+ var requestContext = request?.AuthenticationContext ?? PlayFabSettings.staticPlayer;
+ var requestSettings = PlayFabSettings.staticSettings;
+ if (requestContext.EntityToken == null) throw new PlayFabException(PlayFabExceptionCode.EntityTokenNotSet, "Must call Client Login or GetEntityToken before calling this method");
+
+
+ var httpResult = await PlayFabHttp.DoPost("/Statistic/GetStatistics", request, "X-EntityToken", requestContext.EntityToken, extraHeaders);
+ if (httpResult is PlayFabError)
+ {
+ var error = (PlayFabError)httpResult;
+ PlayFabSettings.GlobalErrorHandler?.Invoke(error);
+ return new PlayFabResult { Error = error, CustomData = customData };
+ }
+
+ var resultRawJson = (string)httpResult;
+ var resultData = PluginManager.GetPlugin(PluginContract.PlayFab_Serializer).DeserializeObject>(resultRawJson);
+ var result = resultData.data;
+
+ return new PlayFabResult { Result = result, CustomData = customData };
+ }
+
+ ///
+ /// Gets statistics for the specified collection of entities.
+ ///
+ public static async Task> GetStatisticsForEntitiesAsync(GetStatisticsForEntitiesRequest request, object customData = null, Dictionary extraHeaders = null)
+ {
+ await new PlayFabUtil.SynchronizationContextRemover();
+
+ var requestContext = request?.AuthenticationContext ?? PlayFabSettings.staticPlayer;
+ var requestSettings = PlayFabSettings.staticSettings;
+ if (requestContext.EntityToken == null) throw new PlayFabException(PlayFabExceptionCode.EntityTokenNotSet, "Must call Client Login or GetEntityToken before calling this method");
+
+
+ var httpResult = await PlayFabHttp.DoPost("/Statistic/GetStatisticsForEntities", request, "X-EntityToken", requestContext.EntityToken, extraHeaders);
+ if (httpResult is PlayFabError)
+ {
+ var error = (PlayFabError)httpResult;
+ PlayFabSettings.GlobalErrorHandler?.Invoke(error);
+ return new PlayFabResult { Error = error, CustomData = customData };
+ }
+
+ var resultRawJson = (string)httpResult;
+ var resultData = PluginManager.GetPlugin(PluginContract.PlayFab_Serializer).DeserializeObject>(resultRawJson);
+ var result = resultData.data;
+
+ return new PlayFabResult { Result = result, CustomData = customData };
+ }
+
+ ///
+ /// Increment a leaderboard version.
+ ///
+ public static async Task> IncrementLeaderboardVersionAsync(IncrementLeaderboardVersionRequest request, object customData = null, Dictionary extraHeaders = null)
+ {
+ await new PlayFabUtil.SynchronizationContextRemover();
+
+ var requestContext = request?.AuthenticationContext ?? PlayFabSettings.staticPlayer;
+ var requestSettings = PlayFabSettings.staticSettings;
+ if (requestContext.EntityToken == null) throw new PlayFabException(PlayFabExceptionCode.EntityTokenNotSet, "Must call Client Login or GetEntityToken before calling this method");
+
+
+ var httpResult = await PlayFabHttp.DoPost("/Leaderboard/IncrementLeaderboardVersion", request, "X-EntityToken", requestContext.EntityToken, extraHeaders);
+ if (httpResult is PlayFabError)
+ {
+ var error = (PlayFabError)httpResult;
+ PlayFabSettings.GlobalErrorHandler?.Invoke(error);
+ return new PlayFabResult { Error = error, CustomData = customData };
+ }
+
+ var resultRawJson = (string)httpResult;
+ var resultData = PluginManager.GetPlugin(PluginContract.PlayFab_Serializer).DeserializeObject>(resultRawJson);
+ var result = resultData.data;
+
+ return new PlayFabResult { Result = result, CustomData = customData };
+ }
+
+ ///
+ /// Increment an entity statistic definition version.
+ ///
+ public static async Task> IncrementStatisticVersionAsync(IncrementStatisticVersionRequest request, object customData = null, Dictionary extraHeaders = null)
+ {
+ await new PlayFabUtil.SynchronizationContextRemover();
+
+ var requestContext = request?.AuthenticationContext ?? PlayFabSettings.staticPlayer;
+ var requestSettings = PlayFabSettings.staticSettings;
+ if (requestContext.EntityToken == null) throw new PlayFabException(PlayFabExceptionCode.EntityTokenNotSet, "Must call Client Login or GetEntityToken before calling this method");
+
+
+ var httpResult = await PlayFabHttp.DoPost("/Statistic/IncrementStatisticVersion", request, "X-EntityToken", requestContext.EntityToken, extraHeaders);
+ if (httpResult is PlayFabError)
+ {
+ var error = (PlayFabError)httpResult;
+ PlayFabSettings.GlobalErrorHandler?.Invoke(error);
+ return new PlayFabResult { Error = error, CustomData = customData };
+ }
+
+ var resultRawJson = (string)httpResult;
+ var resultData = PluginManager.GetPlugin(PluginContract.PlayFab_Serializer).DeserializeObject>(resultRawJson);
+ var result = resultData.data;
+
+ return new PlayFabResult { Result = result, CustomData = customData };
+ }
+
+ ///
+ /// Lists the leaderboard definitions defined for the Title.
+ ///
+ public static async Task> ListLeaderboardDefinitionsAsync(ListLeaderboardDefinitionsRequest request, object customData = null, Dictionary extraHeaders = null)
+ {
+ await new PlayFabUtil.SynchronizationContextRemover();
+
+ var requestContext = request?.AuthenticationContext ?? PlayFabSettings.staticPlayer;
+ var requestSettings = PlayFabSettings.staticSettings;
+ if (requestContext.EntityToken == null) throw new PlayFabException(PlayFabExceptionCode.EntityTokenNotSet, "Must call Client Login or GetEntityToken before calling this method");
+
+
+ var httpResult = await PlayFabHttp.DoPost("/Leaderboard/ListLeaderboardDefinitions", request, "X-EntityToken", requestContext.EntityToken, extraHeaders);
+ if (httpResult is PlayFabError)
+ {
+ var error = (PlayFabError)httpResult;
+ PlayFabSettings.GlobalErrorHandler?.Invoke(error);
+ return new PlayFabResult { Error = error, CustomData = customData };
+ }
+
+ var resultRawJson = (string)httpResult;
+ var resultData = PluginManager.GetPlugin(PluginContract.PlayFab_Serializer).DeserializeObject>(resultRawJson);
+ var result = resultData.data;
+
+ return new PlayFabResult { Result = result, CustomData = customData };
+ }
+
+ ///
+ /// Get all current statistic definitions information
+ ///
+ public static async Task> ListStatisticDefinitionsAsync(ListStatisticDefinitionsRequest request, object customData = null, Dictionary extraHeaders = null)
+ {
+ await new PlayFabUtil.SynchronizationContextRemover();
+
+ var requestContext = request?.AuthenticationContext ?? PlayFabSettings.staticPlayer;
+ var requestSettings = PlayFabSettings.staticSettings;
+ if (requestContext.EntityToken == null) throw new PlayFabException(PlayFabExceptionCode.EntityTokenNotSet, "Must call Client Login or GetEntityToken before calling this method");
+
+
+ var httpResult = await PlayFabHttp.DoPost("/Statistic/ListStatisticDefinitions", request, "X-EntityToken", requestContext.EntityToken, extraHeaders);
+ if (httpResult is PlayFabError)
+ {
+ var error = (PlayFabError)httpResult;
+ PlayFabSettings.GlobalErrorHandler?.Invoke(error);
+ return new PlayFabResult { Error = error, CustomData = customData };
+ }
+
+ var resultRawJson = (string)httpResult;
+ var resultData = PluginManager.GetPlugin(PluginContract.PlayFab_Serializer).DeserializeObject>(resultRawJson);
+ var result = resultData.data;
+
+ return new PlayFabResult { Result = result, CustomData = customData };
+ }
+
+ ///
+ /// Unlinks a leaderboard definition from it's linked statistic definition.
+ ///
+ public static async Task> UnlinkLeaderboardFromStatisticAsync(UnlinkLeaderboardFromStatisticRequest request, object customData = null, Dictionary extraHeaders = null)
+ {
+ await new PlayFabUtil.SynchronizationContextRemover();
+
+ var requestContext = request?.AuthenticationContext ?? PlayFabSettings.staticPlayer;
+ var requestSettings = PlayFabSettings.staticSettings;
+ if (requestContext.EntityToken == null) throw new PlayFabException(PlayFabExceptionCode.EntityTokenNotSet, "Must call Client Login or GetEntityToken before calling this method");
+
+
+ var httpResult = await PlayFabHttp.DoPost("/Leaderboard/UnlinkLeaderboardFromStatistic", request, "X-EntityToken", requestContext.EntityToken, extraHeaders);
+ if (httpResult is PlayFabError)
+ {
+ var error = (PlayFabError)httpResult;
+ PlayFabSettings.GlobalErrorHandler?.Invoke(error);
+ return new PlayFabResult { Error = error, CustomData = customData };
+ }
+
+ var resultRawJson = (string)httpResult;
+ var resultData = PluginManager.GetPlugin(PluginContract.PlayFab_Serializer).DeserializeObject>(resultRawJson);
+ var result = resultData.data;
+
+ return new PlayFabResult { Result = result, CustomData = customData };
+ }
+
+ ///
+ /// Adds or updates entries on the specified leaderboard.
+ ///
+ public static async Task> UpdateLeaderboardEntriesAsync(UpdateLeaderboardEntriesRequest request, object customData = null, Dictionary extraHeaders = null)
+ {
+ await new PlayFabUtil.SynchronizationContextRemover();
+
+ var requestContext = request?.AuthenticationContext ?? PlayFabSettings.staticPlayer;
+ var requestSettings = PlayFabSettings.staticSettings;
+ if (requestContext.EntityToken == null) throw new PlayFabException(PlayFabExceptionCode.EntityTokenNotSet, "Must call Client Login or GetEntityToken before calling this method");
+
+
+ var httpResult = await PlayFabHttp.DoPost("/Leaderboard/UpdateLeaderboardEntries", request, "X-EntityToken", requestContext.EntityToken, extraHeaders);
+ if (httpResult is PlayFabError)
+ {
+ var error = (PlayFabError)httpResult;
+ PlayFabSettings.GlobalErrorHandler?.Invoke(error);
+ return new PlayFabResult { Error = error, CustomData = customData };
+ }
+
+ var resultRawJson = (string)httpResult;
+ var resultData = PluginManager.GetPlugin(PluginContract.PlayFab_Serializer).DeserializeObject>(resultRawJson);
+ var result = resultData.data;
+
+ return new PlayFabResult { Result = result, CustomData = customData };
+ }
+
+ ///
+ /// Update statistics on an entity profile. Depending on the statistic definition, this may result in entity being ranked on
+ /// various leaderboards.
+ ///
+ public static async Task> UpdateStatisticsAsync(UpdateStatisticsRequest request, object customData = null, Dictionary extraHeaders = null)
+ {
+ await new PlayFabUtil.SynchronizationContextRemover();
+
+ var requestContext = request?.AuthenticationContext ?? PlayFabSettings.staticPlayer;
+ var requestSettings = PlayFabSettings.staticSettings;
+ if (requestContext.EntityToken == null) throw new PlayFabException(PlayFabExceptionCode.EntityTokenNotSet, "Must call Client Login or GetEntityToken before calling this method");
+
+
+ var httpResult = await PlayFabHttp.DoPost("/Statistic/UpdateStatistics", request, "X-EntityToken", requestContext.EntityToken, extraHeaders);
+ if (httpResult is PlayFabError)
+ {
+ var error = (PlayFabError)httpResult;
+ PlayFabSettings.GlobalErrorHandler?.Invoke(error);
+ return new PlayFabResult { Error = error, CustomData = customData };
+ }
+
+ var resultRawJson = (string)httpResult;
+ var resultData = PluginManager.GetPlugin(PluginContract.PlayFab_Serializer).DeserializeObject>(resultRawJson);
+ var result = resultData.data;
+
+ return new PlayFabResult { Result = result, CustomData = customData };
+ }
+}
+}
+#endif
diff --git a/PlayFabSDK/source/PlayFabLeaderboardsInstanceAPI.cs b/PlayFabSDK/source/PlayFabLeaderboardsInstanceAPI.cs
new file mode 100644
index 00000000..653896cb
--- /dev/null
+++ b/PlayFabSDK/source/PlayFabLeaderboardsInstanceAPI.cs
@@ -0,0 +1,630 @@
+#if !DISABLE_PLAYFABENTITY_API
+
+using PlayFab.LeaderboardsModels;
+using PlayFab.Internal;
+#pragma warning disable 0649
+using System;
+// This is required for the Obsolete Attribute flag
+// which is not always present in all API's
+#pragma warning restore 0649
+using System.Collections.Generic;
+using System.Threading.Tasks;
+
+namespace PlayFab
+{
+ ///
+ /// Manage entity statistics Manage entity statistics
+ ///
+ public class PlayFabLeaderboardsInstanceAPI
+ {
+ public readonly PlayFabApiSettings apiSettings = null;
+ public readonly PlayFabAuthenticationContext authenticationContext = null;
+
+ public PlayFabLeaderboardsInstanceAPI(PlayFabAuthenticationContext context)
+ {
+ if (context == null)
+ throw new PlayFabException(PlayFabExceptionCode.AuthContextRequired, "Context cannot be null, create a PlayFabAuthenticationContext for each player in advance, or get .authenticationContext");
+ authenticationContext = context;
+ }
+
+ public PlayFabLeaderboardsInstanceAPI(PlayFabApiSettings settings, PlayFabAuthenticationContext context)
+ {
+ if (context == null)
+ throw new PlayFabException(PlayFabExceptionCode.AuthContextRequired, "Context cannot be null, create a PlayFabAuthenticationContext for each player in advance, or get .authenticationContext");
+ apiSettings = settings;
+ authenticationContext = context;
+ }
+
+ ///
+ /// Verify entity login.
+ ///
+ public bool IsEntityLoggedIn()
+ {
+ return authenticationContext == null ? false : authenticationContext.IsEntityLoggedIn();
+ }
+
+ ///
+ /// Clear the Client SessionToken which allows this Client to call API calls requiring login.
+ /// A new/fresh login will be required after calling this.
+ ///
+ public void ForgetAllCredentials()
+ {
+ authenticationContext?.ForgetAllCredentials();
+ }
+
+ ///
+ /// Creates a new leaderboard definition.
+ ///
+ public async Task> CreateLeaderboardDefinitionAsync(CreateLeaderboardDefinitionRequest request, object customData = null, Dictionary extraHeaders = null)
+ {
+ await new PlayFabUtil.SynchronizationContextRemover();
+
+ var requestContext = request?.AuthenticationContext ?? authenticationContext;
+ var requestSettings = apiSettings ?? PlayFabSettings.staticSettings;
+ if (requestContext.EntityToken == null) throw new PlayFabException(PlayFabExceptionCode.EntityTokenNotSet, "Must call Client Login or GetEntityToken before calling this method");
+
+ var httpResult = await PlayFabHttp.DoPost("/Leaderboard/CreateLeaderboardDefinition", request, "X-EntityToken", requestContext.EntityToken, extraHeaders, requestSettings);
+ if (httpResult is PlayFabError)
+ {
+ var error = (PlayFabError)httpResult;
+ PlayFabSettings.GlobalErrorHandler?.Invoke(error);
+ return new PlayFabResult { Error = error, CustomData = customData };
+ }
+
+ var resultRawJson = (string)httpResult;
+ var resultData = PluginManager.GetPlugin(PluginContract.PlayFab_Serializer).DeserializeObject>(resultRawJson);
+ var result = resultData.data;
+
+ return new PlayFabResult { Result = result, CustomData = customData };
+ }
+
+ ///
+ /// Create a new entity statistic definition.
+ ///
+ public async Task> CreateStatisticDefinitionAsync(CreateStatisticDefinitionRequest request, object customData = null, Dictionary extraHeaders = null)
+ {
+ await new PlayFabUtil.SynchronizationContextRemover();
+
+ var requestContext = request?.AuthenticationContext ?? authenticationContext;
+ var requestSettings = apiSettings ?? PlayFabSettings.staticSettings;
+ if (requestContext.EntityToken == null) throw new PlayFabException(PlayFabExceptionCode.EntityTokenNotSet, "Must call Client Login or GetEntityToken before calling this method");
+
+ var httpResult = await PlayFabHttp.DoPost("/Statistic/CreateStatisticDefinition", request, "X-EntityToken", requestContext.EntityToken, extraHeaders, requestSettings);
+ if (httpResult is PlayFabError)
+ {
+ var error = (PlayFabError)httpResult;
+ PlayFabSettings.GlobalErrorHandler?.Invoke(error);
+ return new PlayFabResult { Error = error, CustomData = customData };
+ }
+
+ var resultRawJson = (string)httpResult;
+ var resultData = PluginManager.GetPlugin(PluginContract.PlayFab_Serializer).DeserializeObject>(resultRawJson);
+ var result = resultData.data;
+
+ return new PlayFabResult { Result = result, CustomData = customData };
+ }
+
+ ///
+ /// Deletes a leaderboard definition.
+ ///
+ public async Task> DeleteLeaderboardDefinitionAsync(DeleteLeaderboardDefinitionRequest request, object customData = null, Dictionary extraHeaders = null)
+ {
+ await new PlayFabUtil.SynchronizationContextRemover();
+
+ var requestContext = request?.AuthenticationContext ?? authenticationContext;
+ var requestSettings = apiSettings ?? PlayFabSettings.staticSettings;
+ if (requestContext.EntityToken == null) throw new PlayFabException(PlayFabExceptionCode.EntityTokenNotSet, "Must call Client Login or GetEntityToken before calling this method");
+
+ var httpResult = await PlayFabHttp.DoPost("/Leaderboard/DeleteLeaderboardDefinition", request, "X-EntityToken", requestContext.EntityToken, extraHeaders, requestSettings);
+ if (httpResult is PlayFabError)
+ {
+ var error = (PlayFabError)httpResult;
+ PlayFabSettings.GlobalErrorHandler?.Invoke(error);
+ return new PlayFabResult { Error = error, CustomData = customData };
+ }
+
+ var resultRawJson = (string)httpResult;
+ var resultData = PluginManager.GetPlugin(PluginContract.PlayFab_Serializer).DeserializeObject>(resultRawJson);
+ var result = resultData.data;
+
+ return new PlayFabResult { Result = result, CustomData = customData };
+ }
+
+ ///
+ /// Deletes the specified entries from the given leaderboard.
+ ///
+ public async Task> DeleteLeaderboardEntriesAsync(DeleteLeaderboardEntriesRequest request, object customData = null, Dictionary extraHeaders = null)
+ {
+ await new PlayFabUtil.SynchronizationContextRemover();
+
+ var requestContext = request?.AuthenticationContext ?? authenticationContext;
+ var requestSettings = apiSettings ?? PlayFabSettings.staticSettings;
+ if (requestContext.EntityToken == null) throw new PlayFabException(PlayFabExceptionCode.EntityTokenNotSet, "Must call Client Login or GetEntityToken before calling this method");
+
+ var httpResult = await PlayFabHttp.DoPost("/Leaderboard/DeleteLeaderboardEntries", request, "X-EntityToken", requestContext.EntityToken, extraHeaders, requestSettings);
+ if (httpResult is PlayFabError)
+ {
+ var error = (PlayFabError)httpResult;
+ PlayFabSettings.GlobalErrorHandler?.Invoke(error);
+ return new PlayFabResult { Error = error, CustomData = customData };
+ }
+
+ var resultRawJson = (string)httpResult;
+ var resultData = PluginManager.GetPlugin(PluginContract.PlayFab_Serializer).DeserializeObject>(resultRawJson);
+ var result = resultData.data;
+
+ return new PlayFabResult { Result = result, CustomData = customData };
+ }
+
+ ///
+ /// Delete an entity statistic definition. Will delete all statistics on entity profiles and leaderboards.
+ ///
+ public async Task> DeleteStatisticDefinitionAsync(DeleteStatisticDefinitionRequest request, object customData = null, Dictionary extraHeaders = null)
+ {
+ await new PlayFabUtil.SynchronizationContextRemover();
+
+ var requestContext = request?.AuthenticationContext ?? authenticationContext;
+ var requestSettings = apiSettings ?? PlayFabSettings.staticSettings;
+ if (requestContext.EntityToken == null) throw new PlayFabException(PlayFabExceptionCode.EntityTokenNotSet, "Must call Client Login or GetEntityToken before calling this method");
+
+ var httpResult = await PlayFabHttp.DoPost("/Statistic/DeleteStatisticDefinition", request, "X-EntityToken", requestContext.EntityToken, extraHeaders, requestSettings);
+ if (httpResult is PlayFabError)
+ {
+ var error = (PlayFabError)httpResult;
+ PlayFabSettings.GlobalErrorHandler?.Invoke(error);
+ return new PlayFabResult { Error = error, CustomData = customData };
+ }
+
+ var resultRawJson = (string)httpResult;
+ var resultData = PluginManager.GetPlugin(PluginContract.PlayFab_Serializer).DeserializeObject>(resultRawJson);
+ var result = resultData.data;
+
+ return new PlayFabResult { Result = result, CustomData = customData };
+ }
+
+ ///
+ /// Delete statistics on an entity profile. This will remove all rankings from associated leaderboards.
+ ///
+ public async Task> DeleteStatisticsAsync(DeleteStatisticsRequest request, object customData = null, Dictionary extraHeaders = null)
+ {
+ await new PlayFabUtil.SynchronizationContextRemover();
+
+ var requestContext = request?.AuthenticationContext ?? authenticationContext;
+ var requestSettings = apiSettings ?? PlayFabSettings.staticSettings;
+ if (requestContext.EntityToken == null) throw new PlayFabException(PlayFabExceptionCode.EntityTokenNotSet, "Must call Client Login or GetEntityToken before calling this method");
+
+ var httpResult = await PlayFabHttp.DoPost("/Statistic/DeleteStatistics", request, "X-EntityToken", requestContext.EntityToken, extraHeaders, requestSettings);
+ if (httpResult is PlayFabError)
+ {
+ var error = (PlayFabError)httpResult;
+ PlayFabSettings.GlobalErrorHandler?.Invoke(error);
+ return new PlayFabResult { Error = error, CustomData = customData };
+ }
+
+ var resultRawJson = (string)httpResult;
+ var resultData = PluginManager.GetPlugin(PluginContract.PlayFab_Serializer).DeserializeObject>(resultRawJson);
+ var result = resultData.data;
+
+ return new PlayFabResult { Result = result, CustomData = customData };
+ }
+
+ ///
+ /// Get the friend leaderboard for the specified entity. A maximum of 100 friend entries are listed in the leaderboard.
+ ///
+ public async Task> GetFriendLeaderboardForEntityAsync(GetFriendLeaderboardForEntityRequest request, object customData = null, Dictionary extraHeaders = null)
+ {
+ await new PlayFabUtil.SynchronizationContextRemover();
+
+ var requestContext = request?.AuthenticationContext ?? authenticationContext;
+ var requestSettings = apiSettings ?? PlayFabSettings.staticSettings;
+ if (requestContext.EntityToken == null) throw new PlayFabException(PlayFabExceptionCode.EntityTokenNotSet, "Must call Client Login or GetEntityToken before calling this method");
+
+ var httpResult = await PlayFabHttp.DoPost("/Leaderboard/GetFriendLeaderboardForEntity", request, "X-EntityToken", requestContext.EntityToken, extraHeaders, requestSettings);
+ if (httpResult is PlayFabError)
+ {
+ var error = (PlayFabError)httpResult;
+ PlayFabSettings.GlobalErrorHandler?.Invoke(error);
+ return new PlayFabResult { Error = error, CustomData = customData };
+ }
+
+ var resultRawJson = (string)httpResult;
+ var resultData = PluginManager.GetPlugin(PluginContract.PlayFab_Serializer).DeserializeObject>(resultRawJson);
+ var result = resultData.data;
+
+ return new PlayFabResult { Result = result, CustomData = customData };
+ }
+
+ ///
+ /// Get the leaderboard for a specific entity type and statistic.
+ ///
+ public async Task> GetLeaderboardAsync(GetEntityLeaderboardRequest request, object customData = null, Dictionary extraHeaders = null)
+ {
+ await new PlayFabUtil.SynchronizationContextRemover();
+
+ var requestContext = request?.AuthenticationContext ?? authenticationContext;
+ var requestSettings = apiSettings ?? PlayFabSettings.staticSettings;
+ if (requestContext.EntityToken == null) throw new PlayFabException(PlayFabExceptionCode.EntityTokenNotSet, "Must call Client Login or GetEntityToken before calling this method");
+
+ var httpResult = await PlayFabHttp.DoPost("/Leaderboard/GetLeaderboard", request, "X-EntityToken", requestContext.EntityToken, extraHeaders, requestSettings);
+ if (httpResult is PlayFabError)
+ {
+ var error = (PlayFabError)httpResult;
+ PlayFabSettings.GlobalErrorHandler?.Invoke(error);
+ return new PlayFabResult { Error = error, CustomData = customData };
+ }
+
+ var resultRawJson = (string)httpResult;
+ var resultData = PluginManager.GetPlugin(PluginContract.PlayFab_Serializer).DeserializeObject>(resultRawJson);
+ var result = resultData.data;
+
+ return new PlayFabResult { Result = result, CustomData = customData };
+ }
+
+ ///
+ /// Get the leaderboard around a specific entity.
+ ///
+ public async Task> GetLeaderboardAroundEntityAsync(GetLeaderboardAroundEntityRequest request, object customData = null, Dictionary extraHeaders = null)
+ {
+ await new PlayFabUtil.SynchronizationContextRemover();
+
+ var requestContext = request?.AuthenticationContext ?? authenticationContext;
+ var requestSettings = apiSettings ?? PlayFabSettings.staticSettings;
+ if (requestContext.EntityToken == null) throw new PlayFabException(PlayFabExceptionCode.EntityTokenNotSet, "Must call Client Login or GetEntityToken before calling this method");
+
+ var httpResult = await PlayFabHttp.DoPost("/Leaderboard/GetLeaderboardAroundEntity", request, "X-EntityToken", requestContext.EntityToken, extraHeaders, requestSettings);
+ if (httpResult is PlayFabError)
+ {
+ var error = (PlayFabError)httpResult;
+ PlayFabSettings.GlobalErrorHandler?.Invoke(error);
+ return new PlayFabResult { Error = error, CustomData = customData };
+ }
+
+ var resultRawJson = (string)httpResult;
+ var resultData = PluginManager.GetPlugin(PluginContract.PlayFab_Serializer).DeserializeObject>(resultRawJson);
+ var result = resultData.data;
+
+ return new PlayFabResult { Result = result, CustomData = customData };
+ }
+
+ ///
+ /// Gets the specified leaderboard definition.
+ ///
+ public async Task> GetLeaderboardDefinitionAsync(GetLeaderboardDefinitionRequest request, object customData = null, Dictionary extraHeaders = null)
+ {
+ await new PlayFabUtil.SynchronizationContextRemover();
+
+ var requestContext = request?.AuthenticationContext ?? authenticationContext;
+ var requestSettings = apiSettings ?? PlayFabSettings.staticSettings;
+ if (requestContext.EntityToken == null) throw new PlayFabException(PlayFabExceptionCode.EntityTokenNotSet, "Must call Client Login or GetEntityToken before calling this method");
+
+ var httpResult = await PlayFabHttp.DoPost("/Leaderboard/GetLeaderboardDefinition", request, "X-EntityToken", requestContext.EntityToken, extraHeaders, requestSettings);
+ if (httpResult is PlayFabError)
+ {
+ var error = (PlayFabError)httpResult;
+ PlayFabSettings.GlobalErrorHandler?.Invoke(error);
+ return new PlayFabResult { Error = error, CustomData = customData };
+ }
+
+ var resultRawJson = (string)httpResult;
+ var resultData = PluginManager.GetPlugin(PluginContract.PlayFab_Serializer).DeserializeObject>(resultRawJson);
+ var result = resultData.data;
+
+ return new PlayFabResult { Result = result, CustomData = customData };
+ }
+
+ ///
+ /// Get the leaderboard limited to a set of entities.
+ ///
+ public async Task> GetLeaderboardForEntitiesAsync(GetLeaderboardForEntitiesRequest request, object customData = null, Dictionary extraHeaders = null)
+ {
+ await new PlayFabUtil.SynchronizationContextRemover();
+
+ var requestContext = request?.AuthenticationContext ?? authenticationContext;
+ var requestSettings = apiSettings ?? PlayFabSettings.staticSettings;
+ if (requestContext.EntityToken == null) throw new PlayFabException(PlayFabExceptionCode.EntityTokenNotSet, "Must call Client Login or GetEntityToken before calling this method");
+
+ var httpResult = await PlayFabHttp.DoPost("/Leaderboard/GetLeaderboardForEntities", request, "X-EntityToken", requestContext.EntityToken, extraHeaders, requestSettings);
+ if (httpResult is PlayFabError)
+ {
+ var error = (PlayFabError)httpResult;
+ PlayFabSettings.GlobalErrorHandler?.Invoke(error);
+ return new PlayFabResult { Error = error, CustomData = customData };
+ }
+
+ var resultRawJson = (string)httpResult;
+ var resultData = PluginManager.GetPlugin(PluginContract.PlayFab_Serializer).DeserializeObject>(resultRawJson);
+ var result = resultData.data;
+
+ return new PlayFabResult { Result = result, CustomData = customData };
+ }
+
+ ///
+ /// Get current statistic definition information
+ ///
+ public async Task> GetStatisticDefinitionAsync(GetStatisticDefinitionRequest request, object customData = null, Dictionary extraHeaders = null)
+ {
+ await new PlayFabUtil.SynchronizationContextRemover();
+
+ var requestContext = request?.AuthenticationContext ?? authenticationContext;
+ var requestSettings = apiSettings ?? PlayFabSettings.staticSettings;
+ if (requestContext.EntityToken == null) throw new PlayFabException(PlayFabExceptionCode.EntityTokenNotSet, "Must call Client Login or GetEntityToken before calling this method");
+
+ var httpResult = await PlayFabHttp.DoPost("/Statistic/GetStatisticDefinition", request, "X-EntityToken", requestContext.EntityToken, extraHeaders, requestSettings);
+ if (httpResult is PlayFabError)
+ {
+ var error = (PlayFabError)httpResult;
+ PlayFabSettings.GlobalErrorHandler?.Invoke(error);
+ return new PlayFabResult { Error = error, CustomData = customData };
+ }
+
+ var resultRawJson = (string)httpResult;
+ var resultData = PluginManager.GetPlugin(PluginContract.PlayFab_Serializer).DeserializeObject>(resultRawJson);
+ var result = resultData.data;
+
+ return new PlayFabResult { Result = result, CustomData = customData };
+ }
+
+ ///
+ /// Get all current statistic definitions information
+ ///
+ public async Task> GetStatisticDefinitionsAsync(GetStatisticDefinitionsRequest request, object customData = null, Dictionary extraHeaders = null)
+ {
+ await new PlayFabUtil.SynchronizationContextRemover();
+
+ var requestContext = request?.AuthenticationContext ?? authenticationContext;
+ var requestSettings = apiSettings ?? PlayFabSettings.staticSettings;
+ if (requestContext.EntityToken == null) throw new PlayFabException(PlayFabExceptionCode.EntityTokenNotSet, "Must call Client Login or GetEntityToken before calling this method");
+
+ var httpResult = await PlayFabHttp.DoPost("/Statistic/GetStatisticDefinitions", request, "X-EntityToken", requestContext.EntityToken, extraHeaders, requestSettings);
+ if (httpResult is PlayFabError)
+ {
+ var error = (PlayFabError)httpResult;
+ PlayFabSettings.GlobalErrorHandler?.Invoke(error);
+ return new PlayFabResult { Error = error, CustomData = customData };
+ }
+
+ var resultRawJson = (string)httpResult;
+ var resultData = PluginManager.GetPlugin(PluginContract.PlayFab_Serializer).DeserializeObject>(resultRawJson);
+ var result = resultData.data;
+
+ return new PlayFabResult { Result = result, CustomData = customData };
+ }
+
+ ///
+ /// Gets statistics for the specified entity.
+ ///
+ public async Task> GetStatisticsAsync(GetStatisticsRequest request, object customData = null, Dictionary extraHeaders = null)
+ {
+ await new PlayFabUtil.SynchronizationContextRemover();
+
+ var requestContext = request?.AuthenticationContext ?? authenticationContext;
+ var requestSettings = apiSettings ?? PlayFabSettings.staticSettings;
+ if (requestContext.EntityToken == null) throw new PlayFabException(PlayFabExceptionCode.EntityTokenNotSet, "Must call Client Login or GetEntityToken before calling this method");
+
+ var httpResult = await PlayFabHttp.DoPost("/Statistic/GetStatistics", request, "X-EntityToken", requestContext.EntityToken, extraHeaders, requestSettings);
+ if (httpResult is PlayFabError)
+ {
+ var error = (PlayFabError)httpResult;
+ PlayFabSettings.GlobalErrorHandler?.Invoke(error);
+ return new PlayFabResult { Error = error, CustomData = customData };
+ }
+
+ var resultRawJson = (string)httpResult;
+ var resultData = PluginManager.GetPlugin(PluginContract.PlayFab_Serializer).DeserializeObject>(resultRawJson);
+ var result = resultData.data;
+
+ return new PlayFabResult { Result = result, CustomData = customData };
+ }
+
+ ///
+ /// Gets statistics for the specified collection of entities.
+ ///
+ public async Task> GetStatisticsForEntitiesAsync(GetStatisticsForEntitiesRequest request, object customData = null, Dictionary extraHeaders = null)
+ {
+ await new PlayFabUtil.SynchronizationContextRemover();
+
+ var requestContext = request?.AuthenticationContext ?? authenticationContext;
+ var requestSettings = apiSettings ?? PlayFabSettings.staticSettings;
+ if (requestContext.EntityToken == null) throw new PlayFabException(PlayFabExceptionCode.EntityTokenNotSet, "Must call Client Login or GetEntityToken before calling this method");
+
+ var httpResult = await PlayFabHttp.DoPost("/Statistic/GetStatisticsForEntities", request, "X-EntityToken", requestContext.EntityToken, extraHeaders, requestSettings);
+ if (httpResult is PlayFabError)
+ {
+ var error = (PlayFabError)httpResult;
+ PlayFabSettings.GlobalErrorHandler?.Invoke(error);
+ return new PlayFabResult { Error = error, CustomData = customData };
+ }
+
+ var resultRawJson = (string)httpResult;
+ var resultData = PluginManager.GetPlugin(PluginContract.PlayFab_Serializer).DeserializeObject>(resultRawJson);
+ var result = resultData.data;
+
+ return new PlayFabResult { Result = result, CustomData = customData };
+ }
+
+ ///
+ /// Increment a leaderboard version.
+ ///
+ public async Task> IncrementLeaderboardVersionAsync(IncrementLeaderboardVersionRequest request, object customData = null, Dictionary extraHeaders = null)
+ {
+ await new PlayFabUtil.SynchronizationContextRemover();
+
+ var requestContext = request?.AuthenticationContext ?? authenticationContext;
+ var requestSettings = apiSettings ?? PlayFabSettings.staticSettings;
+ if (requestContext.EntityToken == null) throw new PlayFabException(PlayFabExceptionCode.EntityTokenNotSet, "Must call Client Login or GetEntityToken before calling this method");
+
+ var httpResult = await PlayFabHttp.DoPost("/Leaderboard/IncrementLeaderboardVersion", request, "X-EntityToken", requestContext.EntityToken, extraHeaders, requestSettings);
+ if (httpResult is PlayFabError)
+ {
+ var error = (PlayFabError)httpResult;
+ PlayFabSettings.GlobalErrorHandler?.Invoke(error);
+ return new PlayFabResult { Error = error, CustomData = customData };
+ }
+
+ var resultRawJson = (string)httpResult;
+ var resultData = PluginManager.GetPlugin(PluginContract.PlayFab_Serializer).DeserializeObject>(resultRawJson);
+ var result = resultData.data;
+
+ return new PlayFabResult { Result = result, CustomData = customData };
+ }
+
+ ///
+ /// Increment an entity statistic definition version.
+ ///
+ public async Task> IncrementStatisticVersionAsync(IncrementStatisticVersionRequest request, object customData = null, Dictionary extraHeaders = null)
+ {
+ await new PlayFabUtil.SynchronizationContextRemover();
+
+ var requestContext = request?.AuthenticationContext ?? authenticationContext;
+ var requestSettings = apiSettings ?? PlayFabSettings.staticSettings;
+ if (requestContext.EntityToken == null) throw new PlayFabException(PlayFabExceptionCode.EntityTokenNotSet, "Must call Client Login or GetEntityToken before calling this method");
+
+ var httpResult = await PlayFabHttp.DoPost("/Statistic/IncrementStatisticVersion", request, "X-EntityToken", requestContext.EntityToken, extraHeaders, requestSettings);
+ if (httpResult is PlayFabError)
+ {
+ var error = (PlayFabError)httpResult;
+ PlayFabSettings.GlobalErrorHandler?.Invoke(error);
+ return new PlayFabResult { Error = error, CustomData = customData };
+ }
+
+ var resultRawJson = (string)httpResult;
+ var resultData = PluginManager.GetPlugin(PluginContract.PlayFab_Serializer).DeserializeObject>(resultRawJson);
+ var result = resultData.data;
+
+ return new PlayFabResult { Result = result, CustomData = customData };
+ }
+
+ ///
+ /// Lists the leaderboard definitions defined for the Title.
+ ///
+ public async Task> ListLeaderboardDefinitionsAsync(ListLeaderboardDefinitionsRequest request, object customData = null, Dictionary extraHeaders = null)
+ {
+ await new PlayFabUtil.SynchronizationContextRemover();
+
+ var requestContext = request?.AuthenticationContext ?? authenticationContext;
+ var requestSettings = apiSettings ?? PlayFabSettings.staticSettings;
+ if (requestContext.EntityToken == null) throw new PlayFabException(PlayFabExceptionCode.EntityTokenNotSet, "Must call Client Login or GetEntityToken before calling this method");
+
+ var httpResult = await PlayFabHttp.DoPost("/Leaderboard/ListLeaderboardDefinitions", request, "X-EntityToken", requestContext.EntityToken, extraHeaders, requestSettings);
+ if (httpResult is PlayFabError)
+ {
+ var error = (PlayFabError)httpResult;
+ PlayFabSettings.GlobalErrorHandler?.Invoke(error);
+ return new PlayFabResult { Error = error, CustomData = customData };
+ }
+
+ var resultRawJson = (string)httpResult;
+ var resultData = PluginManager.GetPlugin(PluginContract.PlayFab_Serializer).DeserializeObject>(resultRawJson);
+ var result = resultData.data;
+
+ return new PlayFabResult { Result = result, CustomData = customData };
+ }
+
+ ///
+ /// Get all current statistic definitions information
+ ///
+ public async Task> ListStatisticDefinitionsAsync(ListStatisticDefinitionsRequest request, object customData = null, Dictionary extraHeaders = null)
+ {
+ await new PlayFabUtil.SynchronizationContextRemover();
+
+ var requestContext = request?.AuthenticationContext ?? authenticationContext;
+ var requestSettings = apiSettings ?? PlayFabSettings.staticSettings;
+ if (requestContext.EntityToken == null) throw new PlayFabException(PlayFabExceptionCode.EntityTokenNotSet, "Must call Client Login or GetEntityToken before calling this method");
+
+ var httpResult = await PlayFabHttp.DoPost("/Statistic/ListStatisticDefinitions", request, "X-EntityToken", requestContext.EntityToken, extraHeaders, requestSettings);
+ if (httpResult is PlayFabError)
+ {
+ var error = (PlayFabError)httpResult;
+ PlayFabSettings.GlobalErrorHandler?.Invoke(error);
+ return new PlayFabResult { Error = error, CustomData = customData };
+ }
+
+ var resultRawJson = (string)httpResult;
+ var resultData = PluginManager.GetPlugin(PluginContract.PlayFab_Serializer).DeserializeObject>(resultRawJson);
+ var result = resultData.data;
+
+ return new PlayFabResult { Result = result, CustomData = customData };
+ }
+
+ ///
+ /// Unlinks a leaderboard definition from it's linked statistic definition.
+ ///
+ public async Task> UnlinkLeaderboardFromStatisticAsync(UnlinkLeaderboardFromStatisticRequest request, object customData = null, Dictionary extraHeaders = null)
+ {
+ await new PlayFabUtil.SynchronizationContextRemover();
+
+ var requestContext = request?.AuthenticationContext ?? authenticationContext;
+ var requestSettings = apiSettings ?? PlayFabSettings.staticSettings;
+ if (requestContext.EntityToken == null) throw new PlayFabException(PlayFabExceptionCode.EntityTokenNotSet, "Must call Client Login or GetEntityToken before calling this method");
+
+ var httpResult = await PlayFabHttp.DoPost("/Leaderboard/UnlinkLeaderboardFromStatistic", request, "X-EntityToken", requestContext.EntityToken, extraHeaders, requestSettings);
+ if (httpResult is PlayFabError)
+ {
+ var error = (PlayFabError)httpResult;
+ PlayFabSettings.GlobalErrorHandler?.Invoke(error);
+ return new PlayFabResult { Error = error, CustomData = customData };
+ }
+
+ var resultRawJson = (string)httpResult;
+ var resultData = PluginManager.GetPlugin(PluginContract.PlayFab_Serializer).DeserializeObject>(resultRawJson);
+ var result = resultData.data;
+
+ return new PlayFabResult { Result = result, CustomData = customData };
+ }
+
+ ///