Skip to content

Commit 17ed833

Browse files
authored
Merge pull request #484 from cloudbees-oss/many_users
New method getUsers(id,ids)
2 parents d0d1ff3 + b4b80ed commit 17ed833

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -873,6 +873,11 @@ public Iterable<User> getUsersByRole(String role, String... roles) {
873873
return new PagedIterable<>(cnst(uriBuilder.toString()), handleList(User.class, "users"));
874874
}
875875

876+
public List<User> getUsers(long id, long... ids) {
877+
return complete(submit(req("GET", tmpl("/users/show_many.json{?ids}").set("ids", idArray(id, ids))),
878+
handleList(User.class, "users")));
879+
}
880+
876881
public Iterable<User> getUsersIncrementally(Date startTime) {
877882
return new PagedIterable<>(
878883
tmpl("/incremental/users.json{?start_time}").set("start_time", msToSeconds(startTime.getTime())),

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1166,6 +1166,21 @@ public void getUsers() throws Exception {
11661166
}
11671167
}
11681168

1169+
@Test
1170+
public void getUsersById() throws Exception {
1171+
createClientWithTokenOrPassword();
1172+
1173+
Long[] usersIds = StreamSupport.stream(instance.getUsers().spliterator(), false)
1174+
.limit(5)
1175+
.map(User::getId)
1176+
.toArray(Long[]::new);
1177+
1178+
for (User user : instance.getUsers(usersIds[0], usersIds[1], usersIds[2], usersIds[3], usersIds[4])) {
1179+
assertThat(user.getId(), notNullValue());
1180+
assertThat(user.getName(), notNullValue());
1181+
}
1182+
}
1183+
11691184
@Test
11701185
public void getUsersIncrementally() throws Exception {
11711186
createClientWithTokenOrPassword();

0 commit comments

Comments
 (0)