From 4b09ff5263240f35d13a6225afd5b1d5587449f2 Mon Sep 17 00:00:00 2001 From: PlayFab SDK Team Date: Mon, 5 Aug 2024 22:18:35 +0000 Subject: [PATCH] https://docs.microsoft.com/en-us/gaming/playfab/release-notes/#240802 --- PlayFabSDK/source/PlayFabAdminModels.cs | 4 + PlayFabSDK/source/PlayFabErrors.cs | 6 +- PlayFabSDK/source/PlayFabLeaderboardsAPI.cs | 633 +++++++++++ .../source/PlayFabLeaderboardsInstanceAPI.cs | 630 +++++++++++ .../source/PlayFabLeaderboardsModels.cs | 1007 +++++++++++++++++ PlayFabSDK/source/PlayFabSDK.csproj | 4 +- PlayFabSDK/source/PlayFabServerModels.cs | 6 +- PlayFabSDK/source/PlayFabSettings.cs | 4 +- .../source/PlayFabCloudScriptPlugin.csproj | 6 +- .../PlayFabSDK/PlayFabAdminModels.cs | 4 + .../PlayFabSDK/PlayFabErrors.cs | 6 +- .../PlayFabSDK/PlayFabLeaderboardsAPI.cs | 633 +++++++++++ .../PlayFabLeaderboardsInstanceAPI.cs | 630 +++++++++++ .../PlayFabSDK/PlayFabLeaderboardsModels.cs | 1007 +++++++++++++++++ .../PlayFabSDK/PlayFabSDK.csproj | 4 +- .../PlayFabSDK/PlayFabServerModels.cs | 6 +- .../PlayFabSDK/PlayFabSettings.cs | 4 +- 17 files changed, 4579 insertions(+), 15 deletions(-) create mode 100644 PlayFabSDK/source/PlayFabLeaderboardsAPI.cs create mode 100644 PlayFabSDK/source/PlayFabLeaderboardsInstanceAPI.cs create mode 100644 PlayFabSDK/source/PlayFabLeaderboardsModels.cs create mode 100644 XamarinTestRunner/XamarinTestRunner/PlayFabSDK/PlayFabLeaderboardsAPI.cs create mode 100644 XamarinTestRunner/XamarinTestRunner/PlayFabSDK/PlayFabLeaderboardsInstanceAPI.cs create mode 100644 XamarinTestRunner/XamarinTestRunner/PlayFabSDK/PlayFabLeaderboardsModels.cs 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 }; + } + + /// + /// Adds or updates entries on the specified leaderboard. + /// + public async Task> UpdateLeaderboardEntriesAsync(UpdateLeaderboardEntriesRequest 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/UpdateLeaderboardEntries", 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 }; + } + + /// + /// Update statistics on an entity profile. Depending on the statistic definition, this may result in entity being ranked on + /// various leaderboards. + /// + public async Task> UpdateStatisticsAsync(UpdateStatisticsRequest 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/UpdateStatistics", 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 }; + } + +} +} +#endif diff --git a/PlayFabSDK/source/PlayFabLeaderboardsModels.cs b/PlayFabSDK/source/PlayFabLeaderboardsModels.cs new file mode 100644 index 00000000..bfe7ad91 --- /dev/null +++ b/PlayFabSDK/source/PlayFabLeaderboardsModels.cs @@ -0,0 +1,1007 @@ +using PlayFab.Internal; +using System; +using System.Collections.Generic; + +namespace PlayFab.LeaderboardsModels +{ + public class CreateLeaderboardDefinitionRequest : PlayFabRequestCommon + { + /// + /// Leaderboard columns describing the sort directions, cannot be changed after creation. + /// + public List Columns ; + + /// + /// The optional custom tags associated with the request (e.g. build number, external trace identifiers, etc.). + /// + public Dictionary CustomTags ; + + /// + /// The entity type being represented on the leaderboard. If it doesn't correspond to the PlayFab entity types, use + /// 'external' as the type. + /// + public string EntityType ; + + /// + /// A name for the leaderboard, unique per title. + /// + public string Name ; + + /// + /// Maximum number of entries on this leaderboard + /// + public int SizeLimit ; + + /// + /// The version reset configuration for the leaderboard definition. + /// + public VersionConfiguration VersionConfiguration ; + + } + + public class CreateStatisticDefinitionRequest : PlayFabRequestCommon + { + /// + /// The columns for the statistic defining the aggregation method for each column. + /// + public List Columns ; + + /// + /// The optional custom tags associated with the request (e.g. build number, external trace identifiers, etc.). + /// + public Dictionary CustomTags ; + + /// + /// The entity type allowed to have score(s) for this statistic. + /// + public string EntityType ; + + /// + /// Name of the statistic. Must be less than 50 characters. Restricted to a-Z, 0-9, '(', ')', '_', '-' and '.'. + /// + public string Name ; + + /// + /// The version reset configuration for the statistic definition. + /// + public VersionConfiguration VersionConfiguration ; + + } + + public class DeleteLeaderboardDefinitionRequest : PlayFabRequestCommon + { + /// + /// The optional custom tags associated with the request (e.g. build number, external trace identifiers, etc.). + /// + public Dictionary CustomTags ; + + /// + /// The name of the leaderboard definition to delete. + /// + public string Name ; + + } + + public class DeleteLeaderboardEntriesRequest : PlayFabRequestCommon + { + /// + /// The optional custom tags associated with the request (e.g. build number, external trace identifiers, etc.). + /// + public Dictionary CustomTags ; + + /// + /// The unique Ids of the entries to delete from the leaderboard. + /// + public List EntityIds ; + + /// + /// The name of the leaderboard. + /// + public string Name ; + + } + + public class DeleteStatisticDefinitionRequest : PlayFabRequestCommon + { + /// + /// The optional custom tags associated with the request (e.g. build number, external trace identifiers, etc.). + /// + public Dictionary CustomTags ; + + /// + /// Name of the statistic to delete. + /// + public string Name ; + + } + + public class DeleteStatisticsRequest : PlayFabRequestCommon + { + /// + /// The optional custom tags associated with the request (e.g. build number, external trace identifiers, etc.). + /// + public Dictionary CustomTags ; + + /// + /// The optional entity to perform this action on. Defaults to the currently logged in entity. + /// + public EntityKey Entity ; + + /// + /// Collection of statistics to remove from this entity. + /// + public List Statistics ; + + } + + public class DeleteStatisticsResponse : PlayFabResultCommon + { + /// + /// The entity id and type. + /// + public EntityKey Entity ; + + } + + public class EmptyResponse : PlayFabResultCommon + { + } + + /// + /// Combined entity type and ID structure which uniquely identifies a single entity. + /// + public class EntityKey + { + /// + /// Unique ID of the entity. + /// + public string Id { get; set; } + + /// + /// Entity type. See https://docs.microsoft.com/gaming/playfab/features/data/entities/available-built-in-entity-types + /// + public string Type { get; set; } + + } + + /// + /// Individual rank of an entity in a leaderboard + /// + public class EntityLeaderboardEntry + { + /// + /// Entity's display name. + /// + public string DisplayName ; + + /// + /// Entity identifier. + /// + public EntityKey Entity ; + + /// + /// The time at which the last update to the entry was recorded on the server. + /// + public DateTime LastUpdated ; + + /// + /// An opaque blob of data stored on the leaderboard entry. Note that the metadata is not used for ranking purposes. + /// + public string Metadata ; + + /// + /// Position on the leaderboard. + /// + public int Rank ; + + /// + /// Scores for the entry. + /// + public List Scores ; + + } + + public class EntityStatistics + { + /// + /// Entity key + /// + public EntityKey EntityKey ; + + /// + /// All statistics for the given entitykey + /// + public List Statistics ; + + } + + public class EntityStatisticValue + { + /// + /// Metadata associated with the Statistic. + /// + public string Metadata ; + + /// + /// Statistic name + /// + public string Name ; + + /// + /// Statistic scores + /// + public List Scores ; + + /// + /// Statistic version + /// + public int Version ; + + } + + public enum ExternalFriendSources + { + None, + Steam, + Facebook, + Xbox, + Psn, + All + } + + /// + /// Request to load a leaderboard. + /// + public class GetEntityLeaderboardRequest : PlayFabRequestCommon + { + /// + /// The optional custom tags associated with the request (e.g. build number, external trace identifiers, etc.). + /// + public Dictionary CustomTags ; + + /// + /// Name of the leaderboard. + /// + public string LeaderboardName ; + + /// + /// Maximum number of results to return from the leaderboard. Minimum 1, maximum 1,000. + /// + public uint PageSize ; + + /// + /// Index position to start from. 1 is beginning of leaderboard. + /// + public uint? StartingPosition ; + + /// + /// Optional version of the leaderboard, defaults to current version. + /// + public uint? Version ; + + } + + /// + /// Leaderboard response + /// + public class GetEntityLeaderboardResponse : PlayFabResultCommon + { + /// + /// Leaderboard columns describing the sort directions, + /// + public List Columns ; + + /// + /// Individual entity rankings in the leaderboard, in sorted order by rank. + /// + public List Rankings ; + + /// + /// Version of the leaderboard being returned. + /// + public uint Version ; + + } + + public class GetFriendLeaderboardForEntityRequest : PlayFabRequestCommon + { + /// + /// The optional custom tags associated with the request (e.g. build number, external trace identifiers, etc.). + /// + public Dictionary CustomTags ; + + /// + /// The optional entity to perform this action on. Defaults to the currently logged in entity. + /// + public EntityKey Entity ; + + /// + /// Indicates which other platforms' friends should be included in the response. In HTTP, it is represented as a + /// comma-separated list of platforms. + /// + public ExternalFriendSources? ExternalFriendSources ; + + /// + /// Name of the leaderboard. + /// + public string LeaderboardName ; + + /// + /// Optional version of the leaderboard, defaults to current version. + /// + public uint? Version ; + + /// + /// Xbox token if Xbox friends should be included. Requires Xbox be configured on PlayFab. + /// + public string XboxToken ; + + } + + /// + /// Request to load a section of a leaderboard centered on a specific entity. + /// + public class GetLeaderboardAroundEntityRequest : PlayFabRequestCommon + { + /// + /// The optional custom tags associated with the request (e.g. build number, external trace identifiers, etc.). + /// + public Dictionary CustomTags ; + + /// + /// The optional entity to perform this action on. Defaults to the currently logged in entity. + /// + public EntityKey Entity ; + + /// + /// Name of the leaderboard. + /// + public string LeaderboardName ; + + /// + /// Number of surrounding entries to return (in addition to specified entity). In general, the number of ranks above and + /// below will be split into half. For example, if the specified value is 10, 5 ranks above and 5 ranks below will be + /// retrieved. However, the numbers will get skewed in either direction when the specified entity is towards the top or + /// bottom of the leaderboard. Also, the number of entries returned can be lower than the value specified for entries at the + /// bottom of the leaderboard. + /// + public uint MaxSurroundingEntries ; + + /// + /// Optional version of the leaderboard, defaults to current. + /// + public uint? Version ; + + } + + public class GetLeaderboardDefinitionRequest : PlayFabRequestCommon + { + /// + /// The optional custom tags associated with the request (e.g. build number, external trace identifiers, etc.). + /// + public Dictionary CustomTags ; + + /// + /// The name of the leaderboard to retrieve the definition for. + /// + public string Name ; + + } + + public class GetLeaderboardDefinitionResponse : PlayFabResultCommon + { + /// + /// Sort direction of the leaderboard columns, cannot be changed after creation. + /// + public List Columns ; + + /// + /// Created time, in UTC + /// + public DateTime Created ; + + /// + /// The entity type being represented on the leaderboard. If it doesn't correspond to the PlayFab entity types, use + /// 'external' as the type. + /// + public string EntityType ; + + /// + /// Last time, in UTC, leaderboard version was incremented. + /// + public DateTime? LastResetTime ; + + /// + /// A name for the leaderboard, unique per title. + /// + public string Name ; + + /// + /// Maximum number of entries on this leaderboard + /// + public int SizeLimit ; + + /// + /// Latest Leaderboard version. + /// + public uint Version ; + + /// + /// The version reset configuration for the leaderboard definition. + /// + public VersionConfiguration VersionConfiguration ; + + } + + /// + /// Request a leaderboard limited to a collection of entities. + /// + public class GetLeaderboardForEntitiesRequest : PlayFabRequestCommon + { + /// + /// The optional custom tags associated with the request (e.g. build number, external trace identifiers, etc.). + /// + public Dictionary CustomTags ; + + /// + /// Collection of Entity IDs to include in the leaderboard. + /// + public List EntityIds ; + + /// + /// Name of the leaderboard. + /// + public string LeaderboardName ; + + /// + /// Optional version of the leaderboard, defaults to current. + /// + public uint? Version ; + + } + + public class GetStatisticDefinitionRequest : PlayFabRequestCommon + { + /// + /// The optional custom tags associated with the request (e.g. build number, external trace identifiers, etc.). + /// + public Dictionary CustomTags ; + + /// + /// Name of the statistic. Must be less than 50 characters. + /// + public string Name ; + + } + + public class GetStatisticDefinitionResponse : PlayFabResultCommon + { + /// + /// The columns for the statistic defining the aggregation method for each column. + /// + public List Columns ; + + /// + /// Created time, in UTC + /// + public DateTime Created ; + + /// + /// The entity type that can have this statistic. + /// + public string EntityType ; + + /// + /// Last time, in UTC, statistic version was incremented. + /// + public DateTime? LastResetTime ; + + /// + /// The list of leaderboards that are linked to this statistic definition. + /// + public List LinkedLeaderboardNames ; + + /// + /// Name of the statistic. + /// + public string Name ; + + /// + /// Statistic version. + /// + public uint Version ; + + /// + /// The version reset configuration for the leaderboard definition. + /// + public VersionConfiguration VersionConfiguration ; + + } + + public class GetStatisticDefinitionsRequest : PlayFabRequestCommon + { + /// + /// The optional custom tags associated with the request (e.g. build number, external trace identifiers, etc.). + /// + public Dictionary CustomTags ; + + } + + public class GetStatisticDefinitionsResponse : PlayFabResultCommon + { + /// + /// List of statistic definitions for the title. + /// + public List StatisticDefinitions ; + + } + + public class GetStatisticsForEntitiesRequest : PlayFabRequestCommon + { + /// + /// The optional custom tags associated with the request (e.g. build number, external trace identifiers, etc.). + /// + public Dictionary CustomTags ; + + /// + /// Collection of Entity IDs to retrieve statistics for. + /// + public List Entities ; + + } + + public class GetStatisticsForEntitiesResponse : PlayFabResultCommon + { + /// + /// A mapping of statistic name to the columns defined in the corresponding definition. + /// + public Dictionary ColumnDetails ; + + /// + /// List of entities mapped to their statistics. Only the latest version of a statistic is returned. + /// + public List EntitiesStatistics ; + + } + + public class GetStatisticsRequest : PlayFabRequestCommon + { + /// + /// The optional custom tags associated with the request (e.g. build number, external trace identifiers, etc.). + /// + public Dictionary CustomTags ; + + /// + /// The optional entity to perform this action on. Defaults to the currently logged in entity. + /// + public EntityKey Entity ; + + } + + public class GetStatisticsResponse : PlayFabResultCommon + { + /// + /// A mapping of statistic name to the columns defined in the corresponding definition. + /// + public Dictionary ColumnDetails ; + + /// + /// The entity id and type. + /// + public EntityKey Entity ; + + /// + /// List of statistics keyed by Name. Only the latest version of a statistic is returned. + /// + public Dictionary Statistics ; + + } + + public class IncrementLeaderboardVersionRequest : PlayFabRequestCommon + { + /// + /// The optional custom tags associated with the request (e.g. build number, external trace identifiers, etc.). + /// + public Dictionary CustomTags ; + + /// + /// The name of the leaderboard to increment the version for. + /// + public string Name ; + + } + + public class IncrementLeaderboardVersionResponse : PlayFabResultCommon + { + /// + /// New Leaderboard version. + /// + public uint Version ; + + } + + public class IncrementStatisticVersionRequest : PlayFabRequestCommon + { + /// + /// The optional custom tags associated with the request (e.g. build number, external trace identifiers, etc.). + /// + public Dictionary CustomTags ; + + /// + /// Name of the statistic to increment the version of. + /// + public string Name ; + + } + + public class IncrementStatisticVersionResponse : PlayFabResultCommon + { + /// + /// New statistic version. + /// + public uint Version ; + + } + + public class LeaderboardColumn + { + /// + /// If the value for this column is sourced from a statistic, details of the linked column. Null if the leaderboard is not + /// linked. + /// + public LinkedStatisticColumn LinkedStatisticColumn ; + + /// + /// A name for the leaderboard column, unique per leaderboard definition. + /// + public string Name ; + + /// + /// The sort direction for this column. + /// + public LeaderboardSortDirection SortDirection ; + + } + + public class LeaderboardDefinition + { + /// + /// Sort direction of the leaderboard columns, cannot be changed after creation. + /// + public List Columns ; + + /// + /// Created time, in UTC + /// + public DateTime Created ; + + /// + /// The entity type being represented on the leaderboard. If it doesn't correspond to the PlayFab entity types, use + /// 'external' as the type. + /// + public string EntityType ; + + /// + /// Last time, in UTC, leaderboard version was incremented. + /// + public DateTime? LastResetTime ; + + /// + /// A name for the leaderboard, unique per title. + /// + public string Name ; + + /// + /// Maximum number of entries on this leaderboard + /// + public int SizeLimit ; + + /// + /// Latest Leaderboard version. + /// + public uint Version ; + + /// + /// The version reset configuration for the leaderboard definition. + /// + public VersionConfiguration VersionConfiguration ; + + } + + public class LeaderboardEntryUpdate + { + /// + /// The unique Id for the entry. If using PlayFab Entities, this would be the entityId of the entity. + /// + public string EntityId ; + + /// + /// Arbitrary metadata to store along side the leaderboard entry, will be returned by all Leaderboard APIs. Must be less + /// than 50 UTF8 encoded characters. + /// + public string Metadata ; + + /// + /// The scores for the leaderboard. The number of values provided here must match the number of columns in the Leaderboard + /// definition. + /// + public List Scores ; + + } + + public enum LeaderboardSortDirection + { + Descending, + Ascending + } + + public class LinkedStatisticColumn + { + /// + /// The name of the statistic column that this leaderboard column is sourced from. + /// + public string LinkedStatisticColumnName ; + + /// + /// The name of the statistic. + /// + public string LinkedStatisticName ; + + } + + public class ListLeaderboardDefinitionsRequest : PlayFabRequestCommon + { + /// + /// The optional custom tags associated with the request (e.g. build number, external trace identifiers, etc.). + /// + public Dictionary CustomTags ; + + } + + public class ListLeaderboardDefinitionsResponse : PlayFabResultCommon + { + /// + /// List of leaderboard definitions for the title. + /// + public List LeaderboardDefinitions ; + + } + + public class ListStatisticDefinitionsRequest : PlayFabRequestCommon + { + /// + /// The optional custom tags associated with the request (e.g. build number, external trace identifiers, etc.). + /// + public Dictionary CustomTags ; + + } + + public class ListStatisticDefinitionsResponse : PlayFabResultCommon + { + /// + /// The optional custom tags associated with the request (e.g. build number, external trace identifiers, etc.). + /// + public Dictionary CustomTags ; + + /// + /// List of statistic definitions for the title. + /// + public List StatisticDefinitions ; + + } + + public enum ResetInterval + { + Manual, + Hour, + Day, + Week, + Month + } + + public enum StatisticAggregationMethod + { + Last, + Min, + Max, + Sum + } + + public class StatisticColumn + { + /// + /// Aggregation method for calculating new value of a statistic. + /// + public StatisticAggregationMethod AggregationMethod ; + + /// + /// Name of the statistic column, as originally configured. + /// + public string Name ; + + } + + public class StatisticColumnCollection + { + /// + /// Columns for the statistic defining the aggregation method for each column. + /// + public List Columns ; + + } + + public class StatisticDefinition + { + /// + /// The columns for the statistic defining the aggregation method for each column. + /// + public List Columns ; + + /// + /// Created time, in UTC + /// + public DateTime Created ; + + /// + /// The entity type that can have this statistic. + /// + public string EntityType ; + + /// + /// Last time, in UTC, statistic version was incremented. + /// + public DateTime? LastResetTime ; + + /// + /// The list of leaderboards that are linked to this statistic definition. + /// + public List LinkedLeaderboardNames ; + + /// + /// Name of the statistic. + /// + public string Name ; + + /// + /// Statistic version. + /// + public uint Version ; + + /// + /// The version reset configuration for the leaderboard definition. + /// + public VersionConfiguration VersionConfiguration ; + + } + + public class StatisticDelete + { + /// + /// Name of the statistic, as originally configured. + /// + public string Name ; + + } + + public class StatisticUpdate + { + /// + /// Arbitrary metadata to store along side the statistic, will be returned by all Leaderboard APIs. Must be less than 50 + /// UTF8 encoded characters. + /// + public string Metadata ; + + /// + /// Name of the statistic, as originally configured. + /// + public string Name ; + + /// + /// Statistic scores for the entity. This will be used in accordance with the aggregation method configured for the + /// statistics.The maximum value allowed for each individual score is 9223372036854775807. The minimum value for each + /// individual score is -9223372036854775807The values are formatted as strings to avoid interop issues with client + /// libraries unable to handle 64bit integers. + /// + public List Scores ; + + /// + /// Optional field to indicate the version of the statistic to set. When empty defaults to the statistic's current version. + /// + public uint? Version ; + + } + + public class UnlinkLeaderboardFromStatisticRequest : PlayFabRequestCommon + { + /// + /// The optional custom tags associated with the request (e.g. build number, external trace identifiers, etc.). + /// + public Dictionary CustomTags ; + + /// + /// The name of the leaderboard definition to unlink. + /// + public string Name ; + + /// + /// The name of the statistic definition to unlink. + /// + public string StatisticName ; + + } + + public class UpdateLeaderboardEntriesRequest : PlayFabRequestCommon + { + /// + /// The optional custom tags associated with the request (e.g. build number, external trace identifiers, etc.). + /// + public Dictionary CustomTags ; + + /// + /// The entries to add or update on the leaderboard. + /// + public List Entries ; + + /// + /// The name of the leaderboard. + /// + public string LeaderboardName ; + + } + + public class UpdateStatisticsRequest : PlayFabRequestCommon + { + /// + /// The optional custom tags associated with the request (e.g. build number, external trace identifiers, etc.). + /// + public Dictionary CustomTags ; + + /// + /// The optional entity to perform this action on. Defaults to the currently logged in entity. + /// + public EntityKey Entity ; + + /// + /// Collection of statistics to update, maximum 50. + /// + public List Statistics ; + + } + + public class UpdateStatisticsResponse : PlayFabResultCommon + { + /// + /// A mapping of statistic name to the columns defined in the corresponding definition. + /// + public Dictionary ColumnDetails ; + + /// + /// The entity id and type. + /// + public EntityKey Entity ; + + /// + /// Updated entity profile statistics. + /// + public Dictionary Statistics ; + + } + + public class VersionConfiguration + { + /// + /// The maximum number of versions of this leaderboard/statistic that can be queried. + /// + public int MaxQueryableVersions ; + + /// + /// Reset interval that statistics or leaderboards will reset on. When using Manual intervalthe reset can only be increased + /// by calling the Increase version API. When using Hour interval the resetwill occur at the start of the next hour UTC + /// time. When using Day interval the reset will occur at thestart of the next day in UTC time. When using the Week interval + /// the reset will occur at the start ofthe next Monday in UTC time. When using Month interval the reset will occur at the + /// start of the nextmonth in UTC time. + /// + public ResetInterval ResetInterval ; + + } +} diff --git a/PlayFabSDK/source/PlayFabSDK.csproj b/PlayFabSDK/source/PlayFabSDK.csproj index 70c7db21..de070f16 100644 --- a/PlayFabSDK/source/PlayFabSDK.csproj +++ b/PlayFabSDK/source/PlayFabSDK.csproj @@ -8,7 +8,7 @@ 512 PlayFabAllSDK - 1.184.240719 + 1.185.240802 PlayFab CSharp Sdk Microsoft Microsoft @@ -21,7 +21,7 @@ PlayFab PlayFabSDK PlayFab, Baas, Paas, JSON, REST, HTTP, SSL, API, cloud, liveops, game, gamedev, native - https://docs.microsoft.com/gaming/playfab/release-notes#240719 + https://docs.microsoft.com/gaming/playfab/release-notes#240802 en 1 1 diff --git a/PlayFabSDK/source/PlayFabServerModels.cs b/PlayFabSDK/source/PlayFabServerModels.cs index 86e84e35..c12e42ab 100644 --- a/PlayFabSDK/source/PlayFabServerModels.cs +++ b/PlayFabSDK/source/PlayFabServerModels.cs @@ -2127,7 +2127,11 @@ public enum GenericErrorCodes LinkedStatisticColumnNotFound, LinkedStatisticColumnRequired, MultipleLinkedStatisticsNotAllowed, + DuplicateLinkedStatisticColumnNameFound, + AggregationTypeNotAllowedForMultiColumnStatistic, MaxQueryableVerionsValueNotAllowedForTier, + StatisticDefinitionHasNullOrEmptyVersionConfiguration, + StatisticColumnLengthMismatch, MatchmakingEntityInvalid, MatchmakingPlayerAttributesInvalid, MatchmakingQueueNotFound, @@ -4579,7 +4583,7 @@ public class LinkPSNIdRequest : PlayFabRequestCommon public string PlayFabId ; /// - /// Id of the PlayStation :tm: Network user. + /// Id of the PlayStation :tm: Network user. Also known as the PSN Account Id. /// public string PSNUserId ; diff --git a/PlayFabSDK/source/PlayFabSettings.cs b/PlayFabSDK/source/PlayFabSettings.cs index ecc0b7ba..e57ca1a3 100644 --- a/PlayFabSDK/source/PlayFabSettings.cs +++ b/PlayFabSDK/source/PlayFabSettings.cs @@ -6,9 +6,9 @@ namespace PlayFab { public class PlayFabSettings { - public const string SdkVersion = "1.184.240719"; + public const string SdkVersion = "1.185.240802"; public const string BuildIdentifier = "adobuild_csharpsdk_114"; - public const string SdkVersionString = "CSharpSDK-1.184.240719"; + public const string SdkVersionString = "CSharpSDK-1.185.240802"; /// This is only for customers running a private cluster. Generally you shouldn't touch this public static string DefaultProductionEnvironmentUrl = "playfabapi.com"; diff --git a/Plugins/CloudScript/source/PlayFabCloudScriptPlugin.csproj b/Plugins/CloudScript/source/PlayFabCloudScriptPlugin.csproj index 4660ca42..39bc1015 100644 --- a/Plugins/CloudScript/source/PlayFabCloudScriptPlugin.csproj +++ b/Plugins/CloudScript/source/PlayFabCloudScriptPlugin.csproj @@ -8,7 +8,7 @@ 512 PlayFabCloudScriptPlugin - 1.184.240719-alpha + 1.185.240802-alpha PlayFab CSharp CloudScript Plugin Microsoft Microsoft @@ -21,7 +21,7 @@ PlayFabCloudScriptPlugin Copyright 2024 PlayFab, Baas, Paas, JSON, REST, HTTP, SSL, API, cloud, liveops, game, gamedev, native - https://docs.microsoft.com/gaming/playfab/release-notes#240719 + https://docs.microsoft.com/gaming/playfab/release-notes#240802 en 1 1 @@ -45,7 +45,7 @@ - + diff --git a/XamarinTestRunner/XamarinTestRunner/PlayFabSDK/PlayFabAdminModels.cs b/XamarinTestRunner/XamarinTestRunner/PlayFabSDK/PlayFabAdminModels.cs index 0450e346..9b89e58b 100644 --- a/XamarinTestRunner/XamarinTestRunner/PlayFabSDK/PlayFabAdminModels.cs +++ b/XamarinTestRunner/XamarinTestRunner/PlayFabSDK/PlayFabAdminModels.cs @@ -2807,7 +2807,11 @@ public enum GenericErrorCodes LinkedStatisticColumnNotFound, LinkedStatisticColumnRequired, MultipleLinkedStatisticsNotAllowed, + DuplicateLinkedStatisticColumnNameFound, + AggregationTypeNotAllowedForMultiColumnStatistic, MaxQueryableVerionsValueNotAllowedForTier, + StatisticDefinitionHasNullOrEmptyVersionConfiguration, + StatisticColumnLengthMismatch, MatchmakingEntityInvalid, MatchmakingPlayerAttributesInvalid, MatchmakingQueueNotFound, diff --git a/XamarinTestRunner/XamarinTestRunner/PlayFabSDK/PlayFabErrors.cs b/XamarinTestRunner/XamarinTestRunner/PlayFabSDK/PlayFabErrors.cs index 8a942e14..780309ee 100644 --- a/XamarinTestRunner/XamarinTestRunner/PlayFabSDK/PlayFabErrors.cs +++ b/XamarinTestRunner/XamarinTestRunner/PlayFabSDK/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/XamarinTestRunner/XamarinTestRunner/PlayFabSDK/PlayFabLeaderboardsAPI.cs b/XamarinTestRunner/XamarinTestRunner/PlayFabSDK/PlayFabLeaderboardsAPI.cs new file mode 100644 index 00000000..e4cc5a02 --- /dev/null +++ b/XamarinTestRunner/XamarinTestRunner/PlayFabSDK/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/XamarinTestRunner/XamarinTestRunner/PlayFabSDK/PlayFabLeaderboardsInstanceAPI.cs b/XamarinTestRunner/XamarinTestRunner/PlayFabSDK/PlayFabLeaderboardsInstanceAPI.cs new file mode 100644 index 00000000..653896cb --- /dev/null +++ b/XamarinTestRunner/XamarinTestRunner/PlayFabSDK/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 }; + } + + /// + /// Adds or updates entries on the specified leaderboard. + /// + public async Task> UpdateLeaderboardEntriesAsync(UpdateLeaderboardEntriesRequest 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/UpdateLeaderboardEntries", 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 }; + } + + /// + /// Update statistics on an entity profile. Depending on the statistic definition, this may result in entity being ranked on + /// various leaderboards. + /// + public async Task> UpdateStatisticsAsync(UpdateStatisticsRequest 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/UpdateStatistics", 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 }; + } + +} +} +#endif diff --git a/XamarinTestRunner/XamarinTestRunner/PlayFabSDK/PlayFabLeaderboardsModels.cs b/XamarinTestRunner/XamarinTestRunner/PlayFabSDK/PlayFabLeaderboardsModels.cs new file mode 100644 index 00000000..bfe7ad91 --- /dev/null +++ b/XamarinTestRunner/XamarinTestRunner/PlayFabSDK/PlayFabLeaderboardsModels.cs @@ -0,0 +1,1007 @@ +using PlayFab.Internal; +using System; +using System.Collections.Generic; + +namespace PlayFab.LeaderboardsModels +{ + public class CreateLeaderboardDefinitionRequest : PlayFabRequestCommon + { + /// + /// Leaderboard columns describing the sort directions, cannot be changed after creation. + /// + public List Columns ; + + /// + /// The optional custom tags associated with the request (e.g. build number, external trace identifiers, etc.). + /// + public Dictionary CustomTags ; + + /// + /// The entity type being represented on the leaderboard. If it doesn't correspond to the PlayFab entity types, use + /// 'external' as the type. + /// + public string EntityType ; + + /// + /// A name for the leaderboard, unique per title. + /// + public string Name ; + + /// + /// Maximum number of entries on this leaderboard + /// + public int SizeLimit ; + + /// + /// The version reset configuration for the leaderboard definition. + /// + public VersionConfiguration VersionConfiguration ; + + } + + public class CreateStatisticDefinitionRequest : PlayFabRequestCommon + { + /// + /// The columns for the statistic defining the aggregation method for each column. + /// + public List Columns ; + + /// + /// The optional custom tags associated with the request (e.g. build number, external trace identifiers, etc.). + /// + public Dictionary CustomTags ; + + /// + /// The entity type allowed to have score(s) for this statistic. + /// + public string EntityType ; + + /// + /// Name of the statistic. Must be less than 50 characters. Restricted to a-Z, 0-9, '(', ')', '_', '-' and '.'. + /// + public string Name ; + + /// + /// The version reset configuration for the statistic definition. + /// + public VersionConfiguration VersionConfiguration ; + + } + + public class DeleteLeaderboardDefinitionRequest : PlayFabRequestCommon + { + /// + /// The optional custom tags associated with the request (e.g. build number, external trace identifiers, etc.). + /// + public Dictionary CustomTags ; + + /// + /// The name of the leaderboard definition to delete. + /// + public string Name ; + + } + + public class DeleteLeaderboardEntriesRequest : PlayFabRequestCommon + { + /// + /// The optional custom tags associated with the request (e.g. build number, external trace identifiers, etc.). + /// + public Dictionary CustomTags ; + + /// + /// The unique Ids of the entries to delete from the leaderboard. + /// + public List EntityIds ; + + /// + /// The name of the leaderboard. + /// + public string Name ; + + } + + public class DeleteStatisticDefinitionRequest : PlayFabRequestCommon + { + /// + /// The optional custom tags associated with the request (e.g. build number, external trace identifiers, etc.). + /// + public Dictionary CustomTags ; + + /// + /// Name of the statistic to delete. + /// + public string Name ; + + } + + public class DeleteStatisticsRequest : PlayFabRequestCommon + { + /// + /// The optional custom tags associated with the request (e.g. build number, external trace identifiers, etc.). + /// + public Dictionary CustomTags ; + + /// + /// The optional entity to perform this action on. Defaults to the currently logged in entity. + /// + public EntityKey Entity ; + + /// + /// Collection of statistics to remove from this entity. + /// + public List Statistics ; + + } + + public class DeleteStatisticsResponse : PlayFabResultCommon + { + /// + /// The entity id and type. + /// + public EntityKey Entity ; + + } + + public class EmptyResponse : PlayFabResultCommon + { + } + + /// + /// Combined entity type and ID structure which uniquely identifies a single entity. + /// + public class EntityKey + { + /// + /// Unique ID of the entity. + /// + public string Id { get; set; } + + /// + /// Entity type. See https://docs.microsoft.com/gaming/playfab/features/data/entities/available-built-in-entity-types + /// + public string Type { get; set; } + + } + + /// + /// Individual rank of an entity in a leaderboard + /// + public class EntityLeaderboardEntry + { + /// + /// Entity's display name. + /// + public string DisplayName ; + + /// + /// Entity identifier. + /// + public EntityKey Entity ; + + /// + /// The time at which the last update to the entry was recorded on the server. + /// + public DateTime LastUpdated ; + + /// + /// An opaque blob of data stored on the leaderboard entry. Note that the metadata is not used for ranking purposes. + /// + public string Metadata ; + + /// + /// Position on the leaderboard. + /// + public int Rank ; + + /// + /// Scores for the entry. + /// + public List Scores ; + + } + + public class EntityStatistics + { + /// + /// Entity key + /// + public EntityKey EntityKey ; + + /// + /// All statistics for the given entitykey + /// + public List Statistics ; + + } + + public class EntityStatisticValue + { + /// + /// Metadata associated with the Statistic. + /// + public string Metadata ; + + /// + /// Statistic name + /// + public string Name ; + + /// + /// Statistic scores + /// + public List Scores ; + + /// + /// Statistic version + /// + public int Version ; + + } + + public enum ExternalFriendSources + { + None, + Steam, + Facebook, + Xbox, + Psn, + All + } + + /// + /// Request to load a leaderboard. + /// + public class GetEntityLeaderboardRequest : PlayFabRequestCommon + { + /// + /// The optional custom tags associated with the request (e.g. build number, external trace identifiers, etc.). + /// + public Dictionary CustomTags ; + + /// + /// Name of the leaderboard. + /// + public string LeaderboardName ; + + /// + /// Maximum number of results to return from the leaderboard. Minimum 1, maximum 1,000. + /// + public uint PageSize ; + + /// + /// Index position to start from. 1 is beginning of leaderboard. + /// + public uint? StartingPosition ; + + /// + /// Optional version of the leaderboard, defaults to current version. + /// + public uint? Version ; + + } + + /// + /// Leaderboard response + /// + public class GetEntityLeaderboardResponse : PlayFabResultCommon + { + /// + /// Leaderboard columns describing the sort directions, + /// + public List Columns ; + + /// + /// Individual entity rankings in the leaderboard, in sorted order by rank. + /// + public List Rankings ; + + /// + /// Version of the leaderboard being returned. + /// + public uint Version ; + + } + + public class GetFriendLeaderboardForEntityRequest : PlayFabRequestCommon + { + /// + /// The optional custom tags associated with the request (e.g. build number, external trace identifiers, etc.). + /// + public Dictionary CustomTags ; + + /// + /// The optional entity to perform this action on. Defaults to the currently logged in entity. + /// + public EntityKey Entity ; + + /// + /// Indicates which other platforms' friends should be included in the response. In HTTP, it is represented as a + /// comma-separated list of platforms. + /// + public ExternalFriendSources? ExternalFriendSources ; + + /// + /// Name of the leaderboard. + /// + public string LeaderboardName ; + + /// + /// Optional version of the leaderboard, defaults to current version. + /// + public uint? Version ; + + /// + /// Xbox token if Xbox friends should be included. Requires Xbox be configured on PlayFab. + /// + public string XboxToken ; + + } + + /// + /// Request to load a section of a leaderboard centered on a specific entity. + /// + public class GetLeaderboardAroundEntityRequest : PlayFabRequestCommon + { + /// + /// The optional custom tags associated with the request (e.g. build number, external trace identifiers, etc.). + /// + public Dictionary CustomTags ; + + /// + /// The optional entity to perform this action on. Defaults to the currently logged in entity. + /// + public EntityKey Entity ; + + /// + /// Name of the leaderboard. + /// + public string LeaderboardName ; + + /// + /// Number of surrounding entries to return (in addition to specified entity). In general, the number of ranks above and + /// below will be split into half. For example, if the specified value is 10, 5 ranks above and 5 ranks below will be + /// retrieved. However, the numbers will get skewed in either direction when the specified entity is towards the top or + /// bottom of the leaderboard. Also, the number of entries returned can be lower than the value specified for entries at the + /// bottom of the leaderboard. + /// + public uint MaxSurroundingEntries ; + + /// + /// Optional version of the leaderboard, defaults to current. + /// + public uint? Version ; + + } + + public class GetLeaderboardDefinitionRequest : PlayFabRequestCommon + { + /// + /// The optional custom tags associated with the request (e.g. build number, external trace identifiers, etc.). + /// + public Dictionary CustomTags ; + + /// + /// The name of the leaderboard to retrieve the definition for. + /// + public string Name ; + + } + + public class GetLeaderboardDefinitionResponse : PlayFabResultCommon + { + /// + /// Sort direction of the leaderboard columns, cannot be changed after creation. + /// + public List Columns ; + + /// + /// Created time, in UTC + /// + public DateTime Created ; + + /// + /// The entity type being represented on the leaderboard. If it doesn't correspond to the PlayFab entity types, use + /// 'external' as the type. + /// + public string EntityType ; + + /// + /// Last time, in UTC, leaderboard version was incremented. + /// + public DateTime? LastResetTime ; + + /// + /// A name for the leaderboard, unique per title. + /// + public string Name ; + + /// + /// Maximum number of entries on this leaderboard + /// + public int SizeLimit ; + + /// + /// Latest Leaderboard version. + /// + public uint Version ; + + /// + /// The version reset configuration for the leaderboard definition. + /// + public VersionConfiguration VersionConfiguration ; + + } + + /// + /// Request a leaderboard limited to a collection of entities. + /// + public class GetLeaderboardForEntitiesRequest : PlayFabRequestCommon + { + /// + /// The optional custom tags associated with the request (e.g. build number, external trace identifiers, etc.). + /// + public Dictionary CustomTags ; + + /// + /// Collection of Entity IDs to include in the leaderboard. + /// + public List EntityIds ; + + /// + /// Name of the leaderboard. + /// + public string LeaderboardName ; + + /// + /// Optional version of the leaderboard, defaults to current. + /// + public uint? Version ; + + } + + public class GetStatisticDefinitionRequest : PlayFabRequestCommon + { + /// + /// The optional custom tags associated with the request (e.g. build number, external trace identifiers, etc.). + /// + public Dictionary CustomTags ; + + /// + /// Name of the statistic. Must be less than 50 characters. + /// + public string Name ; + + } + + public class GetStatisticDefinitionResponse : PlayFabResultCommon + { + /// + /// The columns for the statistic defining the aggregation method for each column. + /// + public List Columns ; + + /// + /// Created time, in UTC + /// + public DateTime Created ; + + /// + /// The entity type that can have this statistic. + /// + public string EntityType ; + + /// + /// Last time, in UTC, statistic version was incremented. + /// + public DateTime? LastResetTime ; + + /// + /// The list of leaderboards that are linked to this statistic definition. + /// + public List LinkedLeaderboardNames ; + + /// + /// Name of the statistic. + /// + public string Name ; + + /// + /// Statistic version. + /// + public uint Version ; + + /// + /// The version reset configuration for the leaderboard definition. + /// + public VersionConfiguration VersionConfiguration ; + + } + + public class GetStatisticDefinitionsRequest : PlayFabRequestCommon + { + /// + /// The optional custom tags associated with the request (e.g. build number, external trace identifiers, etc.). + /// + public Dictionary CustomTags ; + + } + + public class GetStatisticDefinitionsResponse : PlayFabResultCommon + { + /// + /// List of statistic definitions for the title. + /// + public List StatisticDefinitions ; + + } + + public class GetStatisticsForEntitiesRequest : PlayFabRequestCommon + { + /// + /// The optional custom tags associated with the request (e.g. build number, external trace identifiers, etc.). + /// + public Dictionary CustomTags ; + + /// + /// Collection of Entity IDs to retrieve statistics for. + /// + public List Entities ; + + } + + public class GetStatisticsForEntitiesResponse : PlayFabResultCommon + { + /// + /// A mapping of statistic name to the columns defined in the corresponding definition. + /// + public Dictionary ColumnDetails ; + + /// + /// List of entities mapped to their statistics. Only the latest version of a statistic is returned. + /// + public List EntitiesStatistics ; + + } + + public class GetStatisticsRequest : PlayFabRequestCommon + { + /// + /// The optional custom tags associated with the request (e.g. build number, external trace identifiers, etc.). + /// + public Dictionary CustomTags ; + + /// + /// The optional entity to perform this action on. Defaults to the currently logged in entity. + /// + public EntityKey Entity ; + + } + + public class GetStatisticsResponse : PlayFabResultCommon + { + /// + /// A mapping of statistic name to the columns defined in the corresponding definition. + /// + public Dictionary ColumnDetails ; + + /// + /// The entity id and type. + /// + public EntityKey Entity ; + + /// + /// List of statistics keyed by Name. Only the latest version of a statistic is returned. + /// + public Dictionary Statistics ; + + } + + public class IncrementLeaderboardVersionRequest : PlayFabRequestCommon + { + /// + /// The optional custom tags associated with the request (e.g. build number, external trace identifiers, etc.). + /// + public Dictionary CustomTags ; + + /// + /// The name of the leaderboard to increment the version for. + /// + public string Name ; + + } + + public class IncrementLeaderboardVersionResponse : PlayFabResultCommon + { + /// + /// New Leaderboard version. + /// + public uint Version ; + + } + + public class IncrementStatisticVersionRequest : PlayFabRequestCommon + { + /// + /// The optional custom tags associated with the request (e.g. build number, external trace identifiers, etc.). + /// + public Dictionary CustomTags ; + + /// + /// Name of the statistic to increment the version of. + /// + public string Name ; + + } + + public class IncrementStatisticVersionResponse : PlayFabResultCommon + { + /// + /// New statistic version. + /// + public uint Version ; + + } + + public class LeaderboardColumn + { + /// + /// If the value for this column is sourced from a statistic, details of the linked column. Null if the leaderboard is not + /// linked. + /// + public LinkedStatisticColumn LinkedStatisticColumn ; + + /// + /// A name for the leaderboard column, unique per leaderboard definition. + /// + public string Name ; + + /// + /// The sort direction for this column. + /// + public LeaderboardSortDirection SortDirection ; + + } + + public class LeaderboardDefinition + { + /// + /// Sort direction of the leaderboard columns, cannot be changed after creation. + /// + public List Columns ; + + /// + /// Created time, in UTC + /// + public DateTime Created ; + + /// + /// The entity type being represented on the leaderboard. If it doesn't correspond to the PlayFab entity types, use + /// 'external' as the type. + /// + public string EntityType ; + + /// + /// Last time, in UTC, leaderboard version was incremented. + /// + public DateTime? LastResetTime ; + + /// + /// A name for the leaderboard, unique per title. + /// + public string Name ; + + /// + /// Maximum number of entries on this leaderboard + /// + public int SizeLimit ; + + /// + /// Latest Leaderboard version. + /// + public uint Version ; + + /// + /// The version reset configuration for the leaderboard definition. + /// + public VersionConfiguration VersionConfiguration ; + + } + + public class LeaderboardEntryUpdate + { + /// + /// The unique Id for the entry. If using PlayFab Entities, this would be the entityId of the entity. + /// + public string EntityId ; + + /// + /// Arbitrary metadata to store along side the leaderboard entry, will be returned by all Leaderboard APIs. Must be less + /// than 50 UTF8 encoded characters. + /// + public string Metadata ; + + /// + /// The scores for the leaderboard. The number of values provided here must match the number of columns in the Leaderboard + /// definition. + /// + public List Scores ; + + } + + public enum LeaderboardSortDirection + { + Descending, + Ascending + } + + public class LinkedStatisticColumn + { + /// + /// The name of the statistic column that this leaderboard column is sourced from. + /// + public string LinkedStatisticColumnName ; + + /// + /// The name of the statistic. + /// + public string LinkedStatisticName ; + + } + + public class ListLeaderboardDefinitionsRequest : PlayFabRequestCommon + { + /// + /// The optional custom tags associated with the request (e.g. build number, external trace identifiers, etc.). + /// + public Dictionary CustomTags ; + + } + + public class ListLeaderboardDefinitionsResponse : PlayFabResultCommon + { + /// + /// List of leaderboard definitions for the title. + /// + public List LeaderboardDefinitions ; + + } + + public class ListStatisticDefinitionsRequest : PlayFabRequestCommon + { + /// + /// The optional custom tags associated with the request (e.g. build number, external trace identifiers, etc.). + /// + public Dictionary CustomTags ; + + } + + public class ListStatisticDefinitionsResponse : PlayFabResultCommon + { + /// + /// The optional custom tags associated with the request (e.g. build number, external trace identifiers, etc.). + /// + public Dictionary CustomTags ; + + /// + /// List of statistic definitions for the title. + /// + public List StatisticDefinitions ; + + } + + public enum ResetInterval + { + Manual, + Hour, + Day, + Week, + Month + } + + public enum StatisticAggregationMethod + { + Last, + Min, + Max, + Sum + } + + public class StatisticColumn + { + /// + /// Aggregation method for calculating new value of a statistic. + /// + public StatisticAggregationMethod AggregationMethod ; + + /// + /// Name of the statistic column, as originally configured. + /// + public string Name ; + + } + + public class StatisticColumnCollection + { + /// + /// Columns for the statistic defining the aggregation method for each column. + /// + public List Columns ; + + } + + public class StatisticDefinition + { + /// + /// The columns for the statistic defining the aggregation method for each column. + /// + public List Columns ; + + /// + /// Created time, in UTC + /// + public DateTime Created ; + + /// + /// The entity type that can have this statistic. + /// + public string EntityType ; + + /// + /// Last time, in UTC, statistic version was incremented. + /// + public DateTime? LastResetTime ; + + /// + /// The list of leaderboards that are linked to this statistic definition. + /// + public List LinkedLeaderboardNames ; + + /// + /// Name of the statistic. + /// + public string Name ; + + /// + /// Statistic version. + /// + public uint Version ; + + /// + /// The version reset configuration for the leaderboard definition. + /// + public VersionConfiguration VersionConfiguration ; + + } + + public class StatisticDelete + { + /// + /// Name of the statistic, as originally configured. + /// + public string Name ; + + } + + public class StatisticUpdate + { + /// + /// Arbitrary metadata to store along side the statistic, will be returned by all Leaderboard APIs. Must be less than 50 + /// UTF8 encoded characters. + /// + public string Metadata ; + + /// + /// Name of the statistic, as originally configured. + /// + public string Name ; + + /// + /// Statistic scores for the entity. This will be used in accordance with the aggregation method configured for the + /// statistics.The maximum value allowed for each individual score is 9223372036854775807. The minimum value for each + /// individual score is -9223372036854775807The values are formatted as strings to avoid interop issues with client + /// libraries unable to handle 64bit integers. + /// + public List Scores ; + + /// + /// Optional field to indicate the version of the statistic to set. When empty defaults to the statistic's current version. + /// + public uint? Version ; + + } + + public class UnlinkLeaderboardFromStatisticRequest : PlayFabRequestCommon + { + /// + /// The optional custom tags associated with the request (e.g. build number, external trace identifiers, etc.). + /// + public Dictionary CustomTags ; + + /// + /// The name of the leaderboard definition to unlink. + /// + public string Name ; + + /// + /// The name of the statistic definition to unlink. + /// + public string StatisticName ; + + } + + public class UpdateLeaderboardEntriesRequest : PlayFabRequestCommon + { + /// + /// The optional custom tags associated with the request (e.g. build number, external trace identifiers, etc.). + /// + public Dictionary CustomTags ; + + /// + /// The entries to add or update on the leaderboard. + /// + public List Entries ; + + /// + /// The name of the leaderboard. + /// + public string LeaderboardName ; + + } + + public class UpdateStatisticsRequest : PlayFabRequestCommon + { + /// + /// The optional custom tags associated with the request (e.g. build number, external trace identifiers, etc.). + /// + public Dictionary CustomTags ; + + /// + /// The optional entity to perform this action on. Defaults to the currently logged in entity. + /// + public EntityKey Entity ; + + /// + /// Collection of statistics to update, maximum 50. + /// + public List Statistics ; + + } + + public class UpdateStatisticsResponse : PlayFabResultCommon + { + /// + /// A mapping of statistic name to the columns defined in the corresponding definition. + /// + public Dictionary ColumnDetails ; + + /// + /// The entity id and type. + /// + public EntityKey Entity ; + + /// + /// Updated entity profile statistics. + /// + public Dictionary Statistics ; + + } + + public class VersionConfiguration + { + /// + /// The maximum number of versions of this leaderboard/statistic that can be queried. + /// + public int MaxQueryableVersions ; + + /// + /// Reset interval that statistics or leaderboards will reset on. When using Manual intervalthe reset can only be increased + /// by calling the Increase version API. When using Hour interval the resetwill occur at the start of the next hour UTC + /// time. When using Day interval the reset will occur at thestart of the next day in UTC time. When using the Week interval + /// the reset will occur at the start ofthe next Monday in UTC time. When using Month interval the reset will occur at the + /// start of the nextmonth in UTC time. + /// + public ResetInterval ResetInterval ; + + } +} diff --git a/XamarinTestRunner/XamarinTestRunner/PlayFabSDK/PlayFabSDK.csproj b/XamarinTestRunner/XamarinTestRunner/PlayFabSDK/PlayFabSDK.csproj index 70c7db21..de070f16 100644 --- a/XamarinTestRunner/XamarinTestRunner/PlayFabSDK/PlayFabSDK.csproj +++ b/XamarinTestRunner/XamarinTestRunner/PlayFabSDK/PlayFabSDK.csproj @@ -8,7 +8,7 @@ 512 PlayFabAllSDK - 1.184.240719 + 1.185.240802 PlayFab CSharp Sdk Microsoft Microsoft @@ -21,7 +21,7 @@ PlayFab PlayFabSDK PlayFab, Baas, Paas, JSON, REST, HTTP, SSL, API, cloud, liveops, game, gamedev, native - https://docs.microsoft.com/gaming/playfab/release-notes#240719 + https://docs.microsoft.com/gaming/playfab/release-notes#240802 en 1 1 diff --git a/XamarinTestRunner/XamarinTestRunner/PlayFabSDK/PlayFabServerModels.cs b/XamarinTestRunner/XamarinTestRunner/PlayFabSDK/PlayFabServerModels.cs index 86e84e35..c12e42ab 100644 --- a/XamarinTestRunner/XamarinTestRunner/PlayFabSDK/PlayFabServerModels.cs +++ b/XamarinTestRunner/XamarinTestRunner/PlayFabSDK/PlayFabServerModels.cs @@ -2127,7 +2127,11 @@ public enum GenericErrorCodes LinkedStatisticColumnNotFound, LinkedStatisticColumnRequired, MultipleLinkedStatisticsNotAllowed, + DuplicateLinkedStatisticColumnNameFound, + AggregationTypeNotAllowedForMultiColumnStatistic, MaxQueryableVerionsValueNotAllowedForTier, + StatisticDefinitionHasNullOrEmptyVersionConfiguration, + StatisticColumnLengthMismatch, MatchmakingEntityInvalid, MatchmakingPlayerAttributesInvalid, MatchmakingQueueNotFound, @@ -4579,7 +4583,7 @@ public class LinkPSNIdRequest : PlayFabRequestCommon public string PlayFabId ; /// - /// Id of the PlayStation :tm: Network user. + /// Id of the PlayStation :tm: Network user. Also known as the PSN Account Id. /// public string PSNUserId ; diff --git a/XamarinTestRunner/XamarinTestRunner/PlayFabSDK/PlayFabSettings.cs b/XamarinTestRunner/XamarinTestRunner/PlayFabSDK/PlayFabSettings.cs index ecc0b7ba..e57ca1a3 100644 --- a/XamarinTestRunner/XamarinTestRunner/PlayFabSDK/PlayFabSettings.cs +++ b/XamarinTestRunner/XamarinTestRunner/PlayFabSDK/PlayFabSettings.cs @@ -6,9 +6,9 @@ namespace PlayFab { public class PlayFabSettings { - public const string SdkVersion = "1.184.240719"; + public const string SdkVersion = "1.185.240802"; public const string BuildIdentifier = "adobuild_csharpsdk_114"; - public const string SdkVersionString = "CSharpSDK-1.184.240719"; + public const string SdkVersionString = "CSharpSDK-1.185.240802"; /// This is only for customers running a private cluster. Generally you shouldn't touch this public static string DefaultProductionEnvironmentUrl = "playfabapi.com";