Skip to content

Commit 9b49681

Browse files
authored
Merge pull request #550 from Walti91/master
2 parents 8f66331 + a590b6c commit 9b49681

File tree

3 files changed

+58
-6
lines changed

3 files changed

+58
-6
lines changed

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

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
import org.zendesk.client.v2.model.hc.Article;
6464
import org.zendesk.client.v2.model.hc.ArticleAttachments;
6565
import org.zendesk.client.v2.model.hc.Category;
66+
import org.zendesk.client.v2.model.hc.Locales;
6667
import org.zendesk.client.v2.model.hc.PermissionGroup;
6768
import org.zendesk.client.v2.model.hc.Section;
6869
import org.zendesk.client.v2.model.hc.Subscription;
@@ -2184,10 +2185,18 @@ public void deleteUserSegment(long id) {
21842185
handleStatus()));
21852186
}
21862187

2187-
public List<String> getHelpCenterLocales() {
2188+
public Locales listHelpCenterLocales() {
21882189
return complete(submit(
2189-
req("GET", cnst("/help_center/locales.json")),
2190-
handle(List.class, "locales")));
2190+
req("GET", cnst("/help_center/locales.json")),
2191+
handle(Locales.class)));
2192+
}
2193+
2194+
/**
2195+
* @deprecated Use {@link Zendesk#listHelpCenterLocales()} instead
2196+
*/
2197+
@Deprecated
2198+
public List<String> getHelpCenterLocales() {
2199+
return listHelpCenterLocales().getLocales();
21912200
}
21922201

21932202
/**
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package org.zendesk.client.v2.model.hc;
2+
3+
import com.fasterxml.jackson.annotation.JsonProperty;
4+
import java.util.List;
5+
6+
public class Locales {
7+
8+
@JsonProperty("default_locale")
9+
private String defaultLocale;
10+
11+
private List<String> locales;
12+
13+
public String getDefaultLocale() {
14+
return defaultLocale;
15+
}
16+
17+
public void setDefaultLocale(String defaultLocale) {
18+
this.defaultLocale = defaultLocale;
19+
}
20+
21+
public List<String> getLocales() {
22+
return locales;
23+
}
24+
25+
public void setLocales(List<String> locales) {
26+
this.locales = locales;
27+
}
28+
}

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

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
import org.zendesk.client.v2.model.events.Event;
4848
import org.zendesk.client.v2.model.hc.Article;
4949
import org.zendesk.client.v2.model.hc.Category;
50+
import org.zendesk.client.v2.model.hc.Locales;
5051
import org.zendesk.client.v2.model.hc.PermissionGroup;
5152
import org.zendesk.client.v2.model.hc.Section;
5253
import org.zendesk.client.v2.model.hc.Subscription;
@@ -95,6 +96,7 @@
9596
import static org.junit.Assert.assertNotEquals;
9697
import static org.junit.Assert.assertNotNull;
9798
import static org.junit.Assert.assertTrue;
99+
import static org.junit.Assert.assertFalse;
98100
import static org.junit.Assume.assumeThat;
99101

100102
/**
@@ -1592,6 +1594,19 @@ public void getArticleSubscriptions() throws Exception {
15921594
}
15931595
}
15941596

1597+
@Test
1598+
public void listHelpCenterLocales() throws Exception {
1599+
createClientWithTokenOrPassword();
1600+
1601+
Locales locales = instance.listHelpCenterLocales();
1602+
1603+
assertNotNull(locales);
1604+
assertNotNull(locales.getDefaultLocale());
1605+
assertNotNull(locales.getLocales());
1606+
assertFalse(locales.getLocales().isEmpty());
1607+
assertTrue(locales.getLocales().contains(locales.getDefaultLocale()));
1608+
}
1609+
15951610
@Test
15961611
public void getArticleTranslations() throws Exception {
15971612
createClientWithTokenOrPassword();
@@ -1617,7 +1632,7 @@ public void getArticleTranslations() throws Exception {
16171632
@Test
16181633
public void showArticleTranslation() throws Exception {
16191634
createClientWithTokenOrPassword();
1620-
List<String> locales = instance.getHelpCenterLocales();
1635+
List<String> locales = instance.listHelpCenterLocales().getLocales();
16211636

16221637
int articleCount = 0;
16231638

@@ -1671,7 +1686,7 @@ public void getSectionTranslations() throws Exception {
16711686
@Test
16721687
public void showSectionTranslation() throws Exception {
16731688
createClientWithTokenOrPassword();
1674-
List<String> locales = instance.getHelpCenterLocales();
1689+
List<String> locales = instance.listHelpCenterLocales().getLocales();
16751690

16761691
int sectionCount = 0;
16771692

@@ -1725,7 +1740,7 @@ public void getCategoryTranslations() throws Exception {
17251740
@Test
17261741
public void showCategoryTranslation() throws Exception {
17271742
createClientWithTokenOrPassword();
1728-
List<String> locales = instance.getHelpCenterLocales();
1743+
List<String> locales = instance.listHelpCenterLocales().getLocales();
17291744

17301745
int categoryCount = 0;
17311746

0 commit comments

Comments
 (0)