diff --git a/pom.xml b/pom.xml
index 8c0582e1c9..2acbbfdafa 100644
--- a/pom.xml
+++ b/pom.xml
@@ -7,7 +7,7 @@
github-api
- 1.38
+ 1.39
GitHub API for Java
http://github-api.kohsuke.org/
GitHub API for Java
diff --git a/src/main/java/org/kohsuke/github/GHAuthorization.java b/src/main/java/org/kohsuke/github/GHAuthorization.java
new file mode 100644
index 0000000000..dae2c74115
--- /dev/null
+++ b/src/main/java/org/kohsuke/github/GHAuthorization.java
@@ -0,0 +1,94 @@
+package org.kohsuke.github;
+
+import java.net.URL;
+import java.util.Collection;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * Generated OAuth token
+ *
+ * @author janinko
+ * @see GitHub#createToken(Collection, String, String)
+ * @see http://developer.github.com/v3/oauth/#create-a-new-authorization
+ */
+public class GHAuthorization {
+ public static final String USER = "user";
+ public static final String USER_EMAIL = "user:email";
+ public static final String USER_FOLLOW = "user:follow";
+ public static final String PUBLIC_REPO = "public_repo";
+ public static final String REPO = "repo";
+ public static final String REPO_STATUS = "repo:status";
+ public static final String DELETE_REPO = "delete_repo";
+ public static final String NOTIFICATIONS = "notifications";
+ public static final String GIST = "gist";
+
+ private GitHub root;
+ private int id;
+ private String url;
+ private List scopes;
+ private String token;
+ private App app;
+ private String note;
+ private String note_url;
+ private String updated_at;
+ private String created_at;
+
+ public GitHub getRoot() {
+ return root;
+ }
+
+ public int getId() {
+ return id;
+ }
+
+ public List getScopes() {
+ return scopes;
+ }
+
+ public String getToken(){
+ return token;
+ }
+
+ public URL getAppUrl(){
+ return GitHub.parseURL(app.url);
+ }
+
+ public String getAppName() {
+ return app.name;
+ }
+
+ public URL getApiURL(){
+ return GitHub.parseURL(url);
+ }
+
+ public String getNote() {
+ return note;
+ }
+
+ public URL getNoteUrl(){
+ return GitHub.parseURL(note_url);
+ }
+
+ public Date getCreatedAt() {
+ return GitHub.parseDate(created_at);
+ }
+
+ public Date getUpdatedAt() {
+ return GitHub.parseDate(updated_at);
+ }
+
+ /*package*/ GHAuthorization wrap(GitHub root) {
+ this.root = root;
+ return this;
+ }
+
+
+
+
+
+ private static class App{
+ private String url;
+ private String name;
+ }
+}
diff --git a/src/main/java/org/kohsuke/github/GHEventPayload.java b/src/main/java/org/kohsuke/github/GHEventPayload.java
index efb3d0d3fe..5d666f5090 100644
--- a/src/main/java/org/kohsuke/github/GHEventPayload.java
+++ b/src/main/java/org/kohsuke/github/GHEventPayload.java
@@ -18,10 +18,15 @@ public abstract class GHEventPayload {
this.root = root;
}
+ /**
+ * A pull request status has changed.
+ *
+ * @see http://developer.github.com/v3/activity/events/types/#pullrequestevent
+ */
public static class PullRequest extends GHEventPayload {
private String action;
private int number;
- GHPullRequest pull_request;
+ private GHPullRequest pull_request;
public String getAction() {
return action;
@@ -43,4 +48,51 @@ void wrapUp(GitHub root) {
}
}
+ /**
+ * A comment was added to an issue
+ *
+ * @see http://developer.github.com/v3/activity/events/types/#issuecommentevent
+ */
+ public static class IssueComment extends GHEventPayload {
+ private String action;
+ private GHIssueComment comment;
+ private GHIssue issue;
+ private GHRepository repository;
+
+ public String getAction() {
+ return action;
+ }
+
+ public GHIssueComment getComment() {
+ return comment;
+ }
+
+ public void setComment(GHIssueComment comment) {
+ this.comment = comment;
+ }
+
+ public GHIssue getIssue() {
+ return issue;
+ }
+
+ public void setIssue(GHIssue issue) {
+ this.issue = issue;
+ }
+
+ public GHRepository getRepository() {
+ return repository;
+ }
+
+ public void setRepository(GHRepository repository) {
+ this.repository = repository;
+ }
+
+ @Override
+ void wrapUp(GitHub root) {
+ super.wrapUp(root);
+ repository.wrap(root);
+ issue.wrap(repository);
+ comment.wrapUp(issue);
+ }
+ }
}
diff --git a/src/main/java/org/kohsuke/github/GitHub.java b/src/main/java/org/kohsuke/github/GitHub.java
index 177f197819..6c7999492b 100644
--- a/src/main/java/org/kohsuke/github/GitHub.java
+++ b/src/main/java/org/kohsuke/github/GitHub.java
@@ -39,11 +39,14 @@
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Arrays;
+import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Properties;
+import java.util.Set;
import java.util.TimeZone;
import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.*;
@@ -303,6 +306,22 @@ public GHRepository createRepository(String name, String description, String hom
return requester.method("POST").to("/user/repos", GHRepository.class).wrap(this);
}
+ /**
+ * Creates a new authorization.
+ *
+ * The token created can be then used for {@link GitHub#connectUsingOAuth(String)} in the future.
+ *
+ * @see http://developer.github.com/v3/oauth/#create-a-new-authorization
+ */
+ public GHAuthorization createToken(Collection scope, String note, String noteUrl) throws IOException{
+ Requester requester = new Requester(this)
+ .with("scopes", scope)
+ .with("note", note)
+ .with("note_url", noteUrl);
+
+ return requester.method("POST").to("/authorizations", GHAuthorization.class).wrap(this);
+ }
+
/**
* Ensures that the credential is valid.
*/