public objects_get(string serverLocation, string sessionId, Request.objects_get request, bool isBulk = false, bool returnRawResponse = false) { if (request == null || String.IsNullOrEmpty(request.id)) { IsCalledSuccessfully = false; this.Error = "Object id must be provided"; return; } // Set the URL string url = (isBulk ? String.Empty : serverLocation) + "/data/objects" + (request.id.Substring(0, 1) != "/" ? "/" : "") + request.id + //(request.fields != null ? "?" + request.fields.ToQueryString() : String.Empty); (request.fields != null ? "?fields=" + GetFieldList(request.fields) : String.Empty); if (isBulk) { this.BulkRequest = new request(url, requestMethod.Get); return; } // Set the header for the authenticated user System.Net.WebHeaderCollection headers = new System.Net.WebHeaderCollection(); headers.Add(System.Net.HttpRequestHeader.Authorization, String.Format("Session {0}", sessionId)); // Call the API Ekin.Rest.Client restClient = new Ekin.Rest.Client(url, headers); restClient.ErrorType = typeof(error); Ekin.Rest.Response response = restClient.Get(); // Parse Data if (response.Status == System.Net.HttpStatusCode.OK) { try { if (returnRawResponse) { this.Data = response.Content; } else { this.Data = JsonConvert.DeserializeObject(response.Content); } this.IsCalledSuccessfully = true; } catch (Exception ex) { this.IsCalledSuccessfully = false; this.Error = ex.Message; } } else { this.IsCalledSuccessfully = false; this.Error = response.InternalError.GetFormattedErrorMessage(); } }
public search(string serverLocation, string sessionId, Request.search request, bool isBulk = false) { if (request == null || String.IsNullOrWhiteSpace(request.q)) { IsCalledSuccessfully = false; this.Error = "Search query must be provided"; return; } // Set the URL string url = (isBulk ? String.Empty : serverLocation) + "/data/search?q=" + request.q + (request.fields != null ? "&" + request.fields.ToQueryString() : String.Empty) + (!String.IsNullOrWhiteSpace(request.typeName) ? "&" + request.typeName.ToQueryString() : String.Empty) + (request.paging != null ? "&" + request.paging.ToQueryString() : String.Empty); if (isBulk) { this.BulkRequest = new request(url, requestMethod.Get); return; } // Set the header for the authenticated user System.Net.WebHeaderCollection headers = new System.Net.WebHeaderCollection(); headers.Add(System.Net.HttpRequestHeader.Authorization, String.Format("Session {0}", sessionId)); // Call the API Ekin.Rest.Client restClient = new Ekin.Rest.Client(url, headers); restClient.ErrorType = typeof(error); Ekin.Rest.Response response = restClient.Get(); // Parse Data if (response.Status == System.Net.HttpStatusCode.OK) { try { this.Data = JsonConvert.DeserializeObject <Result.search>(response.Content); this.IsCalledSuccessfully = true; } catch (Exception ex) { this.IsCalledSuccessfully = false; this.Error = ex.Message; } } else { this.IsCalledSuccessfully = false; this.Error = response.InternalError.GetFormattedErrorMessage(); } }
public download(string serverLocation, string sessionId, Request.download request, bool isBulk = false) { if (request == null || String.IsNullOrEmpty(request.documentId)) { IsCalledSuccessfully = false; this.Error = "Document id must be provided"; return; } // Set the URL string url = (isBulk ? String.Empty : serverLocation) + "/files/download?documentId=" + (request.documentId.Substring(0, 1) != "/" ? "/" : "") + request.documentId + (request.redirect ? "&" + request.redirect.ToQueryString() : String.Empty); if (isBulk) { this.BulkRequest = new request(url, requestMethod.Get); return; } // Set the header for the authenticated user System.Net.WebHeaderCollection headers = new System.Net.WebHeaderCollection(); headers.Add(System.Net.HttpRequestHeader.Authorization, String.Format("Session {0}", sessionId)); // Call the API Ekin.Rest.Client restClient = new Ekin.Rest.Client(url, headers); restClient.ErrorType = typeof(error); Ekin.Rest.Response response = restClient.Get(); // Parse Data if (response.Status == System.Net.HttpStatusCode.OK) { try { this.Data = JsonConvert.DeserializeObject <Result.download>(response.Content); this.IsCalledSuccessfully = true; } catch (Exception ex) { this.IsCalledSuccessfully = false; this.Error = ex.Message; } } else { this.IsCalledSuccessfully = false; this.Error = response.InternalError.GetFormattedErrorMessage(); } }
public getSystemSettingsValues(string serverLocation, string sessionId, Request.getSystemSettingsValues request, bool isBulk = false) { // Set the URL string url = (isBulk ? String.Empty : serverLocation) + "/metadata/getSystemSettingsValues?" + request.ToQueryString(); if (isBulk) { this.BulkRequest = new request(url, requestMethod.Get, typeof(Result.describeMetadata)); return; } // Set the header for the authenticated user System.Net.WebHeaderCollection headers = new System.Net.WebHeaderCollection(); headers.Add(System.Net.HttpRequestHeader.Authorization, String.Format("Session {0}", sessionId)); // Call the API Ekin.Rest.Client restClient = new Ekin.Rest.Client(url, headers); restClient.ErrorType = typeof(error); Ekin.Rest.Response response = restClient.Get(); // Parse Data if (response.Status == System.Net.HttpStatusCode.OK) { try { this.Data = JsonConvert.DeserializeObject <Result.getSystemSettingsValues>(response.Content); this.IsCalledSuccessfully = true; } catch (Exception ex) { this.IsCalledSuccessfully = false; this.Error = ex.Message; } } else { this.IsCalledSuccessfully = false; this.Error = response.InternalError.GetFormattedErrorMessage(); } }