Ejemplo n.º 1
0
        /// <summary>
        /// Returns collection of organizations to which the specified user belongs.
        /// </summary>
        /// <returns></returns>
        public IEnumerable <GitHubOrganization> GetOrganizations(GitHubUser user)
        {
            var organizations = new List <GitHubOrganization>();

            JsonParser.ParseCollection(user.OrganizationsUrl + this.ParseUrlArguments(), (token) =>
            {
                string json = token.ToString();
                GitHubOrganization follower = new GitHubOrganization(json);

                organizations.Add(follower);
            });

            return(organizations);
        }
Ejemplo n.º 2
0
        public static GitHubOrganizationResponse ParseResponse(SocialHttpResponse response)
        {
            // Parse the raw JSON response
            JsonObject obj = response.GetBodyAsJsonObject();

            // Check for any errors
            if (response.StatusCode != HttpStatusCode.OK)
            {
                string message = obj.GetString("message");
                string url     = obj.GetString("documentation_url");
                throw new GitHubHttpException(response.StatusCode, message, url);
            }

            // Initialize the object to be returned
            return(new GitHubOrganizationResponse(response)
            {
                Data = GitHubOrganization.Parse(obj)
            });
        }