Skip to content

Conversation

@mrashed-dev
Copy link
Contributor

@mrashed-dev mrashed-dev commented May 17, 2021

Description

The Nylas Calendar API has a new beta feature of adding a new metadata field to calendar events. This PR makes the feature available via the Nylas Java SDK.

Usage

To create a new event with event metadata, you can create a Map<String, String> with a mapping of key-value pairs for the metadata:

Event event = new Event(calendarId, new Timespan(startTime, endTime));
....
Map<String, String> metadata = new HashMap<>();
metadata.put("event_category", "gathering");
event.setMetadata(metadata);

To query events based on metadata, you can filter on three different parameters:

  • metadata_key (string or array) to filter based on the keys within the metadata object
  • metadata_value (string or array) to filter based on the value within the metadata object
  • metadata_pair (pair of strings; a key and a value) to filter based on the key-value pairs within the metadata object

You can invoke them as such and even chain them:

EventQuery query = new EventQuery()
                .calendarId(calendarId)
                .metadataKey("visitors", "parking")
                .metadataValue("garden")
                .metadataPair("event_category", "gathering");

License

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.

@mrashed-dev mrashed-dev requested a review from philrenaud May 17, 2021 16:25
@shortcut-integration
Copy link

This pull request has been linked to Clubhouse Story #59707: Java SDK support for metadata for events.

As per @ddlatham's comment, the metadata will always be a string value so it's more correct to cast it that way.
Can query based on metadata_key, metadata_value, and metadata_pair
Copy link
Contributor

@ddlatham ddlatham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a couple comments. I also have a few question still for @rajeev2gupta in this story that I'd like to pin down before merging this in. May require some additional documentation:
https://app.clubhouse.io/nylas/story/57542/java-sdk-support-for-metadata-for-events

Switching from replacing variables on setting to adding to a list allows adding a filters rather than replacing all of them when invoked again
@mrashed-dev mrashed-dev requested a review from ddlatham May 21, 2021 19:34
@mrashed-dev mrashed-dev requested a review from ddlatham May 21, 2021 21:16
@mrashed-dev mrashed-dev requested a review from ddlatham May 31, 2021 17:17
Copy link
Contributor

@ddlatham ddlatham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to merge!

@mrashed-dev mrashed-dev merged commit 5ad4358 into main Jun 1, 2021
@mrashed-dev mrashed-dev deleted the mostafarashed/ch59707/java-sdk-support-for-metadata-for-events branch June 1, 2021 18:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants