@Override
public Gist createGist(String userName, String description, Visibility visibility,
Map<String, String> contents) {
GitHubApiUrlBuilder builder = createGitHubApiUrlBuilder(GitHubApiUrls.GistApiUrls.CREATE_GIST_URL);
String apiUrl = builder.withField(ParameterNames.USER_NAME, userName).buildUrl();
Gist gist = new Gist();
gist.setDescription(description);
gist.setVisibility(visibility);
for (String filename : contents.keySet()) {
File file = new File();
file.setFilename(filename);
file.setContent(contents.get(filename));
gist.getFiles().put(filename, file);
}
JsonObject json = unmarshall(callApiMethod(apiUrl, marshall(gist), ApplicationConstants.CONTENT_TYPE_JSON, HttpMethod.POST, 201));
return unmarshall(new TypeToken<Gist>(){}, json);
}