public IEnumerator CreateTableIfNotExistsInternal(string tableName, Action <CallbackResponse> onCreateTableCompleted) { string url = Url + "Tables()"; string json = string.Format("{{\"TableName\":\"{0}\"}}", tableName); using (UnityWebRequest www = StorageUtilities.BuildStorageWebRequest(url, HttpMethod.Post.ToString(), accountName, json)) { yield return(www.Send()); if (Globals.DebugFlag) { Debug.Log(www.responseCode); } CallbackResponse response = new CallbackResponse(); if (Utilities.IsWWWError(www)) { if (Globals.DebugFlag) { Debug.Log(www.error ?? "Error " + www.responseCode); } Utilities.BuildResponseObjectOnFailure(response, www); } else { response.Status = CallBackResult.Success; } onCreateTableCompleted(response); } }
private IEnumerator InsertInternal <T>(T instance, string tableName, Action <CallbackResponse> onInsertCompleted) where T : TableEntity { string url = string.Format("{0}{1}()", Url, tableName); string json = JsonUtility.ToJson(instance); using (UnityWebRequest www = StorageUtilities.BuildStorageWebRequest(url, HttpMethod.Post.ToString(), accountName, json)) { yield return(www.Send()); if (Globals.DebugFlag) { Debug.Log(www.responseCode); } CallbackResponse <T> response = new CallbackResponse <T>(); if (Utilities.IsWWWError(www)) { if (Globals.DebugFlag) { Debug.Log(www.error ?? "Error " + www.responseCode); } Utilities.BuildResponseObjectOnFailure(response, www); } else if (www.downloadHandler != null) //all OK { //let's get the header for the new object that was created string dataServiceId = www.GetResponseHeader("Location"); if (Globals.DebugFlag) { Debug.Log("new object ID is " + dataServiceId); } response.Status = CallBackResult.Success; } onInsertCompleted(response); } }
private IEnumerator QueryTableInternal <T>(TableQuery query, string tableName, Action <CallbackResponse <T[]> > onQueryTableCompleted) where T : TableEntity { string url = string.Format("{0}{1}(){2}", Url, tableName, query.ToString()); using (UnityWebRequest www = StorageUtilities.BuildStorageWebRequest(url, HttpMethod.Get.ToString(), accountName, string.Empty)) { yield return(www.Send()); if (Globals.DebugFlag) { Debug.Log(www.responseCode); } CallbackResponse <T[]> response = new CallbackResponse <T[]>(); if (Utilities.IsWWWError(www)) { if (Globals.DebugFlag) { Debug.Log(www.error ?? "Error " + www.responseCode); } Utilities.BuildResponseObjectOnFailure(response, www); } else if (www.downloadHandler != null) //all OK { //let's get the header for the new object that was created T[] data = JsonHelper.GetJsonArrayFromTableStorage <T>(www.downloadHandler.text); if (Globals.DebugFlag) { Debug.Log("Received " + data.Length + " objects"); } response.Result = data; response.Status = CallBackResult.Success; } onQueryTableCompleted(response); } }
private IEnumerator InsertOrMergeInternal <T>(T instance, string tableName, Action <CallbackResponse> onInsertOrMergeCompleted) where T : TableEntity { string url = string.Format("{0}{1}(PartitionKey='{2}', RowKey='{3}')", Url, tableName, instance.PartitionKey, instance.RowKey); string json = JsonUtility.ToJson(instance); using (UnityWebRequest www = StorageUtilities.BuildStorageWebRequest(url, HttpMethod.Merge.ToString(), accountName, json)) { yield return(www.Send()); if (Globals.DebugFlag) { Debug.Log(www.responseCode); } CallbackResponse <T> response = new CallbackResponse <T>(); if (Utilities.IsWWWError(www)) { if (Globals.DebugFlag) { Debug.Log(www.error ?? "Error " + www.responseCode); } Utilities.BuildResponseObjectOnFailure(response, www); } else if (www.downloadHandler != null) //all OK { if (Globals.DebugFlag) { Debug.Log("successfully inserted or merged object"); } response.Status = CallBackResult.Success; } onInsertOrMergeCompleted(response); } }