Skip to content

Commit eb3a733

Browse files
authored
Merge pull request #545 from Walti91/master
2 parents f29f8ff + bc16588 commit eb3a733

File tree

2 files changed

+119
-0
lines changed

2 files changed

+119
-0
lines changed

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

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2242,6 +2242,13 @@ public Iterable<Translation> getArticleTranslations(Long articleId) {
22422242
handleList(Translation.class, "translations"));
22432243
}
22442244

2245+
public Translation showArticleTranslation(long articleId, String locale) {
2246+
return complete(submit(req("GET",
2247+
tmpl("/help_center/articles/{articleId}/translations/{locale}.json")
2248+
.set("articleId", articleId).set("locale", locale)),
2249+
handle(Translation.class, "translation")));
2250+
}
2251+
22452252
public Article createArticle(Article article) {
22462253
checkHasSectionId(article);
22472254
return complete(submit(req("POST", tmpl("/help_center/sections/{id}/articles.json").set("id", article.getSectionId()),
@@ -2333,6 +2340,14 @@ public Iterable<Translation> getCategoryTranslations(Long categoryId) {
23332340
tmpl("/help_center/categories/{categoryId}/translations.json").set("categoryId", categoryId),
23342341
handleList(Translation.class, "translations"));
23352342
}
2343+
2344+
public Translation showCategoryTranslation(long categoryId, String locale) {
2345+
return complete(submit(req("GET",
2346+
tmpl("/help_center/categories/{categoryId}/translations/{locale}.json")
2347+
.set("categoryId", categoryId).set("locale", locale)),
2348+
handle(Translation.class, "translation")));
2349+
}
2350+
23362351
public Category createCategory(Category category) {
23372352
return complete(submit(req("POST", cnst("/help_center/categories.json"),
23382353
JSON, json(Collections.singletonMap("category", category))), handle(Category.class, "category")));
@@ -2384,6 +2399,14 @@ public Iterable<Translation> getSectionTranslations(Long sectionId) {
23842399
tmpl("/help_center/sections/{sectionId}/translations.json").set("sectionId", sectionId),
23852400
handleList(Translation.class, "translations"));
23862401
}
2402+
2403+
public Translation showSectionTranslation(long sectionId, String locale) {
2404+
return complete(submit(req("GET",
2405+
tmpl("/help_center/sections/{sectionId}/translations/{locale}.json")
2406+
.set("sectionId", sectionId).set("locale", locale)),
2407+
handle(Translation.class, "translation")));
2408+
}
2409+
23872410
public Section createSection(Section section) {
23882411
checkHasCategoryId(section);
23892412
return complete(submit(req("POST", tmpl("/help_center/categories/{id}/sections.json").set("id", section.getCategoryId()),

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

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1614,6 +1614,38 @@ public void getArticleTranslations() throws Exception {
16141614
}
16151615
}
16161616

1617+
@Test
1618+
public void showArticleTranslation() throws Exception {
1619+
createClientWithTokenOrPassword();
1620+
List<String> locales = instance.getHelpCenterLocales();
1621+
1622+
int articleCount = 0;
1623+
1624+
for (Article article : instance.getArticles()) {
1625+
assertNotNull(article.getId());
1626+
1627+
if (++articleCount > 10) {
1628+
break;
1629+
}
1630+
1631+
int translationCount = 0;
1632+
1633+
for (String locale : locales) {
1634+
Translation translation = instance.showArticleTranslation(article.getId(), locale);
1635+
1636+
// if there is no translation for the given locale the endpoint will return null
1637+
if (translation != null) {
1638+
assertNotNull(translation.getId());
1639+
assertNotNull(translation.getTitle());
1640+
}
1641+
1642+
if (++translationCount > 3) {
1643+
break;
1644+
}
1645+
}
1646+
}
1647+
}
1648+
16171649
@Test
16181650
public void getSectionTranslations() throws Exception {
16191651
createClientWithTokenOrPassword();
@@ -1636,6 +1668,38 @@ public void getSectionTranslations() throws Exception {
16361668
}
16371669
}
16381670

1671+
@Test
1672+
public void showSectionTranslation() throws Exception {
1673+
createClientWithTokenOrPassword();
1674+
List<String> locales = instance.getHelpCenterLocales();
1675+
1676+
int sectionCount = 0;
1677+
1678+
for (Section section : instance.getSections()) {
1679+
assertNotNull(section.getId());
1680+
1681+
if (++sectionCount > 10) {
1682+
break;
1683+
}
1684+
1685+
int translationCount = 0;
1686+
1687+
for (String locale : locales) {
1688+
Translation translation = instance.showSectionTranslation(section.getId(), locale);
1689+
1690+
// if there is no translation for the given locale the endpoint will return null
1691+
if (translation != null) {
1692+
assertNotNull(translation.getId());
1693+
assertNotNull(translation.getTitle());
1694+
}
1695+
1696+
if (++translationCount > 3) {
1697+
break;
1698+
}
1699+
}
1700+
}
1701+
}
1702+
16391703
@Test
16401704
public void getCategoryTranslations() throws Exception {
16411705
createClientWithTokenOrPassword();
@@ -1658,6 +1722,38 @@ public void getCategoryTranslations() throws Exception {
16581722
}
16591723
}
16601724

1725+
@Test
1726+
public void showCategoryTranslation() throws Exception {
1727+
createClientWithTokenOrPassword();
1728+
List<String> locales = instance.getHelpCenterLocales();
1729+
1730+
int categoryCount = 0;
1731+
1732+
for (Category category : instance.getCategories()) {
1733+
assertNotNull(category.getId());
1734+
1735+
if (++categoryCount > 10) {
1736+
break;
1737+
}
1738+
1739+
int translationCount = 0;
1740+
1741+
for (String locale : locales) {
1742+
Translation translation = instance.showCategoryTranslation(category.getId(), locale);
1743+
1744+
// if there is no translation for the given locale the endpoint will return null
1745+
if (translation != null) {
1746+
assertNotNull(translation.getId());
1747+
assertNotNull(translation.getTitle());
1748+
}
1749+
1750+
if (++translationCount > 3) {
1751+
break;
1752+
}
1753+
}
1754+
}
1755+
}
1756+
16611757
@Test
16621758
public void getArticlesIncrementally() throws Exception {
16631759
createClientWithTokenOrPassword();

0 commit comments

Comments
 (0)