public IEnumerator Update <T> (T item, Action <IRestResponse <T> > callback = null) where T : new() { string id = null; // Check if model uses the 'IDataModel' Interface to get id property, otherwise try Refelection (using 'Model' helper). IDataModel model = item as IDataModel; if (model != null) { id = model.GetId(); } else if (Model.HasField(item, "id")) { var x = Model.GetField(item, "id"); id = x.GetValue(item) as string; } else { Debug.LogError("Unable to get 'id' data model property"); } if (string.IsNullOrEmpty(id)) { Debug.LogError("Error 'id' value is missing"); yield return(null); } string url = string.Format("{0}/{1}{2}/{3}", _client.AppUrl, URI_TABLES, _name, id); ZumoRequest request = new ZumoRequest(_client, url, Method.PATCH); request.AddBody(item); Debug.Log("Update Request Url: " + url + " patch:" + item); yield return(request.request.Send()); request.ParseJson <T> (callback); }
public void Update <T>(T item, Action <IRestResponse <T> > callback = null) where T : new() { string id = null; // Check if model uses the 'IDataModel' Interface to get id property, otherwise try Refelection (using 'Model' helper). IDataModel model = item as IDataModel; if (model != null) { id = model.GetId(); } else if (Model.HasProperty(item, "id")) { var x = Model.GetProperty(item, "id"); id = x.GetValue(item, null) as string; } else { Debug.LogError("Unable to get 'id' data model property"); } if (string.IsNullOrEmpty(id)) { Debug.LogError("Error 'id' value is missing"); return; } string uri = URI_TABLES + _name + "/" + id; ZumoRequest request = new ZumoRequest(_client, uri, Method.PATCH); Debug.Log("Update Request Uri: " + uri); request.AddBody(item); _client.ExecuteAsync <T>(request, callback); }
/// <summary> /// Invokes custom API with body /// </summary> public void InvokeApi <T>(string apiName, Method httpMethod, T body, Action <IRestResponse <T> > callback = null) where T : new() { string uri = URI_API + apiName; ZumoRequest request = new ZumoRequest(this, uri, httpMethod); request.AddBody(body); Debug.Log(httpMethod.ToString() + " custom API Request Uri: " + uri); this.ExecuteAsync(request, callback); }
public void Insert <T>(T item, Action <IRestResponse <T> > callback = null) where T : new() { string uri = URI_TABLES + _name; ZumoRequest request = new ZumoRequest(_client, uri, Method.POST); Debug.Log("Insert Request: " + uri); request.AddBody(item); _client.ExecuteAsync <T>(request, callback); }
public IEnumerator Insert <T> (T item, Action <IRestResponse <T> > callback = null) where T : new() { string url = string.Format("{0}/{1}{2}", _client.AppUrl, URI_TABLES, _name); ZumoRequest request = new ZumoRequest(_client, url, Method.POST); Debug.Log("Insert Request: " + url); request.AddBody(item); yield return(request.request.Send()); request.ParseJson <T> (callback); }
/// <summary> /// Invokes custom API with body /// </summary> public IEnumerator InvokeApi <T> (string apiName, Method httpMethod, T body, Action <IRestResponse <T> > callback = null) where T : new() { string url = string.Format("{0}/{1}{2}", AppUrl, URI_API, apiName); Debug.Log(httpMethod.ToString() + " custom API Request Url: " + url); ZumoRequest request = new ZumoRequest(this, url, httpMethod); request.AddBody <T> (body); yield return(request.request.Send()); request.ParseJson <T> (callback); }