PageRenderTime 46ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/Atlassian.Jira/Remote/JiraRestService.cs

https://bitbucket.org/seansparkman/atlassian.net-sdk
C# | 34 lines | 29 code | 5 blank | 0 comment | 2 complexity | 1c4553af756553b02944249a8b23596a MD5 | raw file
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using RestSharp;
  6. using Newtonsoft.Json.Linq;
  7. namespace Atlassian.Jira.Remote
  8. {
  9. public class JiraRestService
  10. {
  11. public IEnumerable<string> GetIssuesFromJql(string url, string username, string password, string jql, int startAt, int maxResults)
  12. {
  13. var restClient = new RestClient(url);
  14. if (!String.IsNullOrEmpty(username) && !String.IsNullOrEmpty(password))
  15. {
  16. restClient.Authenticator = new HttpBasicAuthenticator(username, password);
  17. }
  18. var request = new RestRequest();
  19. request.Method = Method.POST;
  20. request.Resource = "rest/api/latest/search";
  21. request.RequestFormat = DataFormat.Json;
  22. request.AddBody(new { jql = jql, startAt = startAt, maxResults = maxResults });
  23. var response = restClient.Execute(request);
  24. var json = JObject.Parse(response.Content);
  25. return from i in (JArray)json["issues"]
  26. select i.ToString();
  27. }
  28. }
  29. }