diff --git a/CHANGELOG.md b/CHANGELOG.md index 74b7fef3..6b0abcd1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ This section contains changes that have been committed but not yet released. ### Added +* Added support for overriding the Event ID when updating, for recurring events + ### Changed ### Deprecated diff --git a/src/main/java/com/nylas/Event.java b/src/main/java/com/nylas/Event.java index 05219695..304ad8de 100644 --- a/src/main/java/com/nylas/Event.java +++ b/src/main/java/com/nylas/Event.java @@ -346,6 +346,10 @@ void validate() { "The number of participants in the event exceeds the set capacity"); } + protected void setId(String id) { + this.id = id; + } + @Override protected Map getWritableFields(boolean creation) { if (!creation) { diff --git a/src/main/java/com/nylas/Events.java b/src/main/java/com/nylas/Events.java index 061dd820..753823e2 100644 --- a/src/main/java/com/nylas/Events.java +++ b/src/main/java/com/nylas/Events.java @@ -45,6 +45,22 @@ public Event create(Event event, boolean notifyParticipants) throws IOException, } public Event update(Event event, boolean notifyParticipants) throws IOException, RequestFailedException { + return update(event, null, notifyParticipants); + } + + /** + * Update the event with the given id. Useful for updating + * a single instance of a recurring event. + * @param event The event to update + * @param overrideId The ID of the event to update. If null, the ID of the event will be used. + * @param notifyParticipants Whether or not to notify participants of the event update + * @return The updated event + */ + public Event update(Event event, String overrideId, boolean notifyParticipants) throws IOException, RequestFailedException { + if(overrideId != null) { + event.setId(overrideId); + } + event.validate(); return super.update(event, getExtraQueryParams(notifyParticipants)); } diff --git a/src/main/java/com/nylas/RestfulModel.java b/src/main/java/com/nylas/RestfulModel.java index 990a948a..94fcbdf1 100644 --- a/src/main/java/com/nylas/RestfulModel.java +++ b/src/main/java/com/nylas/RestfulModel.java @@ -7,7 +7,7 @@ public abstract class RestfulModel { - private String id; + String id; private String job_status_id;