/// <exception cref="RPM.ApiResults.RPMApiError">An RPM API Error occurred.</exception> private T sendRequest <T>(string endpoint, dynamic apiParameters = null) { if (apiParameters == null) { apiParameters = this.apiParameters(); } RestRequest request = new RestRequest(endpoint, Method.POST); request.RequestFormat = DataFormat.Json; request.AddBody(apiParameters); RestResponse response = (RestResponse)this.client.Execute(request); string statusDescription = response.StatusDescription.ToString(); if (statusDescription == "Not Found" || statusDescription == "Bad Request") { throw new WebException(statusDescription); } JsonDeserializer js = new JsonDeserializer(); response.Content = response.Content.Replace("{\"Result\":", ""); response.Content = response.Content.Substring(0, response.Content.Length - 1); if (response.Content.StartsWith("{\"Error\"")) { RPMApiError parsedError = js.Deserialize <RPMApiError>(response); throw parsedError; } T parsedResponse = js.Deserialize <T>(response); return(parsedResponse); }
public RPMSync(string apiUrl, string apiKey) { this.rpmApiUrl = apiUrl; this.rpmApiKey = apiKey; this.syncDataWorker.WorkerReportsProgress = true; this.syncDataWorker.DoWork += syncData; this.syncDataWorker.RunWorkerCompleted += syncingComplete; this.syncDataWorker.ProgressChanged += syncingProgressChanged; this.checkRPMAccess(); if (this.infoSuccessful()) { ProcsResult procs = this.getAllProcs(); this.jobProcess = this.getProc("External-JobInformation", procs); if (this.jobProcess == null) { throw new ProcessNotFoundException("The RPM Process \"External-JobInformation\" was not Found."); } if (!this.jobProcess.Enabled) { RPMApiError error = new RPMApiError(); error.Error = new Dictionary <string, string> { { "Message", "The RPM Process \"External-JobInformation\" is not enabled." } }; throw error; } } }