summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Sawicki2011-04-13 13:46:26 (EDT)
committer Chris Aniszczyk2011-04-14 10:56:42 (EDT)
commit546cb834e9ed9fd541167fb4f6abd86d3b2453bc (patch)
tree27af48922af0524e2bc5403d204cc3ad10e4a2ad
parentc7661f48402d24a0604dffa79aca0681aa64c0b6 (diff)
downloadegit-github-546cb834e9ed9fd541167fb4f6abd86d3b2453bc.zip
egit-github-546cb834e9ed9fd541167fb4f6abd86d3b2453bc.tar.gz
egit-github-546cb834e9ed9fd541167fb4f6abd86d3b2453bc.tar.bz2
Add support for creating gists using new APIrefs/changes/97/3097/3
Change-Id: Id4f923be2ade1c418f091d23aaae62f446670781 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/Gist.java36
-rw-r--r--org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/GistFile.java18
-rw-r--r--org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/GistService.java19
-rw-r--r--org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/User.java9
4 files changed, 82 insertions, 0 deletions
diff --git a/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/Gist.java b/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/Gist.java
index 56e1690..f00c2b1 100644
--- a/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/Gist.java
+++ b/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/Gist.java
@@ -51,6 +51,15 @@ public class Gist {
}
/**
+ * @param isPublic
+ * @return this gist
+ */
+ public Gist setPublic(boolean isPublic) {
+ this.isPublic = isPublic;
+ return this;
+ }
+
+ /**
* @return createdAt
*/
public Date getCreatedAt() {
@@ -72,6 +81,15 @@ public class Gist {
}
/**
+ * @param files
+ * @return this gist
+ */
+ public Gist setFiles(Map<String, GistFile> files) {
+ this.files = files;
+ return this;
+ }
+
+ /**
* @return description
*/
public String getDescription() {
@@ -79,6 +97,15 @@ public class Gist {
}
/**
+ * @param description
+ * @return this gist
+ */
+ public Gist setDescription(String description) {
+ this.description = description;
+ return this;
+ }
+
+ /**
* @return gitPullUrl
*/
public String getGitPullUrl() {
@@ -120,4 +147,13 @@ public class Gist {
return this.author;
}
+ /**
+ * @param author
+ * @return this gist
+ */
+ public Gist setAuthor(User author) {
+ this.author = author;
+ return this;
+ }
+
}
diff --git a/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/GistFile.java b/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/GistFile.java
index 10f022a..ff56ae2 100644
--- a/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/GistFile.java
+++ b/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/GistFile.java
@@ -17,6 +17,8 @@ public class GistFile {
private int size;
+ private String content;
+
private String filename;
private String rawUrl;
@@ -29,6 +31,22 @@ public class GistFile {
}
/**
+ * @return content
+ */
+ public String getContent() {
+ return this.content;
+ }
+
+ /**
+ * @param content
+ * @return this gist file
+ */
+ public GistFile setContent(String content) {
+ this.content = content;
+ return this;
+ }
+
+ /**
* @return filename
*/
public String getFilename() {
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 00cf2f3..55ad5dc 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
@@ -64,4 +64,23 @@ public class GistService {
return this.client.get(uri.toString(), gistToken.getType());
}
+ /**
+ * Create a gist
+ *
+ * @param gist
+ * @return created gist
+ * @throws IOException
+ */
+ public Gist createGist(Gist gist) throws IOException {
+ StringBuilder uri = new StringBuilder();
+ User user = gist.getAuthor();
+ if (user != null) {
+ uri.append(IGitHubConstants.SEGMENT_USERS);
+ uri.append('/').append(user.getLogin());
+ }
+ uri.append(IGitHubConstants.SEGMENT_GISTS).append(
+ IGitHubConstants.SUFFIX_JSON);
+ return this.client.post(uri.toString(), gist, Gist.class);
+ }
+
}
diff --git a/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/User.java b/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/User.java
index 39c63ad..b1f3ab2 100644
--- a/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/User.java
+++ b/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/User.java
@@ -78,6 +78,15 @@ public class User {
}
/**
+ * @param login
+ * @return this user
+ */
+ public User setLogin(String login) {
+ this.login = login;
+ return this;
+ }
+
+ /**
* @return name
*/
public String getName() {