#if !DISABLE_PLAYFABENTITY_API && !DISABLE_PLAYFAB_STATIC_API using System; using System.Collections.Generic; using PlayFab.ProfilesModels; using PlayFab.Internal; namespace PlayFab { /// /// All PlayFab entities have profiles, which hold top-level properties about the entity. These APIs give you the tools /// needed to manage entity profiles. /// public static class PlayFabProfilesAPI { static PlayFabProfilesAPI() {} /// /// 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(); } /// /// Gets the global title access policy /// public static void GetGlobalPolicy(GetGlobalPolicyRequest request, Action resultCallback, Action errorCallback, object customData = null, Dictionary extraHeaders = null) { var context = (request == null ? null : request.AuthenticationContext) ?? PlayFabSettings.staticPlayer; var callSettings = PlayFabSettings.staticSettings; if (!context.IsEntityLoggedIn()) throw new PlayFabException(PlayFabExceptionCode.NotLoggedIn,"Must be logged in to call this method"); PlayFabHttp.MakeApiCall("/Profile/GetGlobalPolicy", request, AuthType.EntityToken, resultCallback, errorCallback, customData, extraHeaders, context, callSettings); } /// /// Retrieves the entity's profile. /// public static void GetProfile(GetEntityProfileRequest request, Action resultCallback, Action errorCallback, object customData = null, Dictionary extraHeaders = null) { var context = (request == null ? null : request.AuthenticationContext) ?? PlayFabSettings.staticPlayer; var callSettings = PlayFabSettings.staticSettings; if (!context.IsEntityLoggedIn()) throw new PlayFabException(PlayFabExceptionCode.NotLoggedIn,"Must be logged in to call this method"); PlayFabHttp.MakeApiCall("/Profile/GetProfile", request, AuthType.EntityToken, resultCallback, errorCallback, customData, extraHeaders, context, callSettings); } /// /// Retrieves the entity's profile. /// public static void GetProfiles(GetEntityProfilesRequest request, Action resultCallback, Action errorCallback, object customData = null, Dictionary extraHeaders = null) { var context = (request == null ? null : request.AuthenticationContext) ?? PlayFabSettings.staticPlayer; var callSettings = PlayFabSettings.staticSettings; if (!context.IsEntityLoggedIn()) throw new PlayFabException(PlayFabExceptionCode.NotLoggedIn,"Must be logged in to call this method"); PlayFabHttp.MakeApiCall("/Profile/GetProfiles", request, AuthType.EntityToken, resultCallback, errorCallback, customData, extraHeaders, context, callSettings); } /// /// Retrieves the title player accounts associated with the given master player account. /// public static void GetTitlePlayersFromMasterPlayerAccountIds(GetTitlePlayersFromMasterPlayerAccountIdsRequest request, Action resultCallback, Action errorCallback, object customData = null, Dictionary extraHeaders = null) { var context = (request == null ? null : request.AuthenticationContext) ?? PlayFabSettings.staticPlayer; var callSettings = PlayFabSettings.staticSettings; if (!context.IsEntityLoggedIn()) throw new PlayFabException(PlayFabExceptionCode.NotLoggedIn,"Must be logged in to call this method"); PlayFabHttp.MakeApiCall("/Profile/GetTitlePlayersFromMasterPlayerAccountIds", request, AuthType.EntityToken, resultCallback, errorCallback, customData, extraHeaders, context, callSettings); } /// /// Retrieves the title player accounts associated with the given XUIDs. /// public static void GetTitlePlayersFromXboxLiveIDs(GetTitlePlayersFromXboxLiveIDsRequest request, Action resultCallback, Action errorCallback, object customData = null, Dictionary extraHeaders = null) { var context = (request == null ? null : request.AuthenticationContext) ?? PlayFabSettings.staticPlayer; var callSettings = PlayFabSettings.staticSettings; if (!context.IsEntityLoggedIn()) throw new PlayFabException(PlayFabExceptionCode.NotLoggedIn,"Must be logged in to call this method"); PlayFabHttp.MakeApiCall("/Profile/GetTitlePlayersFromXboxLiveIDs", request, AuthType.EntityToken, resultCallback, errorCallback, customData, extraHeaders, context, callSettings); } /// /// Update the display name of the entity /// public static void SetDisplayName(SetDisplayNameRequest request, Action resultCallback, Action errorCallback, object customData = null, Dictionary extraHeaders = null) { var context = (request == null ? null : request.AuthenticationContext) ?? PlayFabSettings.staticPlayer; var callSettings = PlayFabSettings.staticSettings; if (!context.IsEntityLoggedIn()) throw new PlayFabException(PlayFabExceptionCode.NotLoggedIn,"Must be logged in to call this method"); PlayFabHttp.MakeApiCall("/Profile/SetDisplayName", request, AuthType.EntityToken, resultCallback, errorCallback, customData, extraHeaders, context, callSettings); } /// /// Sets the global title access policy /// public static void SetGlobalPolicy(SetGlobalPolicyRequest request, Action resultCallback, Action errorCallback, object customData = null, Dictionary extraHeaders = null) { var context = (request == null ? null : request.AuthenticationContext) ?? PlayFabSettings.staticPlayer; var callSettings = PlayFabSettings.staticSettings; if (!context.IsEntityLoggedIn()) throw new PlayFabException(PlayFabExceptionCode.NotLoggedIn,"Must be logged in to call this method"); PlayFabHttp.MakeApiCall("/Profile/SetGlobalPolicy", request, AuthType.EntityToken, resultCallback, errorCallback, customData, extraHeaders, context, callSettings); } /// /// Updates the entity's language. The precedence hierarchy for communication to the player is Title Player Account /// language, Master Player Account language, and then title default language if the first two aren't set or supported. /// public static void SetProfileLanguage(SetProfileLanguageRequest request, Action resultCallback, Action errorCallback, object customData = null, Dictionary extraHeaders = null) { var context = (request == null ? null : request.AuthenticationContext) ?? PlayFabSettings.staticPlayer; var callSettings = PlayFabSettings.staticSettings; if (!context.IsEntityLoggedIn()) throw new PlayFabException(PlayFabExceptionCode.NotLoggedIn,"Must be logged in to call this method"); PlayFabHttp.MakeApiCall("/Profile/SetProfileLanguage", request, AuthType.EntityToken, resultCallback, errorCallback, customData, extraHeaders, context, callSettings); } /// /// Sets the profiles access policy /// public static void SetProfilePolicy(SetEntityProfilePolicyRequest request, Action resultCallback, Action errorCallback, object customData = null, Dictionary extraHeaders = null) { var context = (request == null ? null : request.AuthenticationContext) ?? PlayFabSettings.staticPlayer; var callSettings = PlayFabSettings.staticSettings; if (!context.IsEntityLoggedIn()) throw new PlayFabException(PlayFabExceptionCode.NotLoggedIn,"Must be logged in to call this method"); PlayFabHttp.MakeApiCall("/Profile/SetProfilePolicy", request, AuthType.EntityToken, resultCallback, errorCallback, customData, extraHeaders, context, callSettings); } } } #endif