예제 #1
0
        /// <summary>
        /// Gets list of repositories of specified user.
        /// </summary>
        /// <param name="username">The username.</param>
        /// <returns>ClientResponse with collection of repositories.</returns>
        public async Task <ClientResponse <IEnumerable <FullRepositoryData> > > GetUserRepositories(string username)
        {
            if (username == string.Empty)
            {
                var clientResponse = new ClientResponse <IEnumerable <FullRepositoryData> >
                {
                    Message = MessagesHelper.EmptyDataMessage,
                    Status  = OperationStatus.EmptyData
                };
                return(clientResponse);
            }

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

            return(await this.requestSender.ProcessHttpResponse <IEnumerable <FullRepositoryData> >(httpresponse, MessagesHelper.GenerateUserNotFoundMessage(username)));
        }