1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Net;
using Octokit;

namespace SourceBrowser.SolutionRetriever
{
    public class GitHubInformationRetriever
    {
        private static GitHubClient _github = new GitHubClient(new ProductHeaderValue("SourceBrowser"));

        public static void GetUserInformation(string username, ref string fullName, ref string avatarUrl, ref string gitHubUrl, ref string blogUrl)
        {
            var user = _github.User.Get(username).Result;

            avatarUrl = user.AvatarUrl;
            gitHubUrl = user.HtmlUrl;
            blogUrl = user.Blog;
            fullName = user.Name;
        }

        public static void GetRepoInformation(string userName, string repoName, ref int forksCount, ref int starsCount, ref string language, ref string homepage, ref bool isPrivate, ref string description)
        {
            var repo = _github.Repository.Get(userName, repoName).Result;

            forksCount = repo.ForksCount;
            starsCount = repo.StargazersCount;
            language = repo.Language;
            homepage = repo.Homepage;
            isPrivate = repo.Private;
            description = repo.Description;
        }

    }
}