Ejemplo n.º 1
0
        /// Gets the issues of a GitHub repository on the given page
        /// </summary>
        /// <param name="owner">The owner of the repository</param>
        /// <param name="repositoryName">The name of the repository</param>
        /// <returns>An array of issues in the repository</returns>
        public static async Task <Issue[]> GetIssuesFromRepository(string owner, string repositoryName)
        {
            Response resp = await Rest.GetAsync(
                "https://api.github.com/" + "repos/" + owner + "/" + repositoryName + "/issues",
                null,
                -1,
                null,
                true);

            ConnectionManager.Instance.CheckStatusCode(resp.ResponseCode);
            if (!resp.Successful)
            {
                Debug.LogError(resp.ResponseCode + ": " + resp.ResponseBody);
                return(null);
            }
            else
            {
                String json = "{ \"data\": " + resp.ResponseBody + " }";
                Debug.Log(json);
                Issue[] issues = JsonArrayUtility.FromJson <Issue>(json);
                if (issues == null || issues.Length == 0)
                {
                    Debug.Log("Array empty!");
                }
                foreach (Issue issue in issues)
                {
                    IssueCache.AddIssue(issue);
                }
                return(issues);
            }
        }