Class UsersClient

java.lang.Object
ink.icoding.github4j.GithubClient
ink.icoding.github4j.client.UsersClient

public class UsersClient extends GithubClient
GitHub 用户操作客户端。

提供获取用户信息、管理关注者、邮箱、SSH 公钥等功能。

  • Constructor Details

  • Method Details

    • getAuthenticatedUser

      public GithubResponse<User> getAuthenticatedUser()
      获取当前已认证用户的信息。

      对应端点: GET /user

      Returns:
      当前已认证用户的详细信息
    • updateAuthenticatedUser

      public GithubResponse<User> updateAuthenticatedUser(Map<String,Object> updates)
      更新当前已认证用户的个人信息。

      对应端点: PATCH /user

      Parameters:
      updates - 要更新的字段(如 name, email, bio, company, location, blog 等)
      Returns:
      更新后的用户信息
    • getByUsername

      public GithubResponse<User> getByUsername(String username)
      通过用户名获取用户信息。

      对应端点: GET /users/{username}

      Parameters:
      username - 目标用户名
      Returns:
      用户的公开信息
    • listFollowers

      public Page<User> listFollowers(String username, PageOptions options)
      列出指定用户的关注者。

      对应端点: GET /users/{username}/followers

      Parameters:
      username - 目标用户名
      options - 分页参数
      Returns:
      关注者列表(分页)
    • listAuthenticatedFollowers

      public Page<User> listAuthenticatedFollowers(PageOptions options)
      列出当前已认证用户的关注者。

      对应端点: GET /user/followers

      Parameters:
      options - 分页参数
      Returns:
      关注者列表(分页)
    • listFollowing

      public Page<User> listFollowing(String username, PageOptions options)
      列出指定用户关注的人。

      对应端点: GET /users/{username}/following

      Parameters:
      username - 目标用户名
      options - 分页参数
      Returns:
      关注列表(分页)
    • listAuthenticatedFollowing

      public Page<User> listAuthenticatedFollowing(PageOptions options)
      列出当前已认证用户关注的人。

      对应端点: GET /user/following

      Parameters:
      options - 分页参数
      Returns:
      关注列表(分页)
    • checkFollowing

      public boolean checkFollowing(String targetUser)
      检查当前用户是否关注了指定用户。

      对应端点: GET /user/following/{username}

      Parameters:
      targetUser - 目标用户名
      Returns:
      true 表示已关注,false 表示未关注
    • checkFollowing

      public boolean checkFollowing(String username, String targetUser)
      检查用户 A 是否关注了用户 B。

      对应端点: GET /users/{username}/following/{target_user}

      Parameters:
      username - 用户 A
      targetUser - 用户 B
      Returns:
      true 表示已关注
    • follow

      public void follow(String targetUser)
      关注指定用户。

      对应端点: PUT /user/following/{username}

      Parameters:
      targetUser - 要关注的用户名
    • unfollow

      public void unfollow(String targetUser)
      取消关注指定用户。

      对应端点: DELETE /user/following/{username}

      Parameters:
      targetUser - 要取消关注的用户名
    • listEmails

      public Page<Email> listEmails(PageOptions options)
      列出当前已认证用户的邮箱地址。

      对应端点: GET /user/emails

      Parameters:
      options - 分页参数
      Returns:
      邮箱列表(分页)
    • listPublicEmails

      public Page<Email> listPublicEmails(String username)
      列出指定用户的公开邮箱地址。

      对应端点: GET /users/{username}/emails

      Parameters:
      username - 目标用户名
      Returns:
      公开邮箱列表(分页)
    • listPublicKeys

      public Page<PublicKey> listPublicKeys(String username)
      列出指定用户的公开 SSH 公钥。

      对应端点: GET /users/{username}/keys

      Parameters:
      username - 目标用户名
      Returns:
      SSH 公钥列表(分页)
    • listAuthenticatedKeys

      public Page<PublicKey> listAuthenticatedKeys(PageOptions options)
      列出当前已认证用户的 SSH 公钥。

      对应端点: GET /user/keys

      Parameters:
      options - 分页参数
      Returns:
      SSH 公钥列表(分页)