Skip to content

Commit

Permalink
Added support for overriding the Event ID when updating, for recurrin…
Browse files Browse the repository at this point in the history
…g 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.
  • Loading branch information
mrashed-dev authored Jan 8, 2024
1 parent 5e9ad72 commit 214a8db
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/nylas/Event.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, Object> getWritableFields(boolean creation) {
if (!creation) {
Expand Down
16 changes: 16 additions & 0 deletions src/main/java/com/nylas/Events.java
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/nylas/RestfulModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

public abstract class RestfulModel {

private String id;
String id;

private String job_status_id;

Expand Down

0 comments on commit 214a8db

Please sign in to comment.