Example #1
0
    public async Task SearchForGitHub()
    {
        var request = new SearchUsersRequest("github");
        var repos = await _gitHubClient.Search.SearchUsers(request);

        Assert.NotEmpty(repos.Items);
    }
Example #2
0
        public List<Developer> page(int page = 1, int size = 40)
        {
            var credentials = new Octokit.Credentials(ConfigurationManager.AppSettings["user_git"], ConfigurationManager.AppSettings["pass_git"]);
            Octokit.Connection connection = new Connection(new ProductHeaderValue("DevStore"));
            Octokit.ApiConnection apiConn = new ApiConnection(connection);
            Octokit.SearchUsersRequest search = new SearchUsersRequest("a");
            search.AccountType = AccountSearchType.User;
            search.PerPage = size;
            search.Page = page;
            Octokit.UsersClient userCliente = new UsersClient(apiConn);
            Octokit.SearchClient searchUserService = new SearchClient(apiConn);
            SearchUsersResult usersResult = searchUserService.SearchUsers(search).Result;
            Octokit.GitHubClient gitClient = new GitHubClient(connection);
            Octokit.UsersClient userClient = new UsersClient(apiConn);
            List<Developer> developers = (from userGit in usersResult.Items
                                          select new Developer
                                          {
                                              User = userGit.Login,
                                              UrlAvatar = userGit.AvatarUrl.ToString(),
                                              TotalRepo = userGit.PublicRepos,
                                              TotalFollowers = userGit.Followers,
                                              Price = ((userGit.PublicRepos * pesoTotalRepository) + (userGit.Followers * pesoTotalFollowers)) / (pesoTotalRepository + pesoTotalFollowers)
                                          }).ToList();

            return developers;
        }
        public void ReturnsAReadOnlyDictionary()
        {
            var request = new SearchUsersRequest("test");

            var result = request.MergedQualifiers();

            // If I can cast this to a writeable collection, then that defeats the purpose of a read only.
            AssertEx.IsReadOnlyCollection<string>(result);
        }
 /// <summary>
 /// Local func for performing an exception-safe user search
 /// </summary>
 /// <param name="ct">cancellation token</param>
 /// <param name="search">search request</param>
 /// <returns></returns>
 private async Task<SearchUsersResult> SearchUsers(CancellationToken ct, SearchUsersRequest search)
 {
     try
     {
         ct.ThrowIfCancellationRequested();
         return await CreateGitClient().Search.SearchUsers(search);
     }
     catch(Exception e) when (e is OperationCanceledException || e is RateLimitExceededException || e is ApiValidationException)
     {
         cts.Cancel();
         Hit1000Limit = true;
         return await Task.FromResult(new SearchUsersResult(0, true, new List<User>()));
     }
 }
 /// <summary>
 /// search users
 /// http://developer.github.com/v3/search/#search-users
 /// </summary>
 /// <param name="search"></param>
 /// <returns>List of users</returns>
 public Task <IReadOnlyList <User> > SearchUsers(SearchUsersRequest search)
 {
     Ensure.ArgumentNotNull(search, "search");
     return(ApiConnection.GetAll <User>(ApiUrls.SearchUsers(), search.Parameters));
 }
 public Task <SearchUsersResult> SearchUsers(SearchUsersRequest search)
 {
     Ensure.ArgumentNotNull(search, nameof(search));
     return(ApiConnection.Get <SearchUsersResult>(ApiUrls.SearchUsers(), search.Parameters));
 }
Example #7
0
 /// <summary>
 /// search users
 /// http://developer.github.com/v3/search/#search-users
 /// </summary>
 /// <param name="search"></param>
 /// <returns>List of users</returns>
 public Task<SearchUsersResult> SearchUsers(SearchUsersRequest search)
 {
     Ensure.ArgumentNotNull(search, "search");
     return ApiConnection.Get<SearchUsersResult>(ApiUrls.SearchUsers(), search.Parameters);
 }
Example #8
0
 /// <summary>
 /// search users
 /// http://developer.github.com/v3/search/#search-users
 /// </summary>
 /// <param name="search"></param>
 /// <returns>List of users</returns>
 public Task<IReadOnlyList<User>> SearchUsers(SearchUsersRequest search)
 {
     Ensure.ArgumentNotNull(search, "search");
     return ApiConnection.GetAll<User>(ApiUrls.SearchUsers(), search.Parameters);
 }
 public void SortNotSpecifiedByDefault()
 {
     var request = new SearchUsersRequest("shiftkey");
     Assert.True(string.IsNullOrWhiteSpace(request.Sort));
     Assert.False(request.Parameters.ContainsKey("sort"));
 }