Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for overriding the Event ID when updating, for recurring events #186

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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