Skip to content

Commit 67ce1f3

Browse files
author
Matt Tucker
committed
Fix getArticles to retrieve multiple pages
Remove deprecation tag, as the method now returns articles across multiple result pages
1 parent 6c6535b commit 67ce1f3

File tree

3 files changed

+19
-6
lines changed

3 files changed

+19
-6
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ Here is the status of the various API components:
5555
* [Topics](http://developer.zendesk.com/documentation/rest_api/topics.html)
5656
* [Topic Comments](http://developer.zendesk.com/documentation/rest_api/topic_comments.html)
5757
* [Topic Subscriptions](http://developer.zendesk.com/documentation/rest_api/topic_subscriptions.html)
58+
* [Help Center Categories](https://developer.zendesk.com/rest_api/docs/help_center/categories)
59+
* [Help Center Sections](https://developer.zendesk.com/rest_api/docs/help_center/sections)
60+
* [Help Center Articles](https://developer.zendesk.com/rest_api/docs/help_center/articles)
5861
* [Topic Votes](http://developer.zendesk.com/documentation/rest_api/topic_votes.html)
5962
* [Account Settings](http://developer.zendesk.com/documentation/rest_api/account_settings.html)
6063
* [Activity Stream](http://developer.zendesk.com/documentation/rest_api/activity_stream.html)

src/main/java/org/zendesk/client/v2/Zendesk.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1209,15 +1209,13 @@ public void updateInstallation(int id, String json) {
12091209
//////////////////////////////////////////////////////////////////////
12101210

12111211
/**
1212-
* Get first page of articles from help center.
1212+
* Get all articles from help center.
12131213
*
1214-
* @deprecated use #getArticlesFromPage(int). Same as #getArticlesFromPage(0)
12151214
* @return List of Articles.
12161215
*/
1217-
@Deprecated
1218-
public List<Article> getArticles() {
1219-
return complete(submit(req("GET", cnst("/help_center/articles.json")),
1220-
handleList(Article.class, "articles")));
1216+
public Iterable<Article> getArticles() {
1217+
return new PagedIterable<Article>(cnst("/help_center/articles.json"),
1218+
handleList(Article.class, "articles"));
12211219
}
12221220

12231221
public List<Article> getArticlesFromPage(int page) {

src/test/java/org/zendesk/client/v2/RealSmokeTest.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import org.zendesk.client.v2.model.TicketForm;
1818
import org.zendesk.client.v2.model.User;
1919
import org.zendesk.client.v2.model.events.Event;
20+
import org.zendesk.client.v2.model.hc.Article;
2021
import org.zendesk.client.v2.model.targets.Target;
2122

2223
import java.util.ArrayList;
@@ -476,4 +477,15 @@ public void getGroups() throws Exception {
476477
}
477478
}
478479

480+
@Test
481+
public void getArticles() throws Exception {
482+
createClientWithTokenOrPassword();
483+
int count = 0;
484+
for (Article t : instance.getArticles()) {
485+
assertThat(t.getTitle(), notNullValue());
486+
if (++count > 40) { // Check enough to pull 2 result pages
487+
break;
488+
}
489+
}
490+
}
479491
}

0 commit comments

Comments
 (0)