v1.10.0
This release of the Nylas Java SDK introduces 2 new features and fixes a critical bug where updating an event with participants can result in an error.
New Features
- Add support for automatic meeting details
- Add support for Event notifications
Enhancements
- Fix bug where updating an event resulted in an API error
Using New Features
Automatic Meeting Details
To have Nylas autocreate the conference field for you, pass the autocreate object to the new event:
public class NylasExamples {
public static void postEventExample() throws IOException, RequestFailedException {
NylasClient nylas = new NylasClient();
NylasAccount account = nylas.account("{ACCESS_TOKEN}");
// Create a new event object
Event event = new Event("{CALENDAR_ID}", when);
// Add conferencing details
Event.Conferencing conferencing = new Event.Conferencing();
conferencing.setProvider("Zoom Meeting");
Event.Conferencing.Autocreate autocreate = new Event.Conferencing.Autocreate();
conferencing.setAutocreate(autocreate)
event.setConferencing(conferencing);
}
}A few notes and things to keep in mind:
- Only one of
detailsorautocreatecan be present, and we have implemented client-side checking to enforce this rule - Autocreating conferencing data is an asynchronous operation on the server-side. The Event object returned will not have a conferencing field, but it should be available in a future get call once the conference is created on the backend. The initial Event object returned will have a
jobStatusIdvalue which can be used to check on the status of conference creation. - The
settingsobject within theautocreateobject maps to the settings the Nylas API will send to the conference provider for the conference creation. For example with Zoom the settings object maps to Zoom's Create a Meeting object.
Event Notifications
To add notifications to an event:
NylasClient nylas = new NylasClient();
NylasAccount account = nylas.account("{ACCESS_TOKEN}");
Events events = account.events();
Event event = new Event("{CALENDAR_ID}", new Timespan(startTime, endTime));
Event.Notification emailNotification = new Event.Notification();
emailNotification.setType(Event.Notification.NotificationType.EMAIL);
emailNotification.setMinutesBeforeEvent(600);
emailNotification.setSubject("Test Event Notification");
emailNotification.setBody("Reminding you about our meeting.");
Event.Notification webhookNotification = new Event.Notification();
webhookNotification.setType(Event.Notification.NotificationType.WEBHOOK);
webhookNotification.setMinutesBeforeEvent(600);
webhookNotification.setUrl("https://hooks.service.com/services/T01A03EEXDE/B01TBNH532R/HubIZu1zog4oYdFqQ8VUcuiW");
Map<String, Object> payload = new HashMap<>();
payload.put("text", "Your reminder goes here!");
webhookNotification.setPayload(JsonHelper.mapToJson(payload));
Event.Notification smsNotification = new Event.Notification();
smsNotification.setType(Event.Notification.NotificationType.SMS);
smsNotification.setMinutesBeforeEvent(60);
smsNotification.setSubject("Test Event Notification");
event.setNotifications(Arrays.asList(emailNotification, webhookNotification, smsNotification));
events.create(event, true);To retrieve event notification details of an event:
NylasClient nylas = new NylasClient();
NylasAccount account = nylas.account("{ACCESS_TOKEN}");
Events events = account.events();
Event event = events.get("{eventId}");
int minutesBeforeEvent = event.getNotifications().getMinutesBeforeEvent();
String type = event.getNotifications().getType();
String body = event.getNotifications().getBody();
String url = event.getNotifications().getUrl();
String subject = event.getNotifications().getSubject();
String payload = event.getNotifications().getPayload();
String message = event.getNotifications().getMessage();To update an event with a notification:
NylasClient nylas = new NylasClient();
NylasAccount account = nylas.account("{ACCESS_TOKEN}");
Events events = account.events();
Event event = events.get("{eventId}");
Event.Notification notification = new Event.Notification();
notification.setType(Event.Notification.NotificationType.EMAIL);
notification.setMinutesBeforeEvent(60);
notification.setSubject("Test Event Notification");
notification.setBody("Reminding you about our meeting.");
event.setNotifications(Collections.singletonList(notification));
events.update(event, true);To delete a notification from an event:
NylasClient nylas = new NylasClient();
NylasAccount account = nylas.account("{ACCESS_TOKEN}");
Events events = account.events();
Event event = events.get("{eventId}");
event.setNotifications(Collections.emptyList());
events.update(event, true);