Skip to content

Commit 172d868

Browse files
Merge branch 'master' into feat/user-profiles
2 parents 46c3483 + 678b3bc commit 172d868

7 files changed

Lines changed: 325 additions & 20 deletions

File tree

.github/workflows/release-drafter.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ jobs:
1111
runs-on: ubuntu-latest
1212
steps:
1313
# Drafts your next Release notes as Pull Requests are merged into "master"
14-
- uses: release-drafter/release-drafter@v6.0.0
14+
- uses: release-drafter/release-drafter@v6.1.0
1515
env:
1616
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

pom.xml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
<groupId>com.cloudbees.thirdparty</groupId>
2727
<artifactId>zendesk-java-client</artifactId>
28-
<version>1.0.1-SNAPSHOT</version>
28+
<version>1.2.1-SNAPSHOT</version>
2929

3030
<name>zendesk-java-client</name>
3131
<description>Java client for the Zendesk API</description>
@@ -91,22 +91,22 @@
9191
<properties>
9292
<maven.compiler.source>11</maven.compiler.source>
9393
<maven.compiler.target>11</maven.compiler.target>
94-
<spotless.version>2.43.0</spotless.version>
94+
<spotless.version>2.44.3</spotless.version>
9595
</properties>
9696

9797
<dependencyManagement>
9898
<dependencies>
9999
<dependency>
100100
<groupId>com.fasterxml.jackson</groupId>
101101
<artifactId>jackson-bom</artifactId>
102-
<version>2.17.2</version>
102+
<version>2.18.2</version>
103103
<type>pom</type>
104104
<scope>import</scope>
105105
</dependency>
106106
<dependency>
107107
<groupId>io.netty</groupId>
108108
<artifactId>netty-bom</artifactId>
109-
<version>4.1.112.Final</version>
109+
<version>4.1.119.Final</version>
110110
<type>pom</type>
111111
<scope>import</scope>
112112
</dependency>
@@ -122,7 +122,7 @@
122122
<dependency>
123123
<groupId>org.asynchttpclient</groupId>
124124
<artifactId>async-http-client</artifactId>
125-
<version>2.12.3</version>
125+
<version>3.0.1</version>
126126
</dependency>
127127
<dependency>
128128
<groupId>com.fasterxml.jackson.core</groupId>
@@ -152,7 +152,7 @@
152152
<dependency>
153153
<groupId>org.slf4j</groupId>
154154
<artifactId>slf4j-simple</artifactId>
155-
<version>2.0.13</version>
155+
<version>2.0.17</version>
156156
<scope>test</scope>
157157
</dependency>
158158
<dependency>
@@ -165,19 +165,19 @@
165165
<groupId>org.assertj</groupId>
166166
<artifactId>assertj-core</artifactId>
167167
<!-- use 2.9.0 for Java 7 projects -->
168-
<version>3.26.3</version>
168+
<version>3.27.3</version>
169169
<scope>test</scope>
170170
</dependency>
171171
<dependency>
172172
<groupId>org.apache.commons</groupId>
173173
<artifactId>commons-text</artifactId>
174-
<version>1.12.0</version>
174+
<version>1.13.0</version>
175175
<scope>test</scope>
176176
</dependency>
177177
<dependency>
178178
<groupId>org.awaitility</groupId>
179179
<artifactId>awaitility</artifactId>
180-
<version>4.2.1</version>
180+
<version>4.3.0</version>
181181
<scope>test</scope>
182182
</dependency>
183183
</dependencies>
@@ -213,7 +213,7 @@
213213
<dependency>
214214
<groupId>org.codehaus.mojo</groupId>
215215
<artifactId>extra-enforcer-rules</artifactId>
216-
<version>1.8.0</version>
216+
<version>1.9.0</version>
217217
</dependency>
218218
</dependencies>
219219
<executions>
@@ -243,7 +243,7 @@
243243
<configuration>
244244
<rules>
245245
<enforceBytecodeVersion>
246-
<maxJdkVersion>1.8</maxJdkVersion>
246+
<maxJdkVersion>11</maxJdkVersion>
247247
</enforceBytecodeVersion>
248248
</rules>
249249
</configuration>

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

