public string Stringify() { try { return(JsonConvert.SerializeObject(this, TSCloud.serializer_settings())); } catch { throw; } }
public static Hash Parse(string strData) { try { Hash hash = JsonConvert.DeserializeObject <Hash>(strData, TSCloud.serializer_settings()); return(hash); } catch (Exception ee) { throw ee; } }
public Comment CreateComment(string Content) { if (!IsSysInfoDefined()) { throw new Exception("SysInfo is not defined"); } if (!CheckExpiration()) { throw new Exception("token refresh fails"); } RestRequest request = new RestRequest(String.Format("{0}/folders/{1}/comments", SysInfo.ApiPath, Convert.ToString(this.Id)), Method.POST); request.AddParameter("api_token", SysInfo.ApiToken); request.AddParameter("content", Content); try { IRestResponse httpResponse = GetRestClient().Execute(request); if (httpResponse.StatusCode == HttpStatusCode.OK) { Comment response = JsonConvert.DeserializeObject <Comment>(httpResponse.Content, TSCloud.serializer_settings()); response.StatusCode = httpResponse.StatusCode; response.Message = httpResponse.ErrorMessage; response.SysInfo = this.SysInfo; return(response); } else { return(null); } } catch (Exception ee) { throw ee; } }
public Model Update() { if (!IsSysInfoDefined()) { throw new Exception("SysInfo is not defined"); } if (this.Id == 0) { throw new Exception("Model ID Required"); } if (!CheckExpiration()) { throw new Exception("token refresh fails"); } RestRequest request = new RestRequest(String.Format("{0}/folders/{1}", SysInfo.ApiPath, Convert.ToString(this.Id)), Method.PUT); request.AddParameter("api_token", SysInfo.ApiToken); request.AddParameter("name", this.Name); if (this.Meta != null) { request.AddParameter("meta", this.Meta.Stringify()); } if (this.Acl != null) { request.AddParameter("acl", this.Acl.Stringify()); } if (this.Ftype == Ftype.Page) { request.AddParameter("page", this.Content); } request.AddParameter("description", this.Description); try { IRestResponse httpResponse = GetRestClient().Execute(request); if (httpResponse.StatusCode == HttpStatusCode.OK) { Model model_response = JsonConvert.DeserializeObject <Model>(httpResponse.Content, TSCloud.serializer_settings()); model_response.StatusCode = httpResponse.StatusCode; model_response.Message = httpResponse.ErrorMessage; model_response.SysInfo = this.SysInfo; return(model_response); } else { return(new Model(httpResponse.Content)); } } catch (Exception ee) { return(new Model(ee.ToString())); } }