예제 #1
0
        /// <summary>
        /// Get full repository data based on basic repository data.
        /// </summary>
        /// <param name="repositoryData">Basic repository data.</param>
        /// <returns>Full repository data of specified repository.</returns>
        public async Task <ClientResponse <FullRepositoryData> > GetFullRepositoryData(BasicRepositoryData repositoryData)
        {
            var url = $"/{UrlConstants.RepositoriesUrlPart}/{repositoryData.Owner.Login}/{repositoryData.Name}";
            HttpResponseMessage httpresponse = await this.requestSender.SendGetRequestToGitHubApiAsync(url);

            var clientresponse = new ClientResponse <FullRepositoryData>();

            return(await this.requestSender.ProcessHttpResponse <FullRepositoryData>(
                       httpresponse,
                       MessagesHelper.GenerateUserOrRepositoryNotFoundMessage(repositoryData.Owner.Login, repositoryData.Name)));
        }
예제 #2
0
        /// <summary>
        /// Gets branches list of specified repository.
        /// </summary>
        /// <param name="username">The name of repository owner.</param>
        /// <param name="repositoryName">The repository name.</param>
        /// <returns>ClientResponse instance with collection of branches.</returns>
        public async Task <ClientResponse <IEnumerable <Branch> > > GetBranchList(string username, string repositoryName)
        {
            if (username == string.Empty || repositoryName == string.Empty)
            {
                var clientResponse = new ClientResponse <IEnumerable <Branch> >
                {
                    Message = MessagesHelper.EmptyDataMessage,
                    Status  = OperationStatus.EmptyData
                };
                return(clientResponse);
            }

            var url = $"/{UrlConstants.RepositoriesUrlPart}/{username}/{repositoryName}/{UrlConstants.BranchesUrlPart}";
            HttpResponseMessage httpResponse = await this.requestSender.SendGetRequestToGitHubApiAsync(url);

            return(await this.requestSender.ProcessHttpResponse <IEnumerable <Branch> >(
                       httpResponse,
                       MessagesHelper.GenerateUserOrRepositoryNotFoundMessage(username, repositoryName)));
        }