You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
290 lines
21 KiB
C#
290 lines
21 KiB
C#
1 week ago
|
#if !DISABLE_PLAYFABENTITY_API
|
||
|
|
||
|
using System;
|
||
|
using System.Collections.Generic;
|
||
|
using PlayFab.ProgressionModels;
|
||
|
using PlayFab.Internal;
|
||
|
using PlayFab.SharedModels;
|
||
|
|
||
|
namespace PlayFab
|
||
|
{
|
||
|
/// <summary>
|
||
|
/// Manage entity statistics Manage entity leaderboards
|
||
|
/// </summary>
|
||
|
public class PlayFabProgressionInstanceAPI : IPlayFabInstanceApi
|
||
|
{
|
||
|
public readonly PlayFabApiSettings apiSettings = null;
|
||
|
public readonly PlayFabAuthenticationContext authenticationContext = null;
|
||
|
|
||
|
public PlayFabProgressionInstanceAPI(PlayFabAuthenticationContext context)
|
||
|
{
|
||
|
if (context == null)
|
||
|
throw new PlayFabException(PlayFabExceptionCode.AuthContextRequired, "Context cannot be null, create a PlayFabAuthenticationContext for each player in advance, or call <PlayFabClientInstanceAPI>.GetAuthenticationContext()");
|
||
|
authenticationContext = context;
|
||
|
}
|
||
|
|
||
|
public PlayFabProgressionInstanceAPI(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 call <PlayFabClientInstanceAPI>.GetAuthenticationContext()");
|
||
|
apiSettings = settings;
|
||
|
authenticationContext = context;
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// Verify entity login.
|
||
|
/// </summary>
|
||
|
public bool IsEntityLoggedIn()
|
||
|
{
|
||
|
return authenticationContext == null ? false : authenticationContext.IsEntityLoggedIn();
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// Clear the Client SessionToken which allows this Client to call API calls requiring login.
|
||
|
/// A new/fresh login will be required after calling this.
|
||
|
/// </summary>
|
||
|
public void ForgetAllCredentials()
|
||
|
{
|
||
|
if (authenticationContext != null)
|
||
|
{
|
||
|
authenticationContext.ForgetAllCredentials();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// Creates a new leaderboard definition.
|
||
|
/// </summary>
|
||
|
public void CreateLeaderboardDefinition(CreateLeaderboardDefinitionRequest request, Action<EmptyResponse> resultCallback, Action<PlayFabError> errorCallback, object customData = null, Dictionary<string, string> extraHeaders = null)
|
||
|
{
|
||
|
var context = (request == null ? null : request.AuthenticationContext) ?? authenticationContext;
|
||
|
var callSettings = apiSettings ?? PlayFabSettings.staticSettings;
|
||
|
if (!context.IsEntityLoggedIn()) throw new PlayFabException(PlayFabExceptionCode.NotLoggedIn,"Must be logged in to call this method");
|
||
|
PlayFabHttp.MakeApiCall("/Leaderboard/CreateLeaderboardDefinition", request, AuthType.EntityToken, resultCallback, errorCallback, customData, extraHeaders, context, callSettings, this);
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// Create a new entity statistic definition.
|
||
|
/// </summary>
|
||
|
public void CreateStatisticDefinition(CreateStatisticDefinitionRequest request, Action<EmptyResponse> resultCallback, Action<PlayFabError> errorCallback, object customData = null, Dictionary<string, string> extraHeaders = null)
|
||
|
{
|
||
|
var context = (request == null ? null : request.AuthenticationContext) ?? authenticationContext;
|
||
|
var callSettings = apiSettings ?? PlayFabSettings.staticSettings;
|
||
|
if (!context.IsEntityLoggedIn()) throw new PlayFabException(PlayFabExceptionCode.NotLoggedIn,"Must be logged in to call this method");
|
||
|
PlayFabHttp.MakeApiCall("/Statistic/CreateStatisticDefinition", request, AuthType.EntityToken, resultCallback, errorCallback, customData, extraHeaders, context, callSettings, this);
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// Deletes a leaderboard definition.
|
||
|
/// </summary>
|
||
|
public void DeleteLeaderboardDefinition(DeleteLeaderboardDefinitionRequest request, Action<EmptyResponse> resultCallback, Action<PlayFabError> errorCallback, object customData = null, Dictionary<string, string> extraHeaders = null)
|
||
|
{
|
||
|
var context = (request == null ? null : request.AuthenticationContext) ?? authenticationContext;
|
||
|
var callSettings = apiSettings ?? PlayFabSettings.staticSettings;
|
||
|
if (!context.IsEntityLoggedIn()) throw new PlayFabException(PlayFabExceptionCode.NotLoggedIn,"Must be logged in to call this method");
|
||
|
PlayFabHttp.MakeApiCall("/Leaderboard/DeleteLeaderboardDefinition", request, AuthType.EntityToken, resultCallback, errorCallback, customData, extraHeaders, context, callSettings, this);
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// Deletes the specified entries from the given leaderboard.
|
||
|
/// </summary>
|
||
|
public void DeleteLeaderboardEntries(DeleteLeaderboardEntriesRequest request, Action<EmptyResponse> resultCallback, Action<PlayFabError> errorCallback, object customData = null, Dictionary<string, string> extraHeaders = null)
|
||
|
{
|
||
|
var context = (request == null ? null : request.AuthenticationContext) ?? authenticationContext;
|
||
|
var callSettings = apiSettings ?? PlayFabSettings.staticSettings;
|
||
|
if (!context.IsEntityLoggedIn()) throw new PlayFabException(PlayFabExceptionCode.NotLoggedIn,"Must be logged in to call this method");
|
||
|
PlayFabHttp.MakeApiCall("/Leaderboard/DeleteLeaderboardEntries", request, AuthType.EntityToken, resultCallback, errorCallback, customData, extraHeaders, context, callSettings, this);
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// Delete an entity statistic definition. Will delete all statistics on entity profiles and leaderboards.
|
||
|
/// </summary>
|
||
|
public void DeleteStatisticDefinition(DeleteStatisticDefinitionRequest request, Action<EmptyResponse> resultCallback, Action<PlayFabError> errorCallback, object customData = null, Dictionary<string, string> extraHeaders = null)
|
||
|
{
|
||
|
var context = (request == null ? null : request.AuthenticationContext) ?? authenticationContext;
|
||
|
var callSettings = apiSettings ?? PlayFabSettings.staticSettings;
|
||
|
if (!context.IsEntityLoggedIn()) throw new PlayFabException(PlayFabExceptionCode.NotLoggedIn,"Must be logged in to call this method");
|
||
|
PlayFabHttp.MakeApiCall("/Statistic/DeleteStatisticDefinition", request, AuthType.EntityToken, resultCallback, errorCallback, customData, extraHeaders, context, callSettings, this);
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// Delete statistics on an entity profile. This will remove all rankings from associated leaderboards.
|
||
|
/// </summary>
|
||
|
public void DeleteStatistics(DeleteStatisticsRequest request, Action<DeleteStatisticsResponse> resultCallback, Action<PlayFabError> errorCallback, object customData = null, Dictionary<string, string> extraHeaders = null)
|
||
|
{
|
||
|
var context = (request == null ? null : request.AuthenticationContext) ?? authenticationContext;
|
||
|
var callSettings = apiSettings ?? PlayFabSettings.staticSettings;
|
||
|
if (!context.IsEntityLoggedIn()) throw new PlayFabException(PlayFabExceptionCode.NotLoggedIn,"Must be logged in to call this method");
|
||
|
PlayFabHttp.MakeApiCall("/Statistic/DeleteStatistics", request, AuthType.EntityToken, resultCallback, errorCallback, customData, extraHeaders, context, callSettings, this);
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// Get the friend leaderboard for the specified entity. A maximum of 25 friend entries are listed in the leaderboard.
|
||
|
/// </summary>
|
||
|
public void GetFriendLeaderboardForEntity(GetFriendLeaderboardForEntityRequest request, Action<GetEntityLeaderboardResponse> resultCallback, Action<PlayFabError> errorCallback, object customData = null, Dictionary<string, string> extraHeaders = null)
|
||
|
{
|
||
|
var context = (request == null ? null : request.AuthenticationContext) ?? authenticationContext;
|
||
|
var callSettings = apiSettings ?? PlayFabSettings.staticSettings;
|
||
|
if (!context.IsEntityLoggedIn()) throw new PlayFabException(PlayFabExceptionCode.NotLoggedIn,"Must be logged in to call this method");
|
||
|
PlayFabHttp.MakeApiCall("/Leaderboard/GetFriendLeaderboardForEntity", request, AuthType.EntityToken, resultCallback, errorCallback, customData, extraHeaders, context, callSettings, this);
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// Get the leaderboard for a specific entity type and statistic.
|
||
|
/// </summary>
|
||
|
public void GetLeaderboard(GetEntityLeaderboardRequest request, Action<GetEntityLeaderboardResponse> resultCallback, Action<PlayFabError> errorCallback, object customData = null, Dictionary<string, string> extraHeaders = null)
|
||
|
{
|
||
|
var context = (request == null ? null : request.AuthenticationContext) ?? authenticationContext;
|
||
|
var callSettings = apiSettings ?? PlayFabSettings.staticSettings;
|
||
|
if (!context.IsEntityLoggedIn()) throw new PlayFabException(PlayFabExceptionCode.NotLoggedIn,"Must be logged in to call this method");
|
||
|
PlayFabHttp.MakeApiCall("/Leaderboard/GetLeaderboard", request, AuthType.EntityToken, resultCallback, errorCallback, customData, extraHeaders, context, callSettings, this);
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// Get the leaderboard around a specific entity.
|
||
|
/// </summary>
|
||
|
public void GetLeaderboardAroundEntity(GetLeaderboardAroundEntityRequest request, Action<GetEntityLeaderboardResponse> resultCallback, Action<PlayFabError> errorCallback, object customData = null, Dictionary<string, string> extraHeaders = null)
|
||
|
{
|
||
|
var context = (request == null ? null : request.AuthenticationContext) ?? authenticationContext;
|
||
|
var callSettings = apiSettings ?? PlayFabSettings.staticSettings;
|
||
|
if (!context.IsEntityLoggedIn()) throw new PlayFabException(PlayFabExceptionCode.NotLoggedIn,"Must be logged in to call this method");
|
||
|
PlayFabHttp.MakeApiCall("/Leaderboard/GetLeaderboardAroundEntity", request, AuthType.EntityToken, resultCallback, errorCallback, customData, extraHeaders, context, callSettings, this);
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// Gets the specified leaderboard definition.
|
||
|
/// </summary>
|
||
|
public void GetLeaderboardDefinition(GetLeaderboardDefinitionRequest request, Action<GetLeaderboardDefinitionResponse> resultCallback, Action<PlayFabError> errorCallback, object customData = null, Dictionary<string, string> extraHeaders = null)
|
||
|
{
|
||
|
var context = (request == null ? null : request.AuthenticationContext) ?? authenticationContext;
|
||
|
var callSettings = apiSettings ?? PlayFabSettings.staticSettings;
|
||
|
if (!context.IsEntityLoggedIn()) throw new PlayFabException(PlayFabExceptionCode.NotLoggedIn,"Must be logged in to call this method");
|
||
|
PlayFabHttp.MakeApiCall("/Leaderboard/GetLeaderboardDefinition", request, AuthType.EntityToken, resultCallback, errorCallback, customData, extraHeaders, context, callSettings, this);
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// Get the leaderboard limited to a set of entities.
|
||
|
/// </summary>
|
||
|
public void GetLeaderboardForEntities(GetLeaderboardForEntitiesRequest request, Action<GetEntityLeaderboardResponse> resultCallback, Action<PlayFabError> errorCallback, object customData = null, Dictionary<string, string> extraHeaders = null)
|
||
|
{
|
||
|
var context = (request == null ? null : request.AuthenticationContext) ?? authenticationContext;
|
||
|
var callSettings = apiSettings ?? PlayFabSettings.staticSettings;
|
||
|
if (!context.IsEntityLoggedIn()) throw new PlayFabException(PlayFabExceptionCode.NotLoggedIn,"Must be logged in to call this method");
|
||
|
PlayFabHttp.MakeApiCall("/Leaderboard/GetLeaderboardForEntities", request, AuthType.EntityToken, resultCallback, errorCallback, customData, extraHeaders, context, callSettings, this);
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// Get current statistic definition information
|
||
|
/// </summary>
|
||
|
public void GetStatisticDefinition(GetStatisticDefinitionRequest request, Action<GetStatisticDefinitionResponse> resultCallback, Action<PlayFabError> errorCallback, object customData = null, Dictionary<string, string> extraHeaders = null)
|
||
|
{
|
||
|
var context = (request == null ? null : request.AuthenticationContext) ?? authenticationContext;
|
||
|
var callSettings = apiSettings ?? PlayFabSettings.staticSettings;
|
||
|
if (!context.IsEntityLoggedIn()) throw new PlayFabException(PlayFabExceptionCode.NotLoggedIn,"Must be logged in to call this method");
|
||
|
PlayFabHttp.MakeApiCall("/Statistic/GetStatisticDefinition", request, AuthType.EntityToken, resultCallback, errorCallback, customData, extraHeaders, context, callSettings, this);
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// Gets statistics for the specified entity.
|
||
|
/// </summary>
|
||
|
public void GetStatistics(GetStatisticsRequest request, Action<GetStatisticsResponse> resultCallback, Action<PlayFabError> errorCallback, object customData = null, Dictionary<string, string> extraHeaders = null)
|
||
|
{
|
||
|
var context = (request == null ? null : request.AuthenticationContext) ?? authenticationContext;
|
||
|
var callSettings = apiSettings ?? PlayFabSettings.staticSettings;
|
||
|
if (!context.IsEntityLoggedIn()) throw new PlayFabException(PlayFabExceptionCode.NotLoggedIn,"Must be logged in to call this method");
|
||
|
PlayFabHttp.MakeApiCall("/Statistic/GetStatistics", request, AuthType.EntityToken, resultCallback, errorCallback, customData, extraHeaders, context, callSettings, this);
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// Gets statistics for the specified collection of entities.
|
||
|
/// </summary>
|
||
|
public void GetStatisticsForEntities(GetStatisticsForEntitiesRequest request, Action<GetStatisticsForEntitiesResponse> resultCallback, Action<PlayFabError> errorCallback, object customData = null, Dictionary<string, string> extraHeaders = null)
|
||
|
{
|
||
|
var context = (request == null ? null : request.AuthenticationContext) ?? authenticationContext;
|
||
|
var callSettings = apiSettings ?? PlayFabSettings.staticSettings;
|
||
|
if (!context.IsEntityLoggedIn()) throw new PlayFabException(PlayFabExceptionCode.NotLoggedIn,"Must be logged in to call this method");
|
||
|
PlayFabHttp.MakeApiCall("/Statistic/GetStatisticsForEntities", request, AuthType.EntityToken, resultCallback, errorCallback, customData, extraHeaders, context, callSettings, this);
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// Increment a leaderboard version.
|
||
|
/// </summary>
|
||
|
public void IncrementLeaderboardVersion(IncrementLeaderboardVersionRequest request, Action<IncrementLeaderboardVersionResponse> resultCallback, Action<PlayFabError> errorCallback, object customData = null, Dictionary<string, string> extraHeaders = null)
|
||
|
{
|
||
|
var context = (request == null ? null : request.AuthenticationContext) ?? authenticationContext;
|
||
|
var callSettings = apiSettings ?? PlayFabSettings.staticSettings;
|
||
|
if (!context.IsEntityLoggedIn()) throw new PlayFabException(PlayFabExceptionCode.NotLoggedIn,"Must be logged in to call this method");
|
||
|
PlayFabHttp.MakeApiCall("/Leaderboard/IncrementLeaderboardVersion", request, AuthType.EntityToken, resultCallback, errorCallback, customData, extraHeaders, context, callSettings, this);
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// Increment an entity statistic definition version.
|
||
|
/// </summary>
|
||
|
public void IncrementStatisticVersion(IncrementStatisticVersionRequest request, Action<IncrementStatisticVersionResponse> resultCallback, Action<PlayFabError> errorCallback, object customData = null, Dictionary<string, string> extraHeaders = null)
|
||
|
{
|
||
|
var context = (request == null ? null : request.AuthenticationContext) ?? authenticationContext;
|
||
|
var callSettings = apiSettings ?? PlayFabSettings.staticSettings;
|
||
|
if (!context.IsEntityLoggedIn()) throw new PlayFabException(PlayFabExceptionCode.NotLoggedIn,"Must be logged in to call this method");
|
||
|
PlayFabHttp.MakeApiCall("/Statistic/IncrementStatisticVersion", request, AuthType.EntityToken, resultCallback, errorCallback, customData, extraHeaders, context, callSettings, this);
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// Lists the leaderboard definitions defined for the Title.
|
||
|
/// </summary>
|
||
|
public void ListLeaderboardDefinitions(ListLeaderboardDefinitionsRequest request, Action<ListLeaderboardDefinitionsResponse> resultCallback, Action<PlayFabError> errorCallback, object customData = null, Dictionary<string, string> extraHeaders = null)
|
||
|
{
|
||
|
var context = (request == null ? null : request.AuthenticationContext) ?? authenticationContext;
|
||
|
var callSettings = apiSettings ?? PlayFabSettings.staticSettings;
|
||
|
if (!context.IsEntityLoggedIn()) throw new PlayFabException(PlayFabExceptionCode.NotLoggedIn,"Must be logged in to call this method");
|
||
|
PlayFabHttp.MakeApiCall("/Leaderboard/ListLeaderboardDefinitions", request, AuthType.EntityToken, resultCallback, errorCallback, customData, extraHeaders, context, callSettings, this);
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// Get all current statistic definitions information
|
||
|
/// </summary>
|
||
|
public void ListStatisticDefinitions(ListStatisticDefinitionsRequest request, Action<ListStatisticDefinitionsResponse> resultCallback, Action<PlayFabError> errorCallback, object customData = null, Dictionary<string, string> extraHeaders = null)
|
||
|
{
|
||
|
var context = (request == null ? null : request.AuthenticationContext) ?? authenticationContext;
|
||
|
var callSettings = apiSettings ?? PlayFabSettings.staticSettings;
|
||
|
if (!context.IsEntityLoggedIn()) throw new PlayFabException(PlayFabExceptionCode.NotLoggedIn,"Must be logged in to call this method");
|
||
|
PlayFabHttp.MakeApiCall("/Statistic/ListStatisticDefinitions", request, AuthType.EntityToken, resultCallback, errorCallback, customData, extraHeaders, context, callSettings, this);
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// Unlinks a leaderboard definition from it's linked statistic definition.
|
||
|
/// </summary>
|
||
|
public void UnlinkLeaderboardFromStatistic(UnlinkLeaderboardFromStatisticRequest request, Action<EmptyResponse> resultCallback, Action<PlayFabError> errorCallback, object customData = null, Dictionary<string, string> extraHeaders = null)
|
||
|
{
|
||
|
var context = (request == null ? null : request.AuthenticationContext) ?? authenticationContext;
|
||
|
var callSettings = apiSettings ?? PlayFabSettings.staticSettings;
|
||
|
if (!context.IsEntityLoggedIn()) throw new PlayFabException(PlayFabExceptionCode.NotLoggedIn,"Must be logged in to call this method");
|
||
|
PlayFabHttp.MakeApiCall("/Leaderboard/UnlinkLeaderboardFromStatistic", request, AuthType.EntityToken, resultCallback, errorCallback, customData, extraHeaders, context, callSettings, this);
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// Adds or updates entries on the specified leaderboard.
|
||
|
/// </summary>
|
||
|
public void UpdateLeaderboardEntries(UpdateLeaderboardEntriesRequest request, Action<EmptyResponse> resultCallback, Action<PlayFabError> errorCallback, object customData = null, Dictionary<string, string> extraHeaders = null)
|
||
|
{
|
||
|
var context = (request == null ? null : request.AuthenticationContext) ?? authenticationContext;
|
||
|
var callSettings = apiSettings ?? PlayFabSettings.staticSettings;
|
||
|
if (!context.IsEntityLoggedIn()) throw new PlayFabException(PlayFabExceptionCode.NotLoggedIn,"Must be logged in to call this method");
|
||
|
PlayFabHttp.MakeApiCall("/Leaderboard/UpdateLeaderboardEntries", request, AuthType.EntityToken, resultCallback, errorCallback, customData, extraHeaders, context, callSettings, this);
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// Update statistics on an entity profile. Depending on the statistic definition, this may result in entity being ranked on
|
||
|
/// various leaderboards.
|
||
|
/// </summary>
|
||
|
public void UpdateStatistics(UpdateStatisticsRequest request, Action<UpdateStatisticsResponse> resultCallback, Action<PlayFabError> errorCallback, object customData = null, Dictionary<string, string> extraHeaders = null)
|
||
|
{
|
||
|
var context = (request == null ? null : request.AuthenticationContext) ?? authenticationContext;
|
||
|
var callSettings = apiSettings ?? PlayFabSettings.staticSettings;
|
||
|
if (!context.IsEntityLoggedIn()) throw new PlayFabException(PlayFabExceptionCode.NotLoggedIn,"Must be logged in to call this method");
|
||
|
PlayFabHttp.MakeApiCall("/Statistic/UpdateStatistics", request, AuthType.EntityToken, resultCallback, errorCallback, customData, extraHeaders, context, callSettings, this);
|
||
|
}
|
||
|
|
||
|
}
|
||
|
}
|
||
|
|
||
|
#endif
|