Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for update/delete operations on issue comments #201

Merged
merged 1 commit into from
Jul 17, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/main/java/org/kohsuke/github/GHIssue.java
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,9 @@ public URL getApiURL(){
/**
* Updates the issue by adding a comment.
*/
public void comment(String message) throws IOException {
new Requester(root).with("body",message).to(getIssuesApiRoute() + "/comments");
public GHIssueComment comment(String message) throws IOException {
GHIssueComment r = new Requester(root).with("body",message).to(getIssuesApiRoute() + "/comments", GHIssueComment.class);
return r.wrapUp(this);
}

private void edit(String key, Object value) throws IOException {
Expand Down
19 changes: 19 additions & 0 deletions src/main/java/org/kohsuke/github/GHIssueComment.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,23 @@ public GHUser getUser() throws IOException {
public URL getHtmlUrl() {
return null;
}

/**
* Updates the body of the issue comment.
*/
public void update(String body) throws IOException {
new Requester(owner.root).with("body", body).method("PATCH").to(getCommentApiTail(), GHIssueComment.class);
this.body = body;
}

/**
* Deletes this issue comment.
*/
public void delete() throws IOException {
new Requester(owner.root).method("DELETE").to(getCommentApiTail());
}

private String getCommentApiTail() {
return "/repos/"+owner.getRepository().getOwnerName()+"/"+owner.getRepository().getName()+"/issues/comments/" + id;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ protected String getApiRoute() {
*/
public void update(String body) throws IOException {
new Requester(owner.root).method("PATCH").with("body", body).to(getApiRoute(),this);
this.body = body;
}

/**
Expand Down