Esempio n. 1
0
        public static List <JiraProject> GetProjects(this IJiraRestClient jiraRestClient)
        {
            Argument.IsNotNull(() => jiraRestClient);

            var projects = new List <JiraProject>();

            var responseJson = jiraRestClient.ExecuteRequest(Method.GET, "rest/api/2/project");

            foreach (var jsonElement in responseJson.Children())
            {
                var project = JsonConvert.DeserializeObject <JiraProject>(jsonElement.ToString());

                projects.Add(project);
            }

            return(projects);
        }
        public static List <JiraProjectVersion> GetProjectVersions(this IJiraRestClient jiraRestClient, string projectKey)
        {
            Argument.IsNotNull(() => jiraRestClient);
            Argument.IsNotNullOrWhitespace(() => projectKey);

            var projectVersions = new List <JiraProjectVersion>();

            var resource     = string.Format("rest/api/2/project/{0}/versions", projectKey);
            var responseJson = jiraRestClient.ExecuteRequest(Method.GET, resource);

            foreach (var jsonElement in responseJson.Children())
            {
                var projectVersion = JsonConvert.DeserializeObject <JiraProjectVersion>(jsonElement.ToString());
                projectVersion.Project = projectKey;

                projectVersions.Add(projectVersion);
            }

            return(projectVersions);
        }
Esempio n. 3
0
        public static JToken ExecuteRequestRaw(this IJiraRestClient jiraRestClient, Method method, string resource, string jsonRequestBody)
        {
            var restRequest = new RestRequest
            {
                Resource      = resource,
                Method        = method,
                RequestFormat = DataFormat.Json,
            };

            restRequest.AddParameter(new Parameter
            {
                Name  = "application/json",
                Type  = ParameterType.RequestBody,
                Value = jsonRequestBody
            });

            var response = jiraRestClient.ExecuteRequest(restRequest);

            return(response.StatusCode != HttpStatusCode.NoContent ? JToken.Parse(response.Content) : new JObject());
        }
        public static void DeleteProjectVersion(this IJiraRestClient jiraRestClient, JiraProjectVersion projectVersion, JiraProjectVersion projectToMoveFixIssuesTo = null,
                                                JiraProjectVersion projectToMoveAffectedIssuesTo = null)
        {
            Argument.IsNotNull(() => jiraRestClient);
            Argument.IsNotNull(() => projectVersion);

            var resource = string.Format("rest/api/2/version/{0}", projectVersion.Id);

            if (projectToMoveFixIssuesTo != null)
            {
                resource += resource.Contains("?") ? "&" : "?";
                resource += string.Format("moveFixIssuesTo={0}", projectToMoveFixIssuesTo.Id);
            }

            if (projectToMoveAffectedIssuesTo != null)
            {
                resource += resource.Contains("?") ? "&" : "?";
                resource += string.Format("moveAffectedIssuesTo={0}", projectToMoveAffectedIssuesTo.Id);
            }

            var responseJson = jiraRestClient.ExecuteRequest(Method.DELETE, resource);
        }