Class NotificationsClient

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

public class NotificationsClient extends GithubClient
GitHub 通知 API 客户端。

提供通知的列表查询、标记已读、线程订阅管理、仓库通知管理等功能。

对应 GitHub REST API 文档: Notifications

See Also:
  • Constructor Details

    • NotificationsClient

      public NotificationsClient(GithubClient parent)
  • Method Details

    • list

      public Page<Thread> list(ListNotificationsOptions options)
      列出当前认证用户的所有通知。

      API 端点: GET /notifications

      Parameters:
      options - 列表选项(是否显示全部、参与状态、时间范围筛选、分页),可为 null
      Returns:
      分页的通知线程列表
    • getThread

      public GithubResponse<Thread> getThread(long threadId)
      获取指定通知线程的详细信息。

      API 端点: GET /notifications/threads/{thread_id}

      Parameters:
      threadId - 通知线程的 ID
      Returns:
      通知线程详细信息
    • markAsRead

      public GithubResponse<Thread> markAsRead(long threadId)
      将指定通知线程标记为已读。

      API 端点: PATCH /notifications/threads/{thread_id}

      Parameters:
      threadId - 通知线程的 ID
      Returns:
      更新后的通知线程信息
    • markAllAsRead

      public void markAllAsRead(Map<String,String> body)
      将当前认证用户的所有通知标记为已读。

      API 端点: PUT /notifications

      Parameters:
      body - 请求参数(包含 last_read_at 时间戳等)
    • markThreadAsDone

      public GithubResponse<Void> markThreadAsDone(long threadId)
      将指定通知线程标记为已完成(从列表中移除)。

      API 端点: DELETE /notifications/threads/{thread_id}

      Parameters:
      threadId - 通知线程的 ID
      Returns:
      操作结果
    • getThreadSubscription

      public GithubResponse<Subscription> getThreadSubscription(long threadId)
      获取指定通知线程的订阅状态。

      API 端点: GET /notifications/threads/{thread_id}/subscription

      Parameters:
      threadId - 通知线程的 ID
      Returns:
      订阅状态信息(包含 subscribed 和 ignored 字段)
    • setThreadSubscription

      public GithubResponse<Subscription> setThreadSubscription(long threadId, Map<String,Boolean> body)
      设置指定通知线程的订阅状态。

      API 端点: PUT /notifications/threads/{thread_id}/subscription

      Parameters:
      threadId - 通知线程的 ID
      body - 订阅参数(包含 subscribed 和 ignored 布尔值)
      Returns:
      更新后的订阅状态信息
    • deleteThreadSubscription

      public void deleteThreadSubscription(long threadId)
      删除指定通知线程的订阅。

      API 端点: DELETE /notifications/threads/{thread_id}/subscription

      Parameters:
      threadId - 通知线程的 ID
    • listForRepo

      public Page<Thread> listForRepo(String owner, String repo, ListNotificationsOptions options)
      列出指定仓库的通知。

      API 端点: GET /repos/{owner}/{repo}/notifications

      Parameters:
      owner - 仓库所有者
      repo - 仓库名称
      options - 列表选项(是否显示全部、参与状态、时间范围筛选、分页),可为 null
      Returns:
      分页的通知线程列表
    • markRepoNotificationsAsRead

      public void markRepoNotificationsAsRead(String owner, String repo, Map<String,String> body)
      将指定仓库的所有通知标记为已读。

      API 端点: PUT /repos/{owner}/{repo}/notifications

      Parameters:
      owner - 仓库所有者
      repo - 仓库名称
      body - 请求参数(包含 last_read_at 时间戳等)