Skip to content

Commit 800d35b

Browse files
authored
[75380] Fix bug where updating an Event results in an API error (#30)
A recent API update caused updating an event using the SDK to return an error because the SDK sends a Participant's status. This PR ensures that the Participant object omits it on outgoing API calls.
1 parent f3c96d7 commit 800d35b

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ This section contains changes that have been committed but not yet released.
1515

1616
### Fixed
1717

18+
- Fix bug where updating an event resulted in an API error
19+
1820
### Removed
1921

2022
### Security

src/main/java/com/nylas/Event.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import java.util.HashMap;
88
import java.util.List;
99
import java.util.Map;
10+
import java.util.stream.Collectors;
1011

1112
import com.squareup.moshi.JsonAdapter;
1213
import com.squareup.moshi.adapters.PolymorphicJsonAdapterFactory;
@@ -172,11 +173,19 @@ Map<String, Object> getWritableFields(boolean creation) {
172173
if (creation) {
173174
Maps.putIfNotNull(params, "calendar_id", getCalendarId());
174175
}
176+
177+
List<Map<String, Object>> participantWritableFields = null;
178+
if(!participants.isEmpty()) {
179+
participantWritableFields = participants.stream()
180+
.map(Participant::getWritableFields)
181+
.collect(Collectors.toList());
182+
}
183+
175184
Maps.putIfNotNull(params, "when", getWhen());
176185
Maps.putIfNotNull(params, "title", getTitle());
177186
Maps.putIfNotNull(params, "description", getDescription());
178187
Maps.putIfNotNull(params, "location", getLocation());
179-
Maps.putIfNotNull(params, "participants", getParticipants());
188+
Maps.putIfNotNull(params, "participants", participantWritableFields);
180189
Maps.putIfNotNull(params, "busy", getBusy());
181190
Maps.putIfNotNull(params, "metadata", getMetadata());
182191
Maps.putIfNotNull(params, "conferencing", getConferencing());

src/main/java/com/nylas/Participant.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package com.nylas;
22

3+
import java.util.HashMap;
4+
import java.util.Map;
5+
36
public class Participant {
47

58
private String name;
@@ -37,6 +40,7 @@ public Participant name(String name) {
3740
return this;
3841
}
3942

43+
@Deprecated
4044
public Participant status(String status) {
4145
this.status = status;
4246
return this;
@@ -47,6 +51,14 @@ public Participant comment(String comment) {
4751
return this;
4852
}
4953

54+
Map<String, Object> getWritableFields() {
55+
Map<String, Object> params = new HashMap<>();
56+
Maps.putIfNotNull(params, "name", name);
57+
Maps.putIfNotNull(params, "email", email);
58+
Maps.putIfNotNull(params, "comment", comment);
59+
return params;
60+
}
61+
5062
@Override
5163
public String toString() {
5264
return "Participant [name=" + name + ", email=" + email + ", status=" + status + ", comment=" + comment + "]";

0 commit comments

Comments
 (0)