/// <summary> /// Retrieves the specified version of the title's catalog of virtual goods, including all defined properties /// </summary> public static async Task<PlayFabResult<GetCatalogItemsResult>> GetCatalogItemsAsync(GetCatalogItemsRequest request) { if (AuthKey == null) throw new Exception ("Must be logged in to call this method"); object httpResult = await PlayFabHTTP.DoPost(PlayFabSettings.GetURL() + "/Client/GetCatalogItems", request, "X-Authorization", AuthKey); if(httpResult is PlayFabError) { PlayFabError error = (PlayFabError)httpResult; if (PlayFabSettings.GlobalErrorHandler != null) PlayFabSettings.GlobalErrorHandler(error); return new PlayFabResult<GetCatalogItemsResult> { Error = error, }; } string resultRawJson = (string)httpResult; var serializer = JsonSerializer.Create(PlayFabSettings.JsonSettings); var resultData = serializer.Deserialize<PlayFabJsonSuccess<GetCatalogItemsResult>>(new JsonTextReader(new StringReader(resultRawJson))); GetCatalogItemsResult result = resultData.data; return new PlayFabResult<GetCatalogItemsResult> { Result = result }; }
private void GetDataFromPlayFab(Action callback) { var catalogRequest = new GetCatalogItemsRequest() { CatalogVersion = "ItemCatalog" }; PlayFabClientAPI.GetCatalogItems(catalogRequest, (catResult) => { PlayFabDataStore.Catalog = catResult.Catalog; var storeRequest = new GetStoreItemsRequest() { CatalogVersion = "ItemCatalog", StoreId = "ResizerItems" }; PlayFabClientAPI.GetStoreItems(storeRequest, (storeResult) => { PlayFabDataStore.Store = storeResult.Store; callback(); }, PlayFabErrorHandler.HandlePlayFabError); }, PlayFabErrorHandler.HandlePlayFabError); }
private void Start () { //// /// Get's the specified version of the title's catalog of virtual goods, including purchase options and pricing details /// associated with the game title and catalog verion set in Playfab / Developer settings //// icons = new Dictionary<string,Texture2D> (); icons.Add ("health", health); icons.Add ("gun2", gun2); icons.Add ("gun3", gun3); icons.Add ("crate", crate); GetCatalogItemsRequest request = new GetCatalogItemsRequest(); request.CatalogVersion = PlayFabData.CatalogVersion; if (PlayFabData.AuthKey != null) PlayFabClientAPI.GetCatalogItems (request,ConstructCatalog,OnPlayFabError); //Time.timeScale = 0; }
public static List <Recipe> GetMinigameRecipes() { List <Recipe> toRet = new List <Recipe>(); PlayFab.ClientModels.GetCatalogItemsRequest itemRequest = new PlayFab.ClientModels.GetCatalogItemsRequest(); itemRequest.CatalogVersion = "Items"; PlayFabClientAPI.GetCatalogItems(itemRequest, result => { List <PlayFab.ClientModels.CatalogItem> items = result.Catalog; foreach (PlayFab.ClientModels.CatalogItem i in items) { if (i.ItemClass == "Recipe") { if (i.ItemId == "carrotSalad" || i.ItemId == "beefAndChicken" || i.ItemId == "carrotSoup") { toRet.Add(new Recipe(i)); Debug.Log(i.ItemId); } } } }, error => {} ); return(toRet); }
public void TestCallbackFailures() { PlayFabSettings.HideCallbackErrors = true; // Just need any valid auth token for this test LoginWithCustomIDRequest loginRequest = new LoginWithCustomIDRequest(); loginRequest.CreateAccount = true; loginRequest.CustomId = SystemInfo.deviceUniqueIdentifier; PlayFabClientAPI.LoginWithCustomID(loginRequest, null, null); WaitForApiCalls(); PlayFabSettings.RegisterForResponses(null, (PlayFabSettings.ResponseCallback<object, PlayFabResultCommon>)SuccessCallback_Global); PlayFabSettings.GlobalErrorHandler += SharedError_Global; callbacks.Clear(); GetCatalogItemsRequest catalogRequest = new GetCatalogItemsRequest(); PlayFabClientAPI.GetCatalogItems(catalogRequest, GetCatalogItemsCallback_Single, SharedError_Single); WaitForApiCalls(); UUnitAssert.True(callbacks.Contains("GetCatalogItemsCallback_Single"), "GetCatalogItemsCallback_Single"); // All success callbacks should occur, even if some throw exceptions UUnitAssert.True(callbacks.Contains("SuccessCallback_Global"), "SuccessCallback_Global"); // All success callbacks should occur, even if some throw exceptions UUnitAssert.False(callbacks.Contains("SharedError_Single"), "SharedError_Single"); // Successful calls should not invoke error-callbacks (even when callbacks throw exceptions) UUnitAssert.False(callbacks.Contains("SharedError_Global"), "SharedError_Global"); // Successful calls should not invoke error-callbacks (even when callbacks throw exceptions) UUnitAssert.IntEquals(2, callbacks.Count); callbacks.Clear(); RegisterPlayFabUserRequest registerRequest = new RegisterPlayFabUserRequest(); PlayFabClientAPI.RegisterPlayFabUser(registerRequest, RegisterPlayFabUserCallback_Single, SharedError_Single); WaitForApiCalls(); UUnitAssert.False(callbacks.Contains("GetCatalogItemsCallback_Single"), "GetCatalogItemsCallback_Single"); // Success should not have occurred UUnitAssert.False(callbacks.Contains("SuccessCallback_Global"), "SuccessCallback_Global"); // Success should not have occurred UUnitAssert.True(callbacks.Contains("SharedError_Single"), "SharedError_Single"); // All error callbacks should occur, even if some throw exceptions UUnitAssert.True(callbacks.Contains("SharedError_Global"), "SharedError_Global"); // All error callbacks should occur, even if some throw exceptions UUnitAssert.IntEquals(2, callbacks.Count); callbacks.Clear(); PlayFabSettings.HideCallbackErrors = false; PlayFabSettings.ForceUnregisterAll(); }
/// <summary> /// Retrieves the specified version of the title's catalog of virtual goods, including all defined properties /// </summary> public static void GetCatalogItems(GetCatalogItemsRequest request, GetCatalogItemsCallback resultCallback, ErrorCallback errorCallback) { if (AuthKey == null) throw new Exception ("Must be logged in to call this method"); string serializedJSON = JsonConvert.SerializeObject(request, Util.JsonFormatting, Util.JsonSettings); Action<string,string> callback = delegate(string responseStr, string errorStr) { GetCatalogItemsResult result = null; PlayFabError error = null; ResultContainer<GetCatalogItemsResult>.HandleResults(responseStr, errorStr, out result, out error); if(error != null && errorCallback != null) { errorCallback(error); } if(result != null) { if(resultCallback != null) { resultCallback(result); } } }; PlayFabHTTP.Post(PlayFabSettings.GetURL()+"/Client/GetCatalogItems", serializedJSON, "X-Authorization", AuthKey, callback); }
/// <summary> /// Retrieves the specified version of the title's catalog of virtual goods, including all defined properties /// </summary> public static void GetCatalogItems(GetCatalogItemsRequest request, ProcessApiCallback<GetCatalogItemsResult> resultCallback, ErrorCallback errorCallback, object customData = null) { if (_authKey == null) throw new Exception("Must be logged in to call this method"); string serializedJson = SimpleJson.SerializeObject(request, Util.ApiSerializerStrategy); Action<CallRequestContainer> callback = delegate(CallRequestContainer requestContainer) { ResultContainer<GetCatalogItemsResult>.HandleResults(requestContainer, resultCallback, errorCallback, null); }; PlayFabHTTP.Post("/Client/GetCatalogItems", serializedJson, "X-Authorization", _authKey, callback, request, customData); }
//Gets all the quests in the game and stores them public static void GetCatalogQuests() { var request = new GetCatalogItemsRequest() { }; PlayFabClientAPI.GetCatalogItems(request, (result) => { foreach (var item in result.Catalog) { if (item.ItemClass == "Quest") { string[] customData = item.CustomData.Split('"'); PlayFabDataStore.catalogQuests.Add(item.ItemId, new CatalogQuest(item.ItemId, item.ItemClass, item.DisplayName, item.Description, customData[3], item.Bundle.BundledItems, item.Bundle.BundledVirtualCurrencies)); } } Debug.Log("Quests Retrieved"); }, (error) => { Debug.Log("Can't get Quests"); Debug.Log(error.ErrorMessage); Debug.Log(error.ErrorDetails); }); }
//Gets all the items in the game and stores them public static void GetCatalogItems() { var request = new GetCatalogItemsRequest() { }; PlayFabClientAPI.GetCatalogItems(request, (result) => { foreach (var item in result.Catalog) { if (item.ItemClass == "Item") { string[] customData = item.CustomData.Split('"'); PlayFabDataStore.catalogItems.Add(item.ItemId, new UIItemInfo(item.ItemId, item.DisplayName, customData[3], int.Parse(customData[7]), customData[11], int.Parse(customData[15]), int.Parse(customData[19]), int.Parse(customData[23]), int.Parse(customData[27]), int.Parse(customData[31]), int.Parse(customData[35]), int.Parse(customData[39]), int.Parse(customData[43]))); } } Debug.Log("Items are retrieved"); PlayFabUserLogin.playfabUserLogin.Authentication("AUTHENTICATING...", 1); }, (error) => { Debug.Log("Items can't retrieved!"); Debug.Log(error.ErrorMessage); Debug.Log(error.ErrorDetails); }); }
//Gets all the runes in the catalog and stores them public static void GetCatalogRunes() { var request = new GetCatalogItemsRequest() { }; PlayFabClientAPI.GetCatalogItems(request, (result) => { foreach (var item in result.Catalog) { if (item.ItemClass == "Skill" || item.ItemClass == "Modifier") { string[] customData = item.CustomData.Split('"'); PlayFabDataStore.catalogRunes.Add(item.ItemId, new CatalogRune(item.ItemId, item.ItemClass, item.DisplayName, item.Description, customData[3], int.Parse(customData[7]), int.Parse(customData[11]), int.Parse(customData[15]), int.Parse(customData[19]), int.Parse(customData[23]), int.Parse(customData[27]), int.Parse(customData[31]), int.Parse(customData[35]), float.Parse(customData[39]), float.Parse(customData[43]), customData[47].ToString())); } } Debug.Log("Catalog Retrieved"); }, (error) => { Debug.Log("Can't get Catalog Runes"); Debug.Log(error.ErrorMessage); Debug.Log(error.ErrorDetails); }); }
private void OnPfLoginComplete() { var charRequest = new ClientModels.ListUsersCharactersRequest(); PlayFabClientAPI.GetAllUsersCharacters(charRequest, CharCallBack, SharedFailCallback("GetAllUsersCharacters")); var catalogRequest = new ClientModels.GetCatalogItemsRequest(); PlayFabClientAPI.GetCatalogItems(catalogRequest, GetCatalogCallback, SharedFailCallback("GetCatalogItems")); }
public void TestCallbackFailuresGlobal(UUnitTestContext testContext) { PlayFabSettings.HideCallbackErrors = true; PlayFabSettings.RegisterForResponses(null, (PlayFabSettings.ResponseCallback<object, PlayFabResultCommon>)SuccessCallback_Global); GetCatalogItemsRequest catalogRequest = new GetCatalogItemsRequest(); PlayFabClientAPI.GetCatalogItems(catalogRequest, PlayFabUUnitUtils.ApiCallbackWrapper<GetCatalogItemsResult>(testContext, GetCatalogItemsCallback_Single), SharedErrorCallback, testContext); }
/// <summary> /// Sends request to PlayFab, to load the catalog. /// </summary> public void LoadAllCatalogItems() { GetCatalogItemsRequest request = new GetCatalogItemsRequest(); request.CatalogVersion = GameConstants.inGameStoreCatalogName; PlayFabClientAPI.GetCatalogItems(request, OnCatalogItemsLoaded, OnCatalogItemsError); }
/// <summary> /// Gets all catalog items. /// </summary> /// <param name="OnCatalogLoaded">Callback when completes.</param> public void GetAllCatalogItems(ProjectDelegates.PlayFabCatalogListCallback OnCatalogLoaded) { this.OnCatalogLoadedCallback = OnCatalogLoaded; if (catalogItems == null) { GetCatalogItemsRequest request = new GetCatalogItemsRequest(); request.CatalogVersion = "Test"; PlayFabClientAPI.GetCatalogItems(request, OnCatalogItemsLoaded, OnCatalogItemsError); } else { OnCatalogLoadedCallback(catalogItems); } }