Skip to content

Commit 214a8db

Browse files
authored
Added support for overriding the Event ID when updating, for recurring events (#186)
# Description This PR adds the ability for a user to pass in an event ID when updating an event, allowing users to pass in the ID of a single recurrence. # License <!-- Your PR comment must contain the following line for us to merge the PR. --> I confirm that this contribution is made under the terms of the MIT license and that I have the authority necessary to make this contribution on behalf of its copyright owner.
1 parent 5e9ad72 commit 214a8db

4 files changed

Lines changed: 23 additions & 1 deletion

File tree

CHANGELOG.md

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

77
### Added
88

9+
* Added support for overriding the Event ID when updating, for recurring events
10+
911
### Changed
1012

1113
### Deprecated

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,10 @@ void validate() {
346346
"The number of participants in the event exceeds the set capacity");
347347
}
348348

349+
protected void setId(String id) {
350+
this.id = id;
351+
}
352+
349353
@Override
350354
protected Map<String, Object> getWritableFields(boolean creation) {
351355
if (!creation) {

src/main/java/com/nylas/Events.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,22 @@ public Event create(Event event, boolean notifyParticipants) throws IOException,
4545
}
4646

4747
public Event update(Event event, boolean notifyParticipants) throws IOException, RequestFailedException {
48+
return update(event, null, notifyParticipants);
49+
}
50+
51+
/**
52+
* Update the event with the given id. Useful for updating
53+
* a single instance of a recurring event.
54+
* @param event The event to update
55+
* @param overrideId The ID of the event to update. If null, the ID of the event will be used.
56+
* @param notifyParticipants Whether or not to notify participants of the event update
57+
* @return The updated event
58+
*/
59+
public Event update(Event event, String overrideId, boolean notifyParticipants) throws IOException, RequestFailedException {
60+
if(overrideId != null) {
61+
event.setId(overrideId);
62+
}
63+
4864
event.validate();
4965
return super.update(event, getExtraQueryParams(notifyParticipants));
5066
}

src/main/java/com/nylas/RestfulModel.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
public abstract class RestfulModel {
99

10-
private String id;
10+
String id;
1111

1212
private String job_status_id;
1313

0 commit comments

Comments
 (0)