Skip to content

Commit 5e9ad72

Browse files
CUST-1573: support querying events using customer event ID (#153)
# 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.
1 parent 6fbe5e6 commit 5e9ad72

4 files changed

Lines changed: 16 additions & 2 deletions

File tree

src/main/java/com/nylas/Event.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ public String toString() {
189189
", participants=" + participants +
190190
", visibility=" + visibility +
191191
", metadata=" + metadata +
192+
", customer_event_id=" + customer_event_id +
192193
']';
193194
}
194195

@@ -372,6 +373,7 @@ protected Map<String, Object> getWritableFields(boolean creation) {
372373
Maps.putIfNotNull(params, "recurrence", getRecurrence());
373374
Maps.putIfNotNull(params, "hide_participants", getHideParticipants());
374375
Maps.putIfNotNull(params, "visibility", getVisibility());
376+
Maps.putIfNotNull(params, "customer_event_id", getCustomerEventId());
375377
return params;
376378
}
377379

src/main/java/com/nylas/EventQuery.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public class EventQuery extends RestfulQuery<EventQuery> {
2626
private List<String> metadataKeys;
2727
private List<String> metadataValues;
2828
private List<String> metadataPairs;
29+
private String customerEventId;
2930

3031
@Override
3132
public void addParameters(HttpUrl.Builder url) {
@@ -88,6 +89,9 @@ public void addParameters(HttpUrl.Builder url) {
8889
if (metadataQuery != null) {
8990
metadataQuery.addParameters(url);
9091
}
92+
if (customerEventId != null) {
93+
url.addQueryParameter("customer_event_id", customerEventId);
94+
}
9195
}
9296

9397
/**
@@ -208,6 +212,14 @@ public EventQuery metadataQuery(MetadataQuery metadataQuery) {
208212
this.metadataQuery = metadataQuery;
209213
return this;
210214
}
215+
216+
/**
217+
* Return events matching the specified customer event ID.
218+
*/
219+
public EventQuery customerEventId(String customerEventId) {
220+
this.customerEventId = customerEventId;
221+
return this;
222+
}
211223

212224
/**
213225
* Return events with metadata containing a property having the given key.

src/test/java/com/nylas/EventTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ public void testValidate() {
201201

202202
@Test
203203
public void testGetWritableFields() {
204-
assertEquals(event.getWritableFields(true).size(), 15);
204+
assertEquals(event.getWritableFields(true).size(), 16);
205205
assertEquals(event.getWritableFields(false).size(), 16);
206206
}
207207

src/test/java/com/nylas/MessageTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public void testGetters() {
7171
assertEquals(message.getLabels().size(), 1);
7272
assertEquals(message.getMetadata().size(), 1);
7373
assertEquals(message.getHeaders().size(), 1);
74-
assertEquals(message.toString(), "Message [id=null, account_id=null, thread_id=okdvc089, subject=That thing I sent you, from=[NameEmail [name=Peter Potamus, email=potamus.peter@sebbebandsebben.com]], to=[NameEmail [name=Blue Falcone, email=falcone.blue@sebbebandsebben.com]], cc=[NameEmail [name=Harvey Birdman, email=harvey.birdman@sebbebandsebben.com]], bcc=[NameEmail [name=Christie, email=christie@sebbebandsebben.com]], reply_to=[NameEmail [name=Peter Potamus, email=potamus.peter@sebbebandsebben.com]], 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}]");
74+
assertEquals(message.toString(), "Message [id=null, account_id=null, thread_id=okdvc089, subject=That thing I sent you, from=[NameEmail [name=Peter Potamus, email=potamus.peter@sebbebandsebben.com]], to=[NameEmail [name=Blue Falcone, email=falcone.blue@sebbebandsebben.com]], cc=[NameEmail [name=Harvey Birdman, email=harvey.birdman@sebbebandsebben.com]], bcc=[NameEmail [name=Christie, email=christie@sebbebandsebben.com]], reply_to=[NameEmail [name=Peter Potamus, email=potamus.peter@sebbebandsebben.com]], 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}]");
7575
}
7676

7777

0 commit comments

Comments
 (0)