Пример #1
0
        public void SetAuthorizedUser()
        {
            var responseBody = GitlabApi.GetMe(AccessToken);

            if (string.IsNullOrEmpty(responseBody))
            {
                return;
            }

            var json = JObject.Parse(responseBody);

            User = new GitLabUser()
            {
                Id    = json.Value <int>("id"),
                Login = json.Value <string>("username"),
                Email = json.Value <string>("email")
            };
        }
Пример #2
0
        public ExternalRepo[] GetMyPublicRepositories(UserModel user)
        {
            var response = GitlabApi.GetUserPublicProjects(User.Id.ToString());

            var result = new List <ExternalRepo>();

            var repos = JArray.Parse(response);

            foreach (var repo in repos.Children())
            {
                result.Add(new ExternalRepo()
                {
                    Owner       = user,
                    Id          = repo.Value <string>("id"),
                    Name        = User.Login + "/" + repo.Value <string>("name").ToLower().Replace(' ', '-'),
                    Description = repo.Value <string>("description"),
                    ServiceType = ServiceType.GitLab
                });
            }

            return(result.ToArray());
        }