Beispiel #1
0
        public static JiraResultWithData Get <R>(string requestUri, JiraCredentials credentials, HttpStatusCode expectedStatus = HttpStatusCode.OK) where R : class, new()
        {
            try
            {
                HttpResponseMessage response = JiraUtility.GetClient(credentials).GetAsync(requestUri).Result;

                return(ParseResponse <R>(response, expectedStatus));
            }
            catch (Exception ex)
            {
                throw new LoggedException("Error to process GET to Jira", ex);
            }
        }
Beispiel #2
0
        public static JiraResultWithData Put <T, R>(string requestUri, JiraCredentials credentials, T content, HttpStatusCode expectedStatus) where R : class, new()
        {
            try
            {
                string data = ParseRequestContent(content);

                var contentStr = new StringContent(data, Encoding.UTF8, "application/json");

                var client = JiraUtility.GetClient(credentials);

                HttpResponseMessage response = client.PutAsync(requestUri, contentStr).Result;

                return(ParseResponse <R>(response, expectedStatus));
            }
            catch (Exception ex)
            {
                throw new LoggedException("Error to process PUT to Jira", ex);
            }
        }
Beispiel #3
0
        public static BaseJiraResult Delete(string requestUri, JiraCredentials credentials, HttpStatusCode expectedStatus)
        {
            try
            {
                HttpResponseMessage response = JiraUtility.GetClient(credentials).DeleteAsync(requestUri).Result;

                var responseString = response.Content.ReadAsStringAsync().Result;

                return(new BaseJiraResult()
                {
                    Status = response.StatusCode == expectedStatus ? JiraResultStatus.Success : JiraResultStatus.Fail,
                    HttpStatus = (int)response.StatusCode,
                    ErrorMessage = response.StatusCode != expectedStatus ? responseString : string.Empty,
                });
            }
            catch (Exception ex)
            {
                throw new LoggedException("Error to process DELETE to Jira", ex);
            }
        }