Skip to content

Commit 69c1c7b

Browse files
authored
Merge pull request #290 from Dohbedoh/bugfix/289
[#289] Add user_segment_id, permission_group_id and other new fields …
2 parents c3f9a0c + 481b2aa commit 69c1c7b

File tree

2 files changed

+132
-0
lines changed

2 files changed

+132
-0
lines changed

src/main/java/org/zendesk/client/v2/model/hc/Article.java

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package org.zendesk.client.v2.model.hc;
22

3+
import com.fasterxml.jackson.annotation.JsonInclude;
4+
import com.fasterxml.jackson.annotation.JsonInclude.Include;
35
import com.fasterxml.jackson.annotation.JsonProperty;
46
import org.zendesk.client.v2.model.SearchResultEntity;
57

@@ -41,6 +43,10 @@ public class Article implements SearchResultEntity {
4143
/** Whether the source (default) translation of the article is out of date */
4244
private Boolean outdated;
4345

46+
/** Locales in which the article was marked as outdated */
47+
@JsonProperty("outdated_locales")
48+
private List<String> outdatedLocales;
49+
4450
/** An array of label names associated with this article. By default no label names are used. Only available on certain plans */
4551
@JsonProperty("label_names")
4652
private List<String> labelNames;
@@ -66,6 +72,16 @@ public class Article implements SearchResultEntity {
6672
@JsonProperty("section_id")
6773
private Long sectionId;
6874

75+
/** The id of the user segment which defines who can see this article. Set to null to make it accessible to everyone. */
76+
@JsonInclude(Include.ALWAYS)
77+
@JsonProperty(value = "user_segment_id", defaultValue = "null")
78+
private Long userSegmentId;
79+
80+
/** The id of the permission group which defines who can edit and publish this article. */
81+
@JsonInclude(Include.ALWAYS)
82+
@JsonProperty(value = "permission_group_id", defaultValue = "null")
83+
private Long permissionGroupId;
84+
6985
/** The time the article was created */
7086
@JsonProperty("created_at")
7187
private Date createdAt;
@@ -74,6 +90,10 @@ public class Article implements SearchResultEntity {
7490
@JsonProperty("updated_at")
7591
private Date updatedAt;
7692

93+
/** The time the article was last edited in its displayed locale */
94+
@JsonProperty("edited_at")
95+
private Date editedAt;
96+
7797
public Long getId() {
7898
return id;
7999
}
@@ -154,6 +174,14 @@ public void setOutdated(Boolean outdated) {
154174
this.outdated = outdated;
155175
}
156176

177+
public List<String> getOutdatedLocales() {
178+
return outdatedLocales;
179+
}
180+
181+
public void setOutdatedLocales(List<String> outdatedLocales) {
182+
this.outdatedLocales = outdatedLocales;
183+
}
184+
157185
public List<String> getLabelNames() {
158186
return labelNames;
159187
}
@@ -210,6 +238,22 @@ public void setSectionId(Long sectionId) {
210238
this.sectionId = sectionId;
211239
}
212240

241+
public Long getUserSegmentId() {
242+
return userSegmentId;
243+
}
244+
245+
public void setUserSegmentId(Long userSegmentId) {
246+
this.userSegmentId = userSegmentId;
247+
}
248+
249+
public Long getPermissionGroupId() {
250+
return permissionGroupId;
251+
}
252+
253+
public void setPermissionGroupId(Long permissionGroupId) {
254+
this.permissionGroupId = permissionGroupId;
255+
}
256+
213257
public Date getCreatedAt() {
214258
return createdAt;
215259
}
@@ -226,6 +270,14 @@ public void setUpdatedAt(Date updatedAt) {
226270
this.updatedAt = updatedAt;
227271
}
228272

273+
public Date getEditedAt() {
274+
return editedAt;
275+
}
276+
277+
public void setEditedAt(Date editedAt) {
278+
this.editedAt = editedAt;
279+
}
280+
229281
@Override
230282
public String toString() {
231283
return "Article{" +
@@ -239,15 +291,19 @@ public String toString() {
239291
", authorId=" + authorId +
240292
", commentsDisabled=" + commentsDisabled +
241293
", outdated=" + outdated +
294+
", outdatedLocales=" + outdatedLocales +
242295
", labelNames=" + labelNames +
243296
", draft=" + draft +
244297
", promoted=" + promoted +
245298
", position=" + position +
246299
", voteSum=" + voteSum +
247300
", voteCount=" + voteCount +
248301
", sectionId=" + sectionId +
302+
", userSegmentId=" + userSegmentId +
303+
", permissionGroupId=" + permissionGroupId +
249304
", createdAt=" + createdAt +
250305
", updatedAt=" + updatedAt +
306+
", editedAt=" + editedAt +
251307
'}';
252308
}
253309
}
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
package org.zendesk.client.v2.model;
2+
3+
import com.fasterxml.jackson.databind.ObjectMapper;
4+
import org.junit.Test;
5+
import org.zendesk.client.v2.model.hc.Article;
6+
7+
import java.util.ArrayList;
8+
import java.util.Date;
9+
10+
import static org.junit.Assert.*;
11+
12+
public class ArticleTest {
13+
14+
private Article parseJson(byte[] json) {
15+
ObjectMapper mapper = new ObjectMapper();
16+
try {
17+
return mapper.readValue(json, Article.class);
18+
} catch (Exception e) {
19+
e.printStackTrace();
20+
return null;
21+
}
22+
}
23+
24+
@Test
25+
public void testParseArticle() {
26+
String json = "{" +
27+
"\"id\":918273645013," +
28+
"\"url\":\"https://example.zendesk.com/api/v2/help_center/en-us/articles/918273645013-Welcome-to-your-Help-Center-.json\"," +
29+
"\"html_url\":\"https://example.zendesk.com/hc/en-us/articles/918273645013-Welcome-to-your-Help-Center-\"," +
30+
"\"author_id\":2314596780," +
31+
"\"comments_disabled\":false," +
32+
"\"draft\":false," +
33+
"\"promoted\":false," +
34+
"\"position\":0," +
35+
"\"vote_sum\":0," +
36+
"\"vote_count\":0," +
37+
"\"section_id\":123456789," +
38+
"\"created_at\":\"2019-06-10T12:39:23Z\"," +
39+
"\"updated_at\":\"2019-06-10T12:39:23Z\"," +
40+
"\"title\":\"Welcome to your Help Center!\"," +
41+
"\"source_locale\":\"en-us\"," +
42+
"\"locale\":\"en-us\"," +
43+
"\"outdated\":false," +
44+
"\"outdated_locales\":[]," +
45+
"\"edited_at\":\"2019-06-10T12:39:23Z\"," +
46+
"\"user_segment_id\":null," +
47+
"\"permission_group_id\":2739912," +
48+
"\"label_names\":[]," +
49+
"\"body\":\"This is a test\"}";
50+
Article article = parseJson(json.getBytes());
51+
assertNotNull(article);
52+
assertEquals(Article.class, article.getClass());
53+
assertEquals((Long) 918273645013L, article.getId());
54+
assertEquals("https://example.zendesk.com/api/v2/help_center/en-us/articles/918273645013-Welcome-to-your-Help-Center-.json", article.getUrl());
55+
assertEquals("https://example.zendesk.com/hc/en-us/articles/918273645013-Welcome-to-your-Help-Center-", article.getHtmlUrl());
56+
assertEquals((Long) 2314596780L, article.getAuthorId());
57+
assertEquals(false, article.getCommentsDisabled());
58+
assertEquals(false, article.getDraft());
59+
assertEquals(false, article.getPromoted());
60+
assertEquals((Long) 0L, article.getPosition());
61+
assertEquals((Long) 0L, article.getVoteSum());
62+
assertEquals((Long) 0L, article.getVoteCount());
63+
assertEquals(new Date(1560170363000L), article.getCreatedAt());
64+
assertEquals(new Date(1560170363000L), article.getUpdatedAt());
65+
assertEquals("Welcome to your Help Center!", article.getTitle());
66+
assertEquals("en-us", article.getSourceLocale());
67+
assertEquals("en-us", article.getLocale());
68+
assertEquals(false, article.getOutdated());
69+
assertEquals(new ArrayList<>(), article.getOutdatedLocales());
70+
assertEquals(new Date(1560170363000L), article.getEditedAt());
71+
assertNull(article.getUserSegmentId());
72+
assertEquals((Long) 2739912L, article.getPermissionGroupId());
73+
assertEquals(new ArrayList<>(), article.getLabelNames());
74+
assertEquals("This is a test", article.getBody());
75+
}
76+
}

0 commit comments

Comments
 (0)