From 4e0d405e735dc2347dac1144e25855ac238863df Mon Sep 17 00:00:00 2001 From: Burton Rhodes Date: Wed, 29 Apr 2026 22:36:11 -0500 Subject: [PATCH 1/5] add support for Google's "color_id" field for Events --- .../com/nylas/models/CreateEventRequest.kt | 16 ++++++++++++++++ src/main/kotlin/com/nylas/models/Event.kt | 6 ++++++ .../com/nylas/models/UpdateEventRequest.kt | 16 ++++++++++++++++ .../kotlin/com/nylas/resources/EventsTests.kt | 18 +++++++++++------- 4 files changed, 49 insertions(+), 7 deletions(-) diff --git a/src/main/kotlin/com/nylas/models/CreateEventRequest.kt b/src/main/kotlin/com/nylas/models/CreateEventRequest.kt index ef187ec8..8f3b468f 100644 --- a/src/main/kotlin/com/nylas/models/CreateEventRequest.kt +++ b/src/main/kotlin/com/nylas/models/CreateEventRequest.kt @@ -94,6 +94,12 @@ data class CreateEventRequest( */ @Json(name = "notetaker") val notetaker: EventNotetakerRequest? = null, + /** + * The Google color ID for the event. (Currently) Only applies to Google Calendar events. + * @see Google Calendar Colors + */ + @Json(name = "color_id") + val colorId: String? = null, ) { /** * This sealed class represents the different types of event time configurations. @@ -511,6 +517,7 @@ data class CreateEventRequest( private var capacity: Int? = null private var hideParticipant: Boolean? = null private var notetaker: EventNotetakerRequest? = null + private var colorId: String? = null /** * Set the event title. @@ -625,6 +632,14 @@ data class CreateEventRequest( */ fun notetaker(notetaker: EventNotetakerRequest) = apply { this.notetaker = notetaker } + /** + * Set the Google color ID for the event. Only applies to Google Calendar events. + * @param colorId The Google color ID. + * @return The builder. + * @see Google Calendar Colors + */ + fun colorId(colorId: String) = apply { this.colorId = colorId } + /** * Builds the [CreateEventRequest] object. * @return [CreateEventRequest] object. @@ -647,6 +662,7 @@ data class CreateEventRequest( capacity, hideParticipant, notetaker, + colorId, ) } } diff --git a/src/main/kotlin/com/nylas/models/Event.kt b/src/main/kotlin/com/nylas/models/Event.kt index 0931cb3f..5d513296 100644 --- a/src/main/kotlin/com/nylas/models/Event.kt +++ b/src/main/kotlin/com/nylas/models/Event.kt @@ -155,6 +155,12 @@ data class Event( */ @Json(name = "original_start_time") val originalStartTime: Long? = null, + /** + * The Google color ID for the event. (Currently) Only applies to Google Calendar events. + * @see Google Calendar Colors + */ + @Json(name = "color_id") + val colorId: String? = null, ) { /** * Get the type of object. diff --git a/src/main/kotlin/com/nylas/models/UpdateEventRequest.kt b/src/main/kotlin/com/nylas/models/UpdateEventRequest.kt index aa9bfe02..75899a77 100644 --- a/src/main/kotlin/com/nylas/models/UpdateEventRequest.kt +++ b/src/main/kotlin/com/nylas/models/UpdateEventRequest.kt @@ -94,6 +94,12 @@ data class UpdateEventRequest( */ @Json(name = "notetaker") val notetaker: EventNotetakerRequest? = null, + /** + * The Google color ID for the event. (Currently) Only applies to Google Calendar events. + * @see Google Calendar Colors + */ + @Json(name = "color_id") + val colorId: String? = null, ) { /** * This sealed class represents the different types of event time configurations. @@ -597,6 +603,7 @@ data class UpdateEventRequest( private var capacity: Int? = null private var hideParticipant: Boolean? = null private var notetaker: EventNotetakerRequest? = null + private var colorId: String? = null /** * Set the when object. @@ -719,6 +726,14 @@ data class UpdateEventRequest( */ fun notetaker(notetaker: EventNotetakerRequest) = apply { this.notetaker = notetaker } + /** + * Update the Google color ID for the event. Only applies to Google Calendar events. + * @param colorId The Google color ID. + * @return The builder. + * @see Google Calendar Colors + */ + fun colorId(colorId: String) = apply { this.colorId = colorId } + /** * Builds the [UpdateEventRequest] object. * @return [UpdateEventRequest] object. @@ -741,6 +756,7 @@ data class UpdateEventRequest( capacity, hideParticipant, notetaker, + colorId, ) } } diff --git a/src/test/kotlin/com/nylas/resources/EventsTests.kt b/src/test/kotlin/com/nylas/resources/EventsTests.kt index 8778d122..8285483e 100644 --- a/src/test/kotlin/com/nylas/resources/EventsTests.kt +++ b/src/test/kotlin/com/nylas/resources/EventsTests.kt @@ -111,7 +111,8 @@ class EventsTests { "audio_recording": true, "transcription": true } - } + }, + "color_id": "7" } """.trimIndent(), ) @@ -171,6 +172,7 @@ class EventsTests { assertEquals(false, event.notetaker?.meetingSettings?.videoRecording) assertEquals(true, event.notetaker?.meetingSettings?.audioRecording) assertEquals(true, event.notetaker?.meetingSettings?.transcription) + assertEquals("7", event.colorId) } @Test @@ -882,12 +884,12 @@ class EventsTests { val createEventRequest = CreateEventRequest( whenObj = - CreateEventRequest.When.Timespan( - startTime = 1620000000, - endTime = 1620000000, - startTimezone = "America/Los_Angeles", - endTimezone = "America/Los_Angeles", - ), + CreateEventRequest.When.Timespan( + startTime = 1620000000, + endTime = 1620000000, + startTimezone = "America/Los_Angeles", + endTimezone = "America/Los_Angeles", + ), description = "Description of my new event", location = "Los Angeles, CA", metadata = mapOf("your-key" to "value"), @@ -899,6 +901,7 @@ class EventsTests { transcription = true, ), ), + colorId = "7", ) val createEventQueryParams = CreateEventQueryParams( @@ -941,6 +944,7 @@ class EventsTests { transcription = true, ), ), + colorId = "11", ) val updateEventQueryParams = UpdateEventQueryParams( From d8920c83972c13e19d60b499eb258f9156ec5f9c Mon Sep 17 00:00:00 2001 From: Burton Rhodes Date: Wed, 29 Apr 2026 22:48:40 -0500 Subject: [PATCH 2/5] fix indentation for lint validation --- src/test/kotlin/com/nylas/resources/EventsTests.kt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/test/kotlin/com/nylas/resources/EventsTests.kt b/src/test/kotlin/com/nylas/resources/EventsTests.kt index 8285483e..fa4d7096 100644 --- a/src/test/kotlin/com/nylas/resources/EventsTests.kt +++ b/src/test/kotlin/com/nylas/resources/EventsTests.kt @@ -884,12 +884,12 @@ class EventsTests { val createEventRequest = CreateEventRequest( whenObj = - CreateEventRequest.When.Timespan( - startTime = 1620000000, - endTime = 1620000000, - startTimezone = "America/Los_Angeles", - endTimezone = "America/Los_Angeles", - ), + CreateEventRequest.When.Timespan( + startTime = 1620000000, + endTime = 1620000000, + startTimezone = "America/Los_Angeles", + endTimezone = "America/Los_Angeles", + ), description = "Description of my new event", location = "Los Angeles, CA", metadata = mapOf("your-key" to "value"), From c267395971494ca4da836b404d9d6ccc59ae012c Mon Sep 17 00:00:00 2001 From: Gordan Ovcaric Date: Thu, 30 Apr 2026 17:52:08 +0200 Subject: [PATCH 3/5] Nylas eng: more precise comments, ensure color change applies and add unit testing --- CHANGELOG.md | 7 +++ .../com/nylas/models/CreateEventRequest.kt | 6 ++- src/main/kotlin/com/nylas/models/Event.kt | 3 +- .../com/nylas/models/UpdateEventRequest.kt | 10 ++-- .../kotlin/com/nylas/resources/EventsTests.kt | 52 +++++++++++++++++++ 5 files changed, 71 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3d0b090f..83563dfa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Nylas Java SDK Changelog +## [Unreleased] + +### Added +* `colorId` field on `Event`, `CreateEventRequest`, and `UpdateEventRequest` for Google Calendar event colors, mapped to the `color_id` JSON property. + Valid values are strings `"1"` through `"11"`. + See [Google Calendar Colors](https://developers.google.com/calendar/api/v3/reference/colors). + ## [v2.15.1] - Release 2026-03-30 ### Changed diff --git a/src/main/kotlin/com/nylas/models/CreateEventRequest.kt b/src/main/kotlin/com/nylas/models/CreateEventRequest.kt index 8f3b468f..d42044b2 100644 --- a/src/main/kotlin/com/nylas/models/CreateEventRequest.kt +++ b/src/main/kotlin/com/nylas/models/CreateEventRequest.kt @@ -95,7 +95,8 @@ data class CreateEventRequest( @Json(name = "notetaker") val notetaker: EventNotetakerRequest? = null, /** - * The Google color ID for the event. (Currently) Only applies to Google Calendar events. + * The Google color ID for the event. Only supported by Google Calendar providers; ignored by other providers. + * Valid values are strings "1" through "11". * @see Google Calendar Colors */ @Json(name = "color_id") @@ -633,7 +634,8 @@ data class CreateEventRequest( fun notetaker(notetaker: EventNotetakerRequest) = apply { this.notetaker = notetaker } /** - * Set the Google color ID for the event. Only applies to Google Calendar events. + * Set the Google color ID for the event. Only supported by Google Calendar providers; ignored by other providers. + * Valid values are strings "1" through "11". * @param colorId The Google color ID. * @return The builder. * @see Google Calendar Colors diff --git a/src/main/kotlin/com/nylas/models/Event.kt b/src/main/kotlin/com/nylas/models/Event.kt index 5d513296..4c83af7c 100644 --- a/src/main/kotlin/com/nylas/models/Event.kt +++ b/src/main/kotlin/com/nylas/models/Event.kt @@ -156,7 +156,8 @@ data class Event( @Json(name = "original_start_time") val originalStartTime: Long? = null, /** - * The Google color ID for the event. (Currently) Only applies to Google Calendar events. + * The Google color ID for the event. Only supported by Google Calendar providers; ignored by other providers. + * Valid values are strings "1" through "11". * @see Google Calendar Colors */ @Json(name = "color_id") diff --git a/src/main/kotlin/com/nylas/models/UpdateEventRequest.kt b/src/main/kotlin/com/nylas/models/UpdateEventRequest.kt index 75899a77..d534e6a2 100644 --- a/src/main/kotlin/com/nylas/models/UpdateEventRequest.kt +++ b/src/main/kotlin/com/nylas/models/UpdateEventRequest.kt @@ -95,7 +95,8 @@ data class UpdateEventRequest( @Json(name = "notetaker") val notetaker: EventNotetakerRequest? = null, /** - * The Google color ID for the event. (Currently) Only applies to Google Calendar events. + * The Google color ID for the event. Only supported by Google Calendar providers; ignored by other providers. + * Valid values are strings "1" through "11". * @see Google Calendar Colors */ @Json(name = "color_id") @@ -727,12 +728,13 @@ data class UpdateEventRequest( fun notetaker(notetaker: EventNotetakerRequest) = apply { this.notetaker = notetaker } /** - * Update the Google color ID for the event. Only applies to Google Calendar events. - * @param colorId The Google color ID. + * Update the Google color ID for the event. Only supported by Google Calendar providers; ignored by other providers. + * Pass null to clear an existing color. Valid values are strings "1" through "11". + * @param colorId The Google color ID, or null to clear the color. * @return The builder. * @see Google Calendar Colors */ - fun colorId(colorId: String) = apply { this.colorId = colorId } + fun colorId(colorId: String?) = apply { this.colorId = colorId } /** * Builds the [UpdateEventRequest] object. diff --git a/src/test/kotlin/com/nylas/resources/EventsTests.kt b/src/test/kotlin/com/nylas/resources/EventsTests.kt index fa4d7096..2341ac9f 100644 --- a/src/test/kotlin/com/nylas/resources/EventsTests.kt +++ b/src/test/kotlin/com/nylas/resources/EventsTests.kt @@ -14,8 +14,10 @@ import org.mockito.MockitoAnnotations import org.mockito.kotlin.* import java.lang.reflect.Type import kotlin.test.Test +import kotlin.test.assertFalse import kotlin.test.assertEquals import kotlin.test.assertIs +import kotlin.test.assertTrue class EventsTests { private val mockHttpClient: OkHttpClient = Mockito.mock(OkHttpClient::class.java) @@ -441,6 +443,54 @@ class EventsTests { assertEquals("123456", details["pin"]) } + @Test + fun `CreateEventRequest with colorId serializes color_id field`() { + val adapter = JsonHelper.moshi().adapter(CreateEventRequest::class.java) + val request = CreateEventRequest( + whenObj = CreateEventRequest.When.Time(1620000000), + colorId = "7", + ) + + val jsonMap = JsonHelper.moshi().adapter(Map::class.java).fromJson(adapter.toJson(request))!! + assertEquals("7", jsonMap["color_id"]) + } + + @Test + fun `CreateEventRequest without colorId omits color_id from serialized JSON`() { + val adapter = JsonHelper.moshi().adapter(CreateEventRequest::class.java) + val request = CreateEventRequest(whenObj = CreateEventRequest.When.Time(1620000000)) + + val json = adapter.toJson(request) + assertFalse(json.contains("color_id")) + } + + @Test + fun `UpdateEventRequest with colorId serializes color_id field`() { + val adapter = JsonHelper.moshi().adapter(UpdateEventRequest::class.java) + val request = UpdateEventRequest(colorId = "11") + + val jsonMap = JsonHelper.moshi().adapter(Map::class.java).fromJson(adapter.toJson(request))!! + assertEquals("11", jsonMap["color_id"]) + } + + @Test + fun `UpdateEventRequest without colorId omits color_id from serialized JSON`() { + val adapter = JsonHelper.moshi().adapter(UpdateEventRequest::class.java) + val request = UpdateEventRequest(title = "Test") + + val json = adapter.toJson(request) + assertFalse(json.contains("color_id")) + } + + @Test + fun `UpdateEventRequest builder colorId can be cleared with null`() { + val adapter = JsonHelper.moshi().adapter(UpdateEventRequest::class.java) + val request = UpdateEventRequest.Builder().colorId(null).build() + + val json = adapter.toJson(request) + assertFalse(json.contains("color_id")) + } + @Test fun `Event with existing ConferencingProvider still works properly`() { // This test verifies that the original Event model continues to work with the original ConferencingProvider enum @@ -926,6 +976,7 @@ class EventsTests { assertEquals("v3/grants/$grantId/events", pathCaptor.firstValue) assertEquals(Types.newParameterizedType(Response::class.java, Event::class.java), typeCaptor.firstValue) assertEquals(adapter.toJson(createEventRequest), requestBodyCaptor.firstValue) + assertTrue(requestBodyCaptor.firstValue.contains("\"color_id\":\"7\"")) } @Test @@ -969,6 +1020,7 @@ class EventsTests { assertEquals("v3/grants/$grantId/events/$eventId", pathCaptor.firstValue) assertEquals(Types.newParameterizedType(Response::class.java, Event::class.java), typeCaptor.firstValue) assertEquals(adapter.toJson(updateEventRequest), requestBodyCaptor.firstValue) + assertTrue(requestBodyCaptor.firstValue.contains("\"color_id\":\"11\"")) } @Test From 31ad4f1ce943000120d1fcc24d9480964af79183 Mon Sep 17 00:00:00 2001 From: Gordan Ovcaric Date: Thu, 30 Apr 2026 18:05:36 +0200 Subject: [PATCH 4/5] Nylas eng: fix the claude-code change error --- src/main/kotlin/com/nylas/models/UpdateEventRequest.kt | 6 +++--- src/test/kotlin/com/nylas/resources/EventsTests.kt | 9 --------- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/src/main/kotlin/com/nylas/models/UpdateEventRequest.kt b/src/main/kotlin/com/nylas/models/UpdateEventRequest.kt index d534e6a2..6c3af4b4 100644 --- a/src/main/kotlin/com/nylas/models/UpdateEventRequest.kt +++ b/src/main/kotlin/com/nylas/models/UpdateEventRequest.kt @@ -729,12 +729,12 @@ data class UpdateEventRequest( /** * Update the Google color ID for the event. Only supported by Google Calendar providers; ignored by other providers. - * Pass null to clear an existing color. Valid values are strings "1" through "11". - * @param colorId The Google color ID, or null to clear the color. + * Valid values are strings "1" through "11". + * @param colorId The Google color ID. * @return The builder. * @see Google Calendar Colors */ - fun colorId(colorId: String?) = apply { this.colorId = colorId } + fun colorId(colorId: String) = apply { this.colorId = colorId } /** * Builds the [UpdateEventRequest] object. diff --git a/src/test/kotlin/com/nylas/resources/EventsTests.kt b/src/test/kotlin/com/nylas/resources/EventsTests.kt index 2341ac9f..d3f34784 100644 --- a/src/test/kotlin/com/nylas/resources/EventsTests.kt +++ b/src/test/kotlin/com/nylas/resources/EventsTests.kt @@ -482,15 +482,6 @@ class EventsTests { assertFalse(json.contains("color_id")) } - @Test - fun `UpdateEventRequest builder colorId can be cleared with null`() { - val adapter = JsonHelper.moshi().adapter(UpdateEventRequest::class.java) - val request = UpdateEventRequest.Builder().colorId(null).build() - - val json = adapter.toJson(request) - assertFalse(json.contains("color_id")) - } - @Test fun `Event with existing ConferencingProvider still works properly`() { // This test verifies that the original Event model continues to work with the original ConferencingProvider enum From b934968389ea2f45eeffa24f5f34ed992e189652 Mon Sep 17 00:00:00 2001 From: Gordan Ovcaric Date: Thu, 30 Apr 2026 18:12:34 +0200 Subject: [PATCH 5/5] Nylas eng: lint fix --- src/test/kotlin/com/nylas/resources/EventsTests.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/kotlin/com/nylas/resources/EventsTests.kt b/src/test/kotlin/com/nylas/resources/EventsTests.kt index d3f34784..8f6ffac5 100644 --- a/src/test/kotlin/com/nylas/resources/EventsTests.kt +++ b/src/test/kotlin/com/nylas/resources/EventsTests.kt @@ -14,8 +14,8 @@ import org.mockito.MockitoAnnotations import org.mockito.kotlin.* import java.lang.reflect.Type import kotlin.test.Test -import kotlin.test.assertFalse import kotlin.test.assertEquals +import kotlin.test.assertFalse import kotlin.test.assertIs import kotlin.test.assertTrue