Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Sawicki2011-04-13 20:38:33 +0000
committerChris Aniszczyk2011-04-14 14:59:32 +0000
commit7b0fcb59931fca160761504e374543c3ad5160a8 (patch)
tree5fafa31e55554a3a50397ac5a839563ea56b4e25
parent57d357dc53cb589abbf66db64ec55bcdc52679e7 (diff)
downloadegit-github-7b0fcb59931fca160761504e374543c3ad5160a8.tar.gz
egit-github-7b0fcb59931fca160761504e374543c3ad5160a8.tar.xz
egit-github-7b0fcb59931fca160761504e374543c3ad5160a8.zip
Add support for creating and getting a gist's comments
Change-Id: I3c07175d016924830c164915f0810b322bb9a069 Signed-off-by: Kevin Sawicki <kevin@github.com> Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
-rw-r--r--org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/GistService.java40
1 files changed, 40 insertions, 0 deletions
diff --git a/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/GistService.java b/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/GistService.java
index 55ad5dc6..8cc848bf 100644
--- a/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/GistService.java
+++ b/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/GistService.java
@@ -11,7 +11,9 @@
package org.eclipse.mylyn.github.internal;
import java.io.IOException;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import org.eclipse.core.runtime.Assert;
@@ -83,4 +85,42 @@ public class GistService {
return this.client.post(uri.toString(), gist, Gist.class);
}
+ /**
+ * Create comment on specified gist id
+ *
+ * @param gistId
+ * @param comment
+ * @return created issue
+ * @throws IOException
+ */
+ public Comment createComment(String gistId, String comment)
+ throws IOException {
+ StringBuilder uri = new StringBuilder(IGitHubConstants.SEGMENT_GISTS);
+ uri.append('/').append(gistId);
+ uri.append(IGitHubConstants.SEGMENT_COMMENTS).append(
+ IGitHubConstants.SUFFIX_JSON);
+
+ Map<String, String> params = new HashMap<String, String>(1, 1);
+ params.put(IssueService.FIELD_BODY, comment);
+ return this.client.post(uri.toString(), params, Comment.class);
+ }
+
+ /**
+ * Get comments for specified gist id
+ *
+ * @param gistId
+ * @return list of comments
+ * @throws IOException
+ */
+ public List<Comment> getComments(String gistId) throws IOException {
+ StringBuilder uri = new StringBuilder(IGitHubConstants.SEGMENT_GISTS);
+ uri.append('/').append(gistId);
+ uri.append(IGitHubConstants.SEGMENT_COMMENTS).append(
+ IGitHubConstants.SUFFIX_JSON);
+
+ TypeToken<List<Comment>> commentToken = new TypeToken<List<Comment>>() {
+ };
+ return this.client.get(uri.toString(), commentToken.getType());
+ }
+
}

Back to the top