mirror of
https://github.com/jlengrand/github-api.git
synced 2026-03-23 00:11:24 +00:00
75 lines
1.6 KiB
Java
75 lines
1.6 KiB
Java
package org.kohsuke.github;
|
|
|
|
import java.io.IOException;
|
|
import java.util.Date;
|
|
|
|
/**
|
|
* A conversation in the notification API.
|
|
*
|
|
* @see <a href="https://developer.github.com/v3/activity/notifications/">documentation</a>
|
|
* @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);
|
|
}
|
|
}
|