public void TestBlueprintApiDefaultCredentialsConstructor() { var blueprintApi = BlueprintAPI.DefaultCredentials(); UserCredentials user = null; // Authenticate user Task.Run(async() => { APIResult <UserCredentials, JsonError> response = await blueprintApi.AsyncAuthenticateUser(validUser); user = response.GetSuccess(); }).GetAwaiter().GetResult(); Assert.That(user.GetUsername(), Is.EqualTo(validUser.GetUsername())); }
public void Start() { heldItem = GameObject.Find("HeldItem"); currentHeld = 0; inventoryContents = new InventoryItem[size]; itemSlots = GameObject.Find("GridPanel").GetComponentsInChildren <InventorySlotController>().ToList(); UserCredentials user = GameManager.Instance().GetUserCredentials(); GameManager.Instance().store.Subscribe(this); var blueprintApi = BlueprintAPI.DefaultCredentials(); Task.Run(async() => { APIResult <ResponseGetInventory, JsonError> finalInventoryResponse = await blueprintApi.AsyncGetInventory(user); if (finalInventoryResponse.isSuccess()) { remoteInv = finalInventoryResponse.GetSuccess(); } else { JsonError error = finalInventoryResponse.GetError(); } }).GetAwaiter().GetResult(); foreach (InventoryEntry entry in remoteInv.items) { GameManager.Instance().store.Dispatch( new AddItemToInventory(entry.item_id, entry.quantity, GetItemName(entry.item_id))); } /* * Task.Run(async () => { * try { * APIResult<Boolean, JsonError> response = await blueprintApi.AsyncDeleteInventory(user); * * // Success case * } catch (WebException e) { * // Failure case * throw new System.Exception("Did not delete inventory."); * } * }).GetAwaiter().GetResult();*/ foreach (Transform child in heldItem.transform) { if (child.gameObject.CompareTag("Held")) { child.gameObject.GetComponent <Text>().text = GetItemName(inventoryContents[currentHeld].GetId()); } } }
public static GameObjectsHandler WithRemoteSchema() { GameObjectsHandler goh = new GameObjectsHandler(); // Get schema BlueprintAPI api = BlueprintAPI.DefaultCredentials(); Task.Run(async() => { APIResult <string, JsonError> response = await api.AsyncGetItemSchema(); if (response.isSuccess()) { // Populate GameObjs goh.GameObjs = JsonUtility.FromJson <GameObjects>(response.GetSuccess()); } else { throw new InvalidDataException(response.GetError().error); } }).GetAwaiter().GetResult(); return(goh); }