private static dynamic QueryApi(string query, Jira jira)
        {
            var wc = jira.GetAuthorizedWebClient();

            var resp = wc.DownloadString(jira.Url + "/rest/api/latest/" + query);

            return(Json.Decode(resp));
        }
        private IEnumerable <Issue> GetIssues(Jira jira)
        {
            Status = "Processing JQL...";

            var jql = "updated>-12h AND status not in (open)";

            if (!string.IsNullOrEmpty(jira.Project))
            {
                jql = string.Format("project%3D{0}%20AND%20{1}" +
                                    "", jira.Project, jql);
            }

            dynamic dyn = QueryApi(string.Format("search?jql={0}&maxResults=1000", jql), jira);

            return(GetIssues(dyn, jira));
        }
        private IEnumerable <Issue> GetIssues(dynamic response, Jira jira)
        {
            int total = response.total;
            var cur   = 0;

            foreach (var i in response.issues)
            {
                Status = string.Format("Loading issue {0} of {1}", cur++, total);

                var data = QueryApi(string.Format("issue/{0}?expand=changelog", i.Key), jira);

                yield return(new Issue
                {
                    Key = i.Key,
                    Summary = i.fields.summary,
                    Status = i.fields.status.name,
                    Comments = Enumerable.ToArray(GetItems(data.fields.comment.comments)),
                    History = Enumerable.ToArray(GetItems(data.changelog.histories)),
                    JiraUrl = jira.Url
                });
            }
        }