#if !DISABLE_PLAYFABENTITY_API using System; using System.Collections.Generic; using PlayFab.LocalizationModels; using PlayFab.Internal; using PlayFab.SharedModels; namespace PlayFab { /// /// The Localization APIs give you the tools needed to manage language setup in your title. /// public class PlayFabLocalizationInstanceAPI : IPlayFabInstanceApi { public readonly PlayFabApiSettings apiSettings = null; public readonly PlayFabAuthenticationContext authenticationContext = null; public PlayFabLocalizationInstanceAPI(PlayFabAuthenticationContext context) { if (context == null) throw new PlayFabException(PlayFabExceptionCode.AuthContextRequired, "Context cannot be null, create a PlayFabAuthenticationContext for each player in advance, or call .GetAuthenticationContext()"); authenticationContext = context; } public PlayFabLocalizationInstanceAPI(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 .GetAuthenticationContext()"); 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() { if (authenticationContext != null) { authenticationContext.ForgetAllCredentials(); } } /// /// Retrieves the list of allowed languages, only accessible by title entities /// public void GetLanguageList(GetLanguageListRequest request, Action resultCallback, Action errorCallback, object customData = null, Dictionary 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("/Locale/GetLanguageList", request, AuthType.EntityToken, resultCallback, errorCallback, customData, extraHeaders, context, callSettings, this); } } } #endif