Skip to content

Commit 74b8e93

Browse files
committed
More Feed Methods.
1 parent 2c2e44f commit 74b8e93

File tree

6 files changed

+85
-1
lines changed

6 files changed

+85
-1
lines changed

core/src/main/java/com/github/api/v2/services/FeedService.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,9 @@ public interface FeedService extends GitHubService {
3030
public Feed getNetworkFeed(String userName, String repositoryName);
3131
public Feed getWikiFeed(String userName, String repositoryName);
3232
public Feed getPublicTimelineFeed();
33+
34+
public Feed getDiscussionsFeed();
35+
public Feed getDiscussionsFeed(String topic);
36+
public Feed getJobPositionsFeed();
37+
public Feed getBlogFeed();
3338
}

core/src/main/java/com/github/api/v2/services/constant/GitHubApiUrls.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,18 @@ public static interface FeedUrls {
320320

321321
/** The Constant GET_PUBLIC_TIMELINE_FEED_URL. */
322322
public static final String GET_PUBLIC_TIMELINE_FEED_URL = gitHubApiUrls.getProperty("com.github.api.v2.services.feedService.getPublicTimelineFeed");
323+
324+
/** The Constant GET_DISCUSSIONS_FEED_URL. */
325+
public static final String GET_DISCUSSIONS_FEED_URL = gitHubApiUrls.getProperty("com.github.api.v2.services.feedService.getDiscussionsFeed");
326+
327+
/** The Constant GET_DISCUSSIONS_FEED_BY_TOPIC_URL. */
328+
public static final String GET_DISCUSSIONS_FEED_BY_TOPIC_URL = gitHubApiUrls.getProperty("com.github.api.v2.services.feedService.getDiscussionsFeedByTopic");
329+
330+
/** The Constant GET_JOB_POSITIONS_FEED_URL. */
331+
public static final String GET_JOB_POSITIONS_FEED_URL = gitHubApiUrls.getProperty("com.github.api.v2.services.feedService.getJobPositionsFeed");
332+
333+
/** The Constant GET_BLOG_FEED_URL. */
334+
public static final String GET_BLOG_FEED_URL = gitHubApiUrls.getProperty("com.github.api.v2.services.feedService.getBlogFeed");
323335
}
324336

325337
/**

core/src/main/java/com/github/api/v2/services/impl/FeedServiceImpl.java

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,35 @@ public Feed getWikiFeed(String userName, String repositoryName) {
8787
return unmarshall(callApiGet(apiUrl));
8888
}
8989

90+
@Override
91+
public Feed getBlogFeed() {
92+
GitHubApiUrlBuilder builder = createGitHubApiUrlBuilder(GitHubApiUrls.FeedUrls.GET_BLOG_FEED_URL);
93+
String apiUrl = builder.buildUrl();
94+
return unmarshall(callApiGet(apiUrl));
95+
}
96+
97+
@Override
98+
public Feed getDiscussionsFeed() {
99+
GitHubApiUrlBuilder builder = createGitHubApiUrlBuilder(GitHubApiUrls.FeedUrls.GET_DISCUSSIONS_FEED_URL);
100+
String apiUrl = builder.buildUrl();
101+
return unmarshall(callApiGet(apiUrl));
102+
}
103+
104+
@Override
105+
public Feed getDiscussionsFeed(String topic) {
106+
GitHubApiUrlBuilder builder = createGitHubApiUrlBuilder(GitHubApiUrls.FeedUrls.GET_DISCUSSIONS_FEED_BY_TOPIC_URL);
107+
String apiUrl = builder.withField(ParameterNames.KEYWORD, topic).buildUrl();
108+
return unmarshall(callApiGet(apiUrl));
109+
}
110+
111+
@Override
112+
public Feed getJobPositionsFeed() {
113+
GitHubApiUrlBuilder builder = createGitHubApiUrlBuilder(GitHubApiUrls.FeedUrls.GET_JOB_POSITIONS_FEED_URL);
114+
String apiUrl = builder.buildUrl();
115+
return unmarshall(callApiGet(apiUrl));
116+
}
117+
118+
90119
protected Feed unmarshall(InputStream is) {
91120
try {
92121
final SyndFeedInput input = new SyndFeedInput();

core/src/main/resources/com/github/api/v2/services/constant/GitHubApiUrls.properties

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,4 +92,7 @@ com.github.api.v2.services.feedService.getCommitFeed=http://github.com/{userName
9292
com.github.api.v2.services.feedService.getNetworkFeed=http://github.com/{userName}/{repositoryName}/network/feed
9393
com.github.api.v2.services.feedService.getWikiFeed=http://wiki.github.com/{userName}/{repositoryName}/wikis.atom
9494
com.github.api.v2.services.feedService.getPublicTimelineFeed=http://github.com/timeline.atom
95-
95+
com.github.api.v2.services.feedService.getDiscussionsFeed=http://support.github.com/discussions.atom
96+
com.github.api.v2.services.feedService.getDiscussionsFeedByTopic=http://support.github.com/discussions/{keyword}.atom
97+
com.github.api.v2.services.feedService.getJobPositionsFeed=http://jobs.github.com/positions.atom
98+
com.github.api.v2.services.feedService.getBlogFeed=http://feeds.feedburner.com/github?format=rss

core/src/test/java/com/github/api/v2/services/FeedServiceTest.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,4 +89,32 @@ public void testGetWikiFeed() {
8989
assertNotNull("Feed cannot be null.", feed);
9090
assertNotNullOrEmpty("Feed entries cannot be null or empty.", feed.getEntries());
9191
}
92+
93+
@Test
94+
public void testGetBlogFeed() {
95+
Feed feed = service.getBlogFeed();
96+
assertNotNull("Feed cannot be null.", feed);
97+
assertNotNullOrEmpty("Feed entries cannot be null or empty.", feed.getEntries());
98+
}
99+
100+
@Test
101+
public void testGetDiscussionsFeed() {
102+
Feed feed = service.getDiscussionsFeed();
103+
assertNotNull("Feed cannot be null.", feed);
104+
assertNotNullOrEmpty("Feed entries cannot be null or empty.", feed.getEntries());
105+
}
106+
107+
@Test
108+
public void testGetDiscussionsFeedString() {
109+
Feed feed = service.getDiscussionsFeed("api");
110+
assertNotNull("Feed cannot be null.", feed);
111+
assertNotNullOrEmpty("Feed entries cannot be null or empty.", feed.getEntries());
112+
}
113+
114+
@Test
115+
public void testGetJobPositionsFeed() {
116+
Feed feed = service.getJobPositionsFeed();
117+
assertNotNull("Feed cannot be null.", feed);
118+
assertNotNullOrEmpty("Feed entries cannot be null or empty.", feed.getEntries());
119+
}
92120
}

github-api.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,13 @@ http://wiki.github.com/apache/cassandra/wikis.atom
2929
http://feeds.feedburner.com/thechangelog
3030
http://github.com/timeline.
3131

32+
http://support.github.com/discussions.atom
33+
http://support.github.com/discussions/repos.atom
34+
http://jobs.github.com/positions.atom
35+
http://feeds.feedburner.com/github?format=rss
36+
37+
Use Google Ajax Feed API to read feeds.
38+
3239
This library provides a wrapper for GitHub APi v2. Its
3340

3441
Description

0 commit comments

Comments
 (0)