Skip to content

Commit

Permalink
CUST-1573: support querying events using customer event ID (#153)
Browse files Browse the repository at this point in the history
# 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
nickbair-nylas authored Mar 20, 2023
1 parent 6fbe5e6 commit 5e9ad72
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/main/java/com/nylas/Event.java
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ public String toString() {
", participants=" + participants +
", visibility=" + visibility +
", metadata=" + metadata +
", customer_event_id=" + customer_event_id +
']';
}

Expand Down Expand Up @@ -372,6 +373,7 @@ protected Map<String, Object> getWritableFields(boolean creation) {
Maps.putIfNotNull(params, "recurrence", getRecurrence());
Maps.putIfNotNull(params, "hide_participants", getHideParticipants());
Maps.putIfNotNull(params, "visibility", getVisibility());
Maps.putIfNotNull(params, "customer_event_id", getCustomerEventId());
return params;
}

Expand Down
12 changes: 12 additions & 0 deletions src/main/java/com/nylas/EventQuery.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public class EventQuery extends RestfulQuery<EventQuery> {
private List<String> metadataKeys;
private List<String> metadataValues;
private List<String> metadataPairs;
private String customerEventId;

@Override
public void addParameters(HttpUrl.Builder url) {
Expand Down Expand Up @@ -88,6 +89,9 @@ public void addParameters(HttpUrl.Builder url) {
if (metadataQuery != null) {
metadataQuery.addParameters(url);
}
if (customerEventId != null) {
url.addQueryParameter("customer_event_id", customerEventId);
}
}

/**
Expand Down Expand Up @@ -208,6 +212,14 @@ public EventQuery metadataQuery(MetadataQuery metadataQuery) {
this.metadataQuery = metadataQuery;
return this;
}

/**
* Return events matching the specified customer event ID.
*/
public EventQuery customerEventId(String customerEventId) {
this.customerEventId = customerEventId;
return this;
}

/**
* Return events with metadata containing a property having the given key.
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/com/nylas/EventTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ public void testValidate() {

@Test
public void testGetWritableFields() {
assertEquals(event.getWritableFields(true).size(), 15);
assertEquals(event.getWritableFields(true).size(), 16);
assertEquals(event.getWritableFields(false).size(), 16);
}

Expand Down
2 changes: 1 addition & 1 deletion src/test/java/com/nylas/MessageTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public void testGetters() {
assertEquals(message.getLabels().size(), 1);
assertEquals(message.getMetadata().size(), 1);
assertEquals(message.getHeaders().size(), 1);
assertEquals(message.toString(), "Message [id=null, account_id=null, thread_id=okdvc089, subject=That thing I sent you, from=[NameEmail [name=Peter Potamus, [email protected]]], to=[NameEmail [name=Blue Falcone, [email protected]]], cc=[NameEmail [name=Harvey Birdman, [email protected]]], bcc=[NameEmail [name=Christie, [email protected]]], reply_to=[NameEmail [name=Peter Potamus, [email protected]]], date=2022-11-10T12:28:00Z, unread=true, starred=true, snippet=Did you get that thing..., files=[File [id=null, filename=logo.jpg, size=12334, content_type=image/jpeg, message_ids=[odjashjcv89], content_id=osdivcnm90834e, content_disposition=attachment]], events=[Event [id='null', calendar_id='null', ical_uid='null', master_event_id='null', event_collection_id='null', title='null', description='null', location='null', owner='null', status='null', capacity=null, read_only=null, busy=null, hide_participants=null, original_start_time=null, when=null, conferencing=null, recurrence=null, round_robin_order=[], notifications=[], participants=[], visibility=null, metadata={}]], folder=Folder [id=null, name=null, display_name=null], labels=[Label [id=null, name=null, display_name=null]], headers={header1=value}, metadata={key1=value}]");
assertEquals(message.toString(), "Message [id=null, account_id=null, thread_id=okdvc089, subject=That thing I sent you, from=[NameEmail [name=Peter Potamus, [email protected]]], to=[NameEmail [name=Blue Falcone, [email protected]]], cc=[NameEmail [name=Harvey Birdman, [email protected]]], bcc=[NameEmail [name=Christie, [email protected]]], reply_to=[NameEmail [name=Peter Potamus, [email protected]]], date=2022-11-10T12:28:00Z, unread=true, starred=true, snippet=Did you get that thing..., files=[File [id=null, filename=logo.jpg, size=12334, content_type=image/jpeg, message_ids=[odjashjcv89], content_id=osdivcnm90834e, content_disposition=attachment]], events=[Event [id='null', calendar_id='null', ical_uid='null', master_event_id='null', event_collection_id='null', title='null', description='null', location='null', owner='null', status='null', capacity=null, read_only=null, busy=null, hide_participants=null, original_start_time=null, when=null, conferencing=null, recurrence=null, round_robin_order=[], notifications=[], participants=[], visibility=null, metadata={}, customer_event_id=null]], folder=Folder [id=null, name=null, display_name=null], labels=[Label [id=null, name=null, display_name=null]], headers={header1=value}, metadata={key1=value}]");
}


Expand Down

0 comments on commit 5e9ad72

Please sign in to comment.