Lines changed: 38 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import com.fasterxml.jackson.databind.JavaType;
77
import com.fasterxml.jackson.databind.JsonNode;
88
import com.fasterxml.jackson.databind.ObjectMapper;
9+
import com.fasterxml.jackson.databind.ObjectReader;
910
import com.fasterxml.jackson.databind.SerializationFeature;
1011
import com.fasterxml.jackson.databind.util.StdDateFormat;
1112
import java.io.Closeable;
@@ -104,6 +105,8 @@
104105
import org.zendesk.client.v2.model.targets.Target;
105106
import org.zendesk.client.v2.model.targets.TwitterTarget;
106107
import org.zendesk.client.v2.model.targets.UrlTarget;
108+
import org.zendesk.client.v2.model.views.ExecutedViewPage;
109+
import org.zendesk.client.v2.model.views.ViewRow;
107110

108111
/**
109112
* @author stephenc
@@ -1034,6 +1037,17 @@ public Iterable<Ticket> getView(long id) {
10341037
tmpl("/views/{id}/tickets.json").set("id", id), handleList(Ticket.class, "tickets"));
10351038
}
10361039

1040+
@SuppressWarnings("unchecked")
1041+
public <V extends ViewRow> Optional<ExecutedViewPage<V>> executeView(long id, Class<V> clazz) {
1042+
var objectReader =
1043+
mapper.readerFor(
1044+
mapper.getTypeFactory().constructParametricType(ExecutedViewPage.class, clazz));
1045+
return Optional.of(
1046+
complete(
1047+
submit(
1048+
req("GET", tmpl("/views/{id}/execute.json").set("id", id)), handle(objectReader))));
1049+
}
1050+
10371051
// Automations
10381052
public Iterable<Automation> getAutomations() {
10391053
return new PagedIterable<>(
@@ -2454,6 +2468,17 @@ public void deleteOrganizationMembership(long user_id, long organization_members
24542468
handleStatus()));
24552469
}
24562470

2471+
public void unassignOrganizationMembership(long user_id, long organization_id) {
2472+
complete(
2473+
submit(
2474+
req(
2475+
"DELETE",
2476+
tmpl("/users/{uid}/organizations/{oid}.json")
2477+
.set("uid", user_id)
2478+
.set("oid", organization_id)),
2479+
handleStatus()));
2480+
}
2481+
24572482
public List<OrganizationMembership> setOrganizationMembershipAsDefault(
24582483
long user_id, OrganizationMembership organizationMembership) {
24592484
checkHasId(organizationMembership);
@@ -2967,26 +2992,26 @@ public List<String> getHelpCenterLocales() {
29672992
*/
29682993
public Iterable<Article> getArticles() {
29692994
return new PagedIterable<>(
2970-
cnst("/help_center/articles.json"), handleList(Article.class, "articles"));
2995+
cbp("/help_center/articles.json"), handleList(Article.class, "articles"));
29712996
}
29722997

29732998
public Iterable<Article> getArticles(String locale) {
29742999
return new PagedIterable<>(
2975-
tmpl("/help_center/{locale}/articles.json").set("locale", locale),
3000+
cbp("/help_center/{locale}/articles.json").set("locale", locale),
29763001
handleList(Article.class, "articles"));
29773002
}
29783003

29793004
public Iterable<Article> getArticles(Category category) {
29803005
checkHasId(category);
29813006
return new PagedIterable<>(
2982-
tmpl("/help_center/categories/{id}/articles.json").set("id", category.getId()),
3007+
cbp("/help_center/categories/{id}/articles.json").set("id", category.getId()),
29833008
handleList(Article.class, "articles"));
29843009
}
29853010

