Ejemplo n.º 1
0
        public IEnumerator Update <T>(T item, Action <IRestResponse <T> > callback = null) where T : new()
        {
            string id = null;
            // Check if item uses the 'IDataModel' Interface to get 'id' property, otherwise try Refelection (using Reflection helper).
            IDataModel model = item as IDataModel;

            if (model != null)
            {
                id = model.GetId();
            }
            else if (ReflectionHelper.HasField(item, "id"))
            {
                var x = ReflectionHelper.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     = TableUrl(_name, id);
            ZumoRequest request = new ZumoRequest(url, Method.PATCH, true, _client.User);

            request.AddBody(item);
            Debug.Log("Update Request Url: " + url + " patch:" + item);
            yield return(request.Request.Send());

            request.ParseJson <T>(callback);
        }
Ejemplo n.º 2
0
        public IEnumerator Insert <T>(T item, Action <IRestResponse <T> > callback = null) where T : new()
        {
            string      url     = TableUrl(_name);
            ZumoRequest request = new ZumoRequest(url, Method.POST, true, _client.User);

            Debug.Log("Insert Request: " + url);
            request.AddBody(item);
            yield return(request.Request.Send());

            request.ParseJson <T>(callback);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Invokes custom API with body (of type B) and returning response (of type T)
        /// </summary>
        public IEnumerator InvokeApi <B, T>(string apiName, Method httpMethod, B body, Action <IRestResponse <T> > callback = null) where T : new()
        {
            string url = ApiUrl(apiName);

            Debug.Log(httpMethod.ToString() + " custom API Request Url: " + url);
            ZumoRequest request = new ZumoRequest(url, httpMethod, true, User);

            request.AddBody <B>(body);
            yield return(request.Request.SendWebRequest());

            request.ParseJson <T>(callback);
        }