package org.kohsuke.github; import java.io.IOException; import java.util.Date; /** * A conversation in the notification API. * * @see documentation * @see GHNotificationStream * @author Kohsuke Kawaguchi */ public class GHThread extends GHObject { private GitHub root; private GHRepository repository; private Subject subject; private String reason; private boolean unread; private String last_read_at; private String url; static class Subject { String title; String url; String latest_comment_url; String type; } private GHThread() {// no external construction allowed } /** * Returns null if the entire thread has never been read. */ public Date getLastReadAt() { return GitHub.parseDate(last_read_at); } public String getReason() { return reason; } public GHRepository getRepository() { return repository; } // TODO: how to expose the subject? public boolean isRead() { return !unread; } public String getTitle() { return subject.title; } public String getType() { return subject.type; } /*package*/ GHThread wrap(GitHub root) { this.root = root; if (this.repository!=null) this.repository.wrap(root); return this; } /** * Marks this thread as read. */ public void markAsRead() throws IOException { new Requester(root).method("PATCH").to(url); } }