public getSessionInfo(string serverLocation, string sessionId) { System.Net.WebHeaderCollection headers = new System.Net.WebHeaderCollection(); headers.Add(System.Net.HttpRequestHeader.Authorization, String.Format("Session {0}", sessionId)); Ekin.Rest.Client restClient = new Ekin.Rest.Client(serverLocation + "/authentication/getSessionInfo", headers); restClient.ErrorType = typeof(error); Ekin.Rest.Response response = restClient.Get(); if (response.Status == System.Net.HttpStatusCode.OK) { try { this.Data = JsonConvert.DeserializeObject <Result.getSessionInfo>(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 logout(string serverLocation, string sessionId) { System.Net.WebHeaderCollection headers = new System.Net.WebHeaderCollection(); headers.Add(System.Net.HttpRequestHeader.Authorization, String.Format("Session {0}", sessionId)); Ekin.Rest.Client restClient = new Ekin.Rest.Client(serverLocation + "/authentication/logout", headers); Ekin.Rest.Response response = restClient.Get(); this.IsCalledSuccessfully = (response.Status == System.Net.HttpStatusCode.OK); }
public getCalendarExceptions(string serverLocation, string sessionId, Request.getCalendarExceptions request, bool isBulk = false) { if (request == null || request.fromDate == DateTime.MinValue || request.toDate == DateTime.MinValue) { IsCalledSuccessfully = false; this.Error = "FromDate and toDate must be provided"; return; } // Set the URL string url = string.Format("{0}?{1}fromDate={2:yyyy-MM-dd}&toDate={3:yyyy-MM-dd}", (isBulk ? String.Empty : serverLocation) + "/data/getCalendarExceptions?", string.IsNullOrWhiteSpace(request.entityId) ? "" : "entityId=" + request.entityId + "&", request.fromDate, request.toDate); if (isBulk) { this.BulkRequest = new request(url, requestMethod.Get, typeof(Result.getCalendarExceptions)); 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.getCalendarExceptions>(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 entityQuery(string serverLocation, string sessionId, Queries.entityQuery request, bool isBulk = false) { // Set the URL string url = (isBulk ? String.Empty : serverLocation) + "/data/entityQuery"; if (isBulk) { this.BulkRequest = new request(url, requestMethod.Post, request, typeof(Result.entityQuery)); 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.Post(request); // Return result if (response.Status == System.Net.HttpStatusCode.OK) { try { this.Data = JsonConvert.DeserializeObject <Result.entityQuery>(response.Content, new JsonSerializerSettings() { Error = HandleDeserializationError }); this.IsCalledSuccessfully = true; } catch (Exception ex) { this.IsCalledSuccessfully = false; this.Error = ex.Message; } } else if (response.InternalError != null) { this.IsCalledSuccessfully = false; this.Error = response.InternalError.GetFormattedErrorMessage(); } else { this.IsCalledSuccessfully = false; } }
public getTemplateDescriptions(string serverLocation, string sessionId, Request.getTemplateDescriptions request, bool isBulk = false) { if (request == null || String.IsNullOrWhiteSpace(request.typeName)) { IsCalledSuccessfully = false; this.Error = "Type name must be provided"; return; } // Set the URL string url = (isBulk ? String.Empty : serverLocation) + "/data/getTemplateDescriptions?typeName=" + request.typeName; 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.getTemplateDescriptions>(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 objects_delete(string serverLocation, string sessionId, Request.objects_delete request, bool isBulk = false) { if (request == null || String.IsNullOrEmpty(request.id)) { IsCalledSuccessfully = false; this.Error = "Entity id must be provided"; return; } // Set the URL string url = (isBulk ? String.Empty : serverLocation) + "/metadata/objects" + (request.id.Substring(0, 1) != "/" ? "/" : "") + request.id; if (isBulk) { this.BulkRequest = new request(url, requestMethod.Delete); 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.Delete(); // Return result if (response.Status == System.Net.HttpStatusCode.OK) { this.IsCalledSuccessfully = true; } else if (response.InternalError != null) { this.IsCalledSuccessfully = false; this.Error = response.InternalError.GetFormattedErrorMessage(); } else { this.IsCalledSuccessfully = false; } }
public objects_put(string serverLocation, string sessionId, string id, object obj, bool isBulk = false) { // Set the URL string url = (isBulk ? String.Empty : serverLocation) + "/data/objects" + (id.Substring(0, 1) != "/" ? "/" : "") + id; if (isBulk) { this.BulkRequest = new request(url, requestMethod.Put, obj, typeof(Result.objects_put)); 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.Put(obj); // Parse Data if (response.Status == System.Net.HttpStatusCode.OK) { try { this.Data = JsonConvert.DeserializeObject <Result.objects_put>(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 execute(string serverLocation, string sessionId, Request.execute request) { // Set the URL string url = serverLocation + "/bulk/execute"; // 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)); // Set the CallOptions header if (request.batch != null) { headers.Add("CallOptions", string.Format("Batch={0}", ((bool)request.batch) ? "true" : "false")); } // Call the API Ekin.Rest.Client restClient = new Ekin.Rest.Client(url, headers); restClient.ErrorType = typeof(error); Ekin.Rest.Response response = restClient.Post(request); // Parse Data if (response.Status == System.Net.HttpStatusCode.OK) { try { this.Data = JsonConvert.DeserializeObject <Result.execute>(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 objects_post(string serverLocation, string sessionId, string id, object obj, bool isBulk = false) { // Set the URL string url = (isBulk ? String.Empty : serverLocation) + "/data/objects" + (id.Length > 0 && id.Substring(0, 1) != "/" ? "/" : "") + id; if (isBulk) { this.BulkRequest = new request(url, requestMethod.Post, obj, null); 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.Post(obj); // Return result if (response.Status == System.Net.HttpStatusCode.OK) { this.IsCalledSuccessfully = true; } else if (response.InternalError != null) { this.IsCalledSuccessfully = false; this.Error = response.InternalError.GetFormattedErrorMessage(); } else { this.IsCalledSuccessfully = false; } }
public login(string serverLocation, Request.login request) { Ekin.Rest.Client restClient = new Ekin.Rest.Client(serverLocation + "/authentication/login"); restClient.ErrorType = typeof(error); Ekin.Rest.Response response = restClient.Post(request, true); if (response.Status == System.Net.HttpStatusCode.OK) { try { this.Data = JsonConvert.DeserializeObject <Result.login>(response.Content); this.IsCalledSuccessfully = true; } catch (Exception ex) { this.IsCalledSuccessfully = false; this.Error = ex.Message; } } else { this.IsCalledSuccessfully = false; this.Error = response.InternalError.GetFormattedErrorMessage(); } }