Exemplo n.º 1
0
        /// <summary>
        /// Gets a Requirements Bazaar requirement by its id
        /// </summary>
        /// <param name="requirementId">The id of the requirement</param>
        /// <returns>The requirement as a general issue, contained in the APIResult object</returns>
        public static async Task <ApiResult <Issue> > GetRequirement(int requirementId)
        {
            Issue cached = IssueCache.GetRequirement(requirementId);

            if (cached != null)
            {
                return(new ApiResult <Issue>(cached));
            }

            Response resp = await Rest.GetAsync(
                ConnectionManager.Instance.BackendAPIBaseURL + "requirementsBazaar/requirements/" + requirementId,
                null,
                -1,
                null,
                true);

            ConnectionManager.Instance.CheckStatusCode(resp.ResponseCode);
            if (!resp.Successful)
            {
                Debug.LogError(resp.ResponseCode + ": " + resp.ResponseBody);
                return(new ApiResult <Issue>(resp.ResponseCode, resp.ResponseBody));
            }
            else
            {
                Issue issue = JsonUtility.FromJson <Issue>(resp.ResponseBody);
                IssueCache.AddIssue(issue);
                return(new ApiResult <Issue>(issue));
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Gets a specific issue by its number in the given repository
        /// </summary>
        /// <param name="repositoryId">The numeric id of the repository</param>
        /// <param name="issueNumber">The (local) issue number in the repository</param>
        /// <returns>The issue; contained in an APIResult object</returns>
        public static async Task <ApiResult <Issue> > GetIssue(int repositoryId, int issueNumber)
        {
            Issue cached = IssueCache.GetGitHubIssue(repositoryId, issueNumber);

            if (cached != null)
            {
                return(new ApiResult <Issue>(cached));
            }

            Response resp = await Rest.GetAsync(
                ConnectionManager.Instance.BackendAPIBaseURL + "gitHub/repositories/" + repositoryId + "/issues/" + issueNumber,
                null,
                -1,
                null,
                true);

            ConnectionManager.Instance.CheckStatusCode(resp.ResponseCode);
            if (!resp.Successful)
            {
                Debug.LogError(resp.ResponseCode + ": " + resp.ResponseBody);
                return(new ApiResult <Issue>(resp.ResponseCode, resp.ResponseBody));
            }
            else
            {
                Issue issue = JsonUtility.FromJson <Issue>(resp.ResponseBody);
                IssueCache.AddIssue(issue);
                return(new ApiResult <Issue>(issue));
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Gets the requirements in a Requirements Bazaar Category
        /// </summary>
        /// <param name="categoryId">The id of the category</param>
        /// <param name="page">Page of the content (the overall list is divided into pages)</param>
        /// <param name="itemsPerPage">Specifies how many items should be on one page</param>
        /// <param name="search">Search pattern which filters the requirements</param>
        /// <returns>The list of requirements in the category on hte given page, contained in the APIResult object</returns>
        public static async Task <ApiResult <Issue[]> > GetRequirementsInCategory(int categoryId, int page, int itemsPerPage, string search)
        {
            string path = ConnectionManager.Instance.BackendAPIBaseURL + "requirementsBazaar/categories/" + categoryId + "/requirements?page=" + page + "&per_page=" + itemsPerPage;

            search = StringUtilities.RemoveSpecialCharacters(search);
            if (!string.IsNullOrEmpty(search))
            {
                path += "&search=" + search;
            }
            Response resp = await Rest.GetAsync(path, null, -1, null, true);

            ConnectionManager.Instance.CheckStatusCode(resp.ResponseCode);
            if (!resp.Successful)
            {
                Debug.LogError(resp.ResponseCode + ": " + resp.ResponseBody);
                return(new ApiResult <Issue[]>(resp.ResponseCode, resp.ResponseBody));
            }
            else
            {
                Issue[] requirements = JsonArrayUtility.FromJson <Issue>(resp.ResponseBody);
                foreach (Issue req in requirements)
                {
                    IssueCache.AddIssue(req);
                }
                return(new ApiResult <Issue[]>(requirements));
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// 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>
        /// <param name="page">The page of the content</param>
        /// <param name="itemsPerPage">States how many issues should be displayed on one page</param>
        /// <returns>An array of issues in the repository; contained in an APIResult object</returns>
        public static async Task <ApiResult <Issue[]> > GetIssuesInRepository(string owner, string repositoryName, int page, int itemsPerPage)
        {
            Response resp = await Rest.GetAsync(
                ConnectionManager.Instance.BackendAPIBaseURL + "gitHub/repos/" + owner + "/" + repositoryName + "/issues?page=" + page + "&per_page=" + itemsPerPage,
                null,
                -1,
                null,
                true);

            ConnectionManager.Instance.CheckStatusCode(resp.ResponseCode);
            if (!resp.Successful)
            {
                Debug.LogError(resp.ResponseCode + ": " + resp.ResponseBody);
                return(new ApiResult <Issue[]>(resp.ResponseCode, resp.ResponseBody));
            }
            else
            {
                Issue[] issues = JsonArrayUtility.FromJson <Issue>(resp.ResponseBody);
                foreach (Issue issue in issues)
                {
                    IssueCache.AddIssue(issue);
                }
                return(new ApiResult <Issue[]>(issues));
            }
        }