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); }
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); }
/// <summary> /// Invokes custom API for HTTP Methods: GET, POST, PUT, PATCH, DELETE /// </summary> public void InvokeApi <T>(string apiName, Method httpMethod, Action <IRestResponse <T> > callback = null) where T : new() { string uri = URI_API + apiName; ZumoRequest request = new ZumoRequest(this, uri, httpMethod); Debug.Log(httpMethod.ToString() + " custom API Request Uri: " + uri); this.ExecuteAsync(request, callback); }
public void Query <T>(CustomQuery query, Action <IRestResponse <List <T> > > callback = null) where T : new() { string uri = string.Format("{0}{1}{2}", URI_TABLES, _name, query); ZumoRequest request = new ZumoRequest(_client, uri, Method.GET); Debug.Log("Query Request: " + uri + " Query:" + query); _client.ExecuteAsync <List <T> > (request, callback); }
public void Read <T>(Action <IRestResponse <List <T> > > callback = null) where T : new() { string uri = URI_TABLES + _name; ZumoRequest request = new ZumoRequest(_client, uri, Method.GET); Debug.Log("Read Request: " + uri); _client.ExecuteAsync <List <T> >(request, callback); }
public void Lookup <T>(string id, Action <IRestResponse <T> > callback = null) where T : new() { string uri = URI_TABLES + _name + "/" + id; ZumoRequest request = new ZumoRequest(_client, uri, Method.GET); Debug.Log("Lookup Request Uri: " + uri); _client.ExecuteAsync <T>(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); }
/// <summary> /// Client-directed single sign on (POST with access token) /// </summary> public void Login(MobileServiceAuthenticationProvider provider, string token, Action <IRestResponse <MobileServiceUser> > callback = null) { string p = provider.ToString().ToLower(); string uri = IsAppService() ? ".auth/login/" + p : "login/" + p; ZumoRequest request = new ZumoRequest(this, uri, Method.POST); Debug.Log("Login Request Uri: " + uri + " access token: " + token); request.AddBodyAccessToken(token); this.ExecuteAsync(request, callback); }
public IEnumerator Query <T> (CustomQuery query, Action <IRestResponse <T[]> > callback = null) where T : new() { string url = string.Format("{0}/{1}{2}{3}", _client.AppUrl, URI_TABLES, _name, query); ZumoRequest request = new ZumoRequest(_client, url, Method.GET); Debug.Log("Query Request: " + url + " Query:" + query); yield return(request.request.Send()); request.ParseJsonArray <T> (callback); }
public IEnumerator Lookup <T> (string id, Action <IRestResponse <T> > callback = null) where T : new() { string url = string.Format("{0}/{1}{2}/{3}", _client.AppUrl, URI_TABLES, _name, id); ZumoRequest request = new ZumoRequest(_client, url, Method.GET); Debug.Log("Lookup Request Url: " + url); yield return(request.request.Send()); request.ParseJson <T> (callback); }
/// <summary> /// Invokes custom API for HTTP Methods: GET, POST, PUT, PATCH, DELETE /// </summary> public IEnumerator InvokeApi <T> (string apiName, Method httpMethod, 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); yield return(request.request.Send()); request.ParseJson <T> (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); }
public void Query <T>(CustomQuery query, Action <IRestResponse <T> > callback = null) where T : INestedResults, new() { string queryResults = query.ToString(); string q = queryResults.Length > 0 ? "&" : "?"; queryResults += string.Format("{0}$inlinecount=allpages", q); string uri = string.Format("{0}{1}{2}", URI_TABLES, _name, queryResults); ZumoRequest request = new ZumoRequest(_client, uri, Method.GET); Debug.Log("Query Request: " + uri + " Query with inlinecount:" + queryResults); _client.ExecuteAsync <T> (request, callback); }
/// <summary> /// Client-directed single sign on (POST with access token) /// </summary> public IEnumerator Login(MobileServiceAuthenticationProvider provider, string token, Action <IRestResponse <MobileServiceUser> > callback = null) { string p = provider.ToString().ToLower(); string url = string.Format("{0}/.auth/login/{1}", AppUrl, p); Debug.Log("Login Request Url: " + url + " access token: " + token); ZumoRequest request = new ZumoRequest(this, url, Method.POST); request.AddBodyAccessToken(token); yield return(request.request.Send()); request.ParseJson <MobileServiceUser> (callback); }
/* * public IEnumerator Query<T,N> (CustomQuery query, Action<IRestResponse<N>> callback = null) where N : INestedResults<T> where T : new() * { * string queryString = query.ToString (); * string q = queryString.Length > 0 ? "&" : "?"; * queryString += string.Format ("{0}$inlinecount=allpages", q); * string url = string.Format ("{0}/{1}{2}{3}", _client.AppUrl, URI_TABLES, _name, queryString); * Debug.Log ("Query Request: " + url + " Paginated Query:" + query); * ZumoRequest request = new ZumoRequest (_client, url, Method.GET); * yield return request.request.Send (); * request.TryParseJsonNestedArray<T,N> ("results", callback); * } */ public IEnumerator Query <T>(CustomQuery query, Action <IRestResponse <NestedResults <T> > > callback = null) where T : new() { string queryString = query.ToString(); string q = queryString.Length > 0 ? "&" : "?"; queryString += string.Format("{0}$inlinecount=allpages", q); string url = string.Format("{0}/{1}{2}{3}", _client.AppUrl, URI_TABLES, _name, queryString); Debug.Log("Query Request: " + url + " Paginated Query:" + query); ZumoRequest request = new ZumoRequest(_client, url, Method.GET); yield return(request.request.Send()); request.ParseJsonNestedArray <T, NestedResults <T> >("results", callback); }