Class GHUser

All Implemented Interfaces:
HttpRequestInterface, JSONHelper
Direct Known Subclasses:
SelfUser

public class GHUser extends EntityBase
Represents a GitHub user. This class provides methods and properties to access information about a user on GitHub.
  • Field Details

    • github

      protected final Github github
  • Constructor Details

    • GHUser

      public GHUser(Github github, org.json.JSONObject jsonObject)
      Constructs a new GHUser instance with the provided JSON object.
      Parameters:
      jsonObject - the JSON object containing the user data
  • Method Details

    • toJSONObject

      public org.json.JSONObject toJSONObject()
      Converts this user instance to a JSONObject.
      Overrides:
      toJSONObject in class EntityBase
      Returns:
      a JSONObject representation of this user
    • getUser

      public static GHUser getUser(Github github, String name)
      Fetches a GitHub user by their username.
      Parameters:
      github - the GitHub instance
      name - the username of the user to fetch
      Returns:
      a GHUser instance representing the fetched user
    • getFollowersUrl

      public String getFollowersUrl()
      Returns the URL for fetching the followers of this user.
      Returns:
      the followers URL
    • getFollowingUrl

      public String getFollowingUrl()
      Returns the URL for fetching the users followed by this user.
      Returns:
      the following URL
    • getGistsUrl

      public String getGistsUrl()
      Returns the URL for fetching the gists of this user.
      Returns:
      the gists URL
    • getReceivedEventsUrl

      public String getReceivedEventsUrl()
      Returns the URL for fetching the events received by this user.
      Returns:
      the received events URL
    • getStarredUrl

      public String getStarredUrl()
      Returns the URL for fetching the repositories starred by this user.
      Returns:
      the starred URL
    • getSubscriptionsUrl

      public String getSubscriptionsUrl()
      Returns the URL for fetching the subscriptions of this user.
      Returns:
      the subscriptions URL
    • getGravatarId

      public String getGravatarId()
      Returns the gravatar ID of this user.
      Returns:
      the gravatar ID
    • getOrganizationsUrl

      public String getOrganizationsUrl()
      Returns the URL for fetching the organizations of this user.
      Returns:
      the organizations URL
    • getContributions

      public int getContributions()
      Returns the number of contributions made by this user.
      Returns:
      the number of contributions
    • isSiteAdmin

      public boolean isSiteAdmin()
      Returns whether this user is a site administrator.
      Returns:
      true if the user is a site administrator, false otherwise
    • findRepositoryByName

      public GHRepository findRepositoryByName(String name)
      Finds and returns a repository by its name for the current user.
      Parameters:
      name - the name of the repository to find
      Returns:
      the GHRepository instance representing the found repository
    • getFollowers

      public List<GHUser> getFollowers()
      Fetches and returns a list of users who are followers of the current user.
      Returns:
      a list of GHUser instances representing the followers of the current user
    • getFollowing

      public List<GHUser> getFollowing()
      Fetches and returns a list of users who the current user is following.
      Returns:
      a list of GHUser instances representing the users the current user is following
    • getPublicKeys

      public List<GHPublicKey> getPublicKeys()
      Fetches and returns a list of public keys associated with the current user.
      Returns:
      a list of GHPublicKey instances representing the public keys of the current user
    • listRepositories

      public List<GHRepository> listRepositories()
      Fetches and returns a list of repositories owned by the current user.
      Returns:
      a list of GHRepository instances representing the repositories owned by the current user