Skip to content

Commit b0b281d

Browse files
committed
Merge pull request #110 from aheritier/feature/updateArticleTranslation
Add new methods updateArticleTranslation/updateCategoryTranslation/updateSectionTranslation
2 parents 76cb0fc + b1788a2 commit b0b281d

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1394,6 +1394,12 @@ public Article updateArticle(Article article) {
13941394
JSON, json(Collections.singletonMap("article", article))), handle(Article.class, "article")));
13951395
}
13961396

1397+
public Translation updateArticleTranslation(Long articleId, String locale, Translation translation) {
1398+
checkHasId(translation);
1399+
return complete(submit(req("PUT", tmpl("/help_center/articles/{id}/translations/{locale}.json").set("id", articleId).set("locale",locale),
1400+
JSON, json(Collections.singletonMap("translation", translation))), handle(Translation.class, "translation")));
1401+
}
1402+
13971403
public void deleteArticle(Article article) {
13981404
checkHasId(article);
13991405
complete(submit(req("DELETE", tmpl("/help_center/articles/{id}.json").set("id", article.getId())),
@@ -1445,6 +1451,12 @@ public Category updateCategory(Category category) {
14451451
JSON, json(Collections.singletonMap("category", category))), handle(Category.class, "category")));
14461452
}
14471453

1454+
public Translation updateCategoryTranslation(Long categoryId, String locale, Translation translation) {
1455+
checkHasId(translation);
1456+
return complete(submit(req("PUT", tmpl("/help_center/categories/{id}/translations/{locale}.json").set("id", categoryId).set("locale",locale),
1457+
JSON, json(Collections.singletonMap("translation", translation))), handle(Translation.class, "translation")));
1458+
}
1459+
14481460
public void deleteCategory(Category category) {
14491461
checkHasId(category);
14501462
complete(submit(req("DELETE", tmpl("/help_center/categories/{id}.json").set("id", category.getId())),
@@ -1484,6 +1496,12 @@ public Section updateSection(Section section) {
14841496
JSON, json(Collections.singletonMap("section", section))), handle(Section.class, "section")));
14851497
}
14861498

1499+
public Translation updateSectionTranslation(Long sectionId, String locale, Translation translation) {
1500+
checkHasId(translation);
1501+
return complete(submit(req("PUT", tmpl("/help_center/sections/{id}/translations/{locale}.json").set("id", sectionId).set("locale",locale),
1502+
JSON, json(Collections.singletonMap("translation", translation))), handle(Translation.class, "translation")));
1503+
}
1504+
14871505
public void deleteSection(Section section) {
14881506
checkHasId(section);
14891507
complete(submit(req("DELETE", tmpl("/help_center/sections/{id}.json").set("id", section.getId())),
@@ -1964,6 +1982,12 @@ private static void checkHasId(SuspendedTicket ticket) {
19641982
}
19651983
}
19661984

1985+
private static void checkHasId(Translation translation) {
1986+
if (translation.getId() == null) {
1987+
throw new IllegalArgumentException("Translation requires id");
1988+
}
1989+
}
1990+
19671991
private static void checkHasToken(Attachment.Upload upload) {
19681992
if (upload.getToken() == null) {
19691993
throw new IllegalArgumentException("Upload requires token");

0 commit comments

Comments
 (0)