Skip to content

Commit a319457

Browse files
authored
Merge pull request #129 from intercom/MM/bulk_users
add data_type for bulk user actions
2 parents 666b8e1 + a8888e0 commit a319457

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

intercom-java/src/main/java/io/intercom/api/HttpClient.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ private <T> T handleSuccess(JavaType javaType, HttpURLConnection conn, int respo
171171
}
172172

173173
private boolean shouldSkipResponseEntity(JavaType javaType, HttpURLConnection conn, int responseCode) {
174-
return responseCode == 202 || responseCode == 204 || Void.class.equals(javaType.getRawClass()) || "DELETE".equals(conn.getRequestMethod());
174+
return responseCode == 204 || Void.class.equals(javaType.getRawClass()) || "DELETE".equals(conn.getRequestMethod());
175175
}
176176

177177
private <T> T readEntity(HttpURLConnection conn, int responseCode, JavaType javaType) throws IOException {

intercom-java/src/main/java/io/intercom/api/JobItem.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,19 @@ public JobItem() {
3535
}
3636

3737
public JobItem(String method, T data) {
38-
checkNotNull(method, data);
39-
this.method = method;
40-
this.data = data;
41-
this.dataType = data.getType();
38+
this(method, data, null);
4239
}
4340

44-
private void checkNotNull(String method, T data) {
41+
JobItem(String method, T data, String dataType) {
4542
Conditions.checkNotNull(method, "item method must be supplied");
4643
Conditions.checkNotNull(data, "item data must be supplied");
44+
this.method = method;
45+
this.data = data;
46+
this.dataType = dataType;
47+
if (dataType == null) {
48+
this.dataType = data.getType();
49+
}
50+
Conditions.checkNotNull(data, "item dataType must be supplied");
4751
}
4852

4953
public String getType() {

intercom-java/src/main/java/io/intercom/api/User.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,8 @@ static List<JobItem<UserUpdate>> validateAndConvertJobItems(List<JobItem<User>>
120120
final JobSupport jobSupport = new JobSupport();
121121
for (JobItem<User> item : items) {
122122
jobSupport.validateJobItem(item, BULK_METHODS);
123-
updateItems.add(
124-
new JobItem<UserUpdate>(
125-
item.getMethod(), buildFrom(item.getData())));
123+
final JobItem<UserUpdate> jobItem = new JobItem<UserUpdate>(item.getMethod(), buildFrom(item.getData()), item.getData().getType());
124+
updateItems.add(jobItem);
126125
}
127126
return updateItems;
128127
}

0 commit comments

Comments
 (0)