29863011
public Iterable<Article> getArticles(Category category, String locale) {
29873012
checkHasId(category);
29883013
return new PagedIterable<>(
2989-
tmpl("/help_center/{locale}/categories/{id}/articles.json")
3014+
cbp("/help_center/{locale}/categories/{id}/articles.json")
29903015
.set("id", category.getId())
29913016
.set("locale", locale),
29923017
handleList(Article.class, "articles"));
@@ -2995,14 +3020,14 @@ public Iterable<Article> getArticles(Category category, String locale) {
29953020
public Iterable<Article> getArticles(Section section) {
29963021
checkHasId(section);
29973022
return new PagedIterable<>(
2998-
tmpl("/help_center/sections/{id}/articles.json").set("id", section.getId()),
3023+
cbp("/help_center/sections/{id}/articles.json").set("id", section.getId()),
29993024
handleList(Article.class, "articles"));
30003025
}
30013026

30023027
public Iterable<Article> getArticles(Section section, String locale) {
30033028
checkHasId(section);
30043029
return new PagedIterable<>(
3005-
tmpl("/help_center/{locale}/sections/{id}/articles.json")
3030+
cbp("/help_center/{locale}/sections/{id}/articles.json")
30063031
.set("id", section.getId())
30073032
.set("locale", locale),
30083033
handleList(Article.class, "articles"));
@@ -3031,7 +3056,7 @@ public Article getArticle(long id) {
30313056

30323057
public Iterable<Translation> getArticleTranslations(Long articleId) {
30333058
return new PagedIterable<>(
3034-
tmpl("/help_center/articles/{articleId}/translations.json").set("articleId", articleId),
3059+
cbp("/help_center/articles/{articleId}/translations.json").set("articleId", articleId),
30353060
handleList(Translation.class, "translations"));
30363061
}
30373062

@@ -3587,12 +3612,17 @@ public Void onCompleted(Response response) throws Exception {
35873612

35883613
@SuppressWarnings("unchecked")
35893614
protected <T> ZendeskAsyncCompletionHandler<T> handle(final Class<T> clazz) {
3615+
return handle(mapper.readerFor(clazz));
3616+
}
3617+
3618+
@SuppressWarnings("unchecked")
3619+
protected <T> ZendeskAsyncCompletionHandler<T> handle(ObjectReader reader) {
35903620
return new ZendeskAsyncCompletionHandler<T>() {
35913621
@Override
35923622
public T onCompleted(Response response) throws Exception {
35933623
logResponse(response);
35943624
if (isStatus2xx(response)) {
3595-
return (T) mapper.readerFor(clazz).readValue(response.getResponseBodyAsStream());
3625+
return reader.readValue(response.getResponseBodyAsStream());
35963626
} else if (isRateLimitResponse(response)) {
35973627
throw new ZendeskResponseRateLimitException(response);
35983628
}
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
package org.zendesk.client.v2.model.views;
2+
3+
import com.fasterxml.jackson.annotation.JsonProperty;
4+
import java.io.Serializable;
5+
import java.util.List;
6+
import java.util.Objects;
7+
8+
// this is somewhat similar to a Page but with a single ExecuteView object and not a list
9+
// hence why we cannot inherite Page<?>
10+
public class ExecutedViewPage<V extends ViewRow> implements Serializable {
11+
private static final long serialVersionUID = -7683989282890282540L;
12+
13+
private @JsonProperty("next_page") String nextPage;
14+
private @JsonProperty("previous_page") String previousPage;
15+
private int count;
16+
17+
private List<ViewColumn> columns;
18+
private List<V> rows;
19+
20+
public List<ViewColumn> getColumns() {
21+
return columns;
22+
}
23+
24+
public void setColumns(List<ViewColumn> columns) {
25+
this.columns = columns;
26+
}
27+
28+
public List<V> getRows() {
29+
return rows;
30+
}
31+
32+
public void setRows(List<V> rows) {
33+
this.rows = rows;
34+
}
35+
36+
public String getNextPage() {
37+
return nextPage;
38+
}
39+
40+
public void setNextPage(final String nextPage) {
41+
this.nextPage = nextPage;
42+
}
43+
44+
public String getPreviousPage() {
45+
return previousPage;
46+
}
47+
48+
public void setPreviousPage(final String previousPage) {
49+
this.previousPage = previousPage;
50+
}
51+
52+
public int getCount() {
53+
return count;
54+
}
55+
56+
public void setCount(final int count) {
57+
this.count = count;
58+
}
59+
60+
@Override
61+
public boolean equals(Object o) {
62+
if (o == null || getClass() != o.getClass()) return false;
63+
64+
ExecutedViewPage<?> that = (ExecutedViewPage<?>) o;
65+
return count == that.count
66+
&& Objects.equals(nextPage, that.nextPage)
67+
&& Objects.equals(previousPage, that.previousPage)
68+
&& Objects.equals(columns, that.columns)
69+
&& Objects.equals(rows, that.rows);
70+
}
71+
72+
@Override
73+
public int hashCode() {
74+
int result = Objects.hashCode(nextPage);
75+
result = 31 * result + Objects.hashCode(previousPage);
76+
result = 31 * result + count;
77+
result = 31 * result + Objects.hashCode(columns);
78+
result = 31 * result + Objects.hashCode(rows);
79+
return result;
80+
}
81+
82+
@Override
83+
public String toString() {
84+
return "ExecutedViewPage{"
85+
+ "nextPage='"
86+
+ nextPage
87+
+ '\''
88+
+ ", previousPage='"
89+
+ previousPage
90+
+ '\''
91+
+ ", count="
92+
+ count
93+
+ ", columns="
94+
+ columns
95+
+ ", rows="
96+
+ rows
97+
+ '}';
98+
}
99+
}

0 commit comments

Comments
 (0)