Skip to content

Commit b4b80ed

Browse files
committed
[feature] New method getUsers(id,ids)
1 parent c807045 commit b4b80ed

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
@@ -867,6 +867,11 @@ public Iterable<User> getUsersByRole(String role, String... roles) {
867867
return new PagedIterable<>(cnst(uriBuilder.toString()), handleList(User.class, "users"));
868868
}
869869

870+
public List<User> getUsers(long id, long... ids) {
871+
return complete(submit(req("GET", tmpl("/users/show_many.json{?ids}").set("ids", idArray(id, ids))),
872+
handleList(User.class, "users")));
873+
}
874+
870875
public Iterable<User> getUsersIncrementally(Date startTime) {
871876
return new PagedIterable<>(
872877
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
@@ -1154,6 +1154,21 @@ public void getUsers() throws Exception {
11541154
}
11551155
}
11561156

1157+
@Test
1158+
public void getUsersById() throws Exception {
1159+
createClientWithTokenOrPassword();
1160+
1161+
Long[] usersIds = StreamSupport.stream(instance.getUsers().spliterator(), false)
1162+
.limit(5)
1163+
.map(User::getId)
1164+
.toArray(Long[]::new);
1165+
1166+
for (User user : instance.getUsers(usersIds[0], usersIds[1], usersIds[2], usersIds[3], usersIds[4])) {
1167+
assertThat(user.getId(), notNullValue());
1168+
assertThat(user.getName(), notNullValue());
1169+
}
1170+
}
1171+
11571172
@Test
11581173
public void getUsersIncrementally() throws Exception {
11591174
createClientWithTokenOrPassword();

0 commit comments

Comments
 (0)