Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
18 changes: 18 additions & 0 deletions src/main/kotlin/com/nylas/models/CreateEventRequest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,13 @@ data class CreateEventRequest(
*/
@Json(name = "notetaker")
val notetaker: EventNotetakerRequest? = null,
/**
* 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 <a href="https://developers.google.com/calendar/api/v3/reference/colors">Google Calendar Colors</a>
*/
@Json(name = "color_id")
val colorId: String? = null,
) {
/**
* This sealed class represents the different types of event time configurations.
Expand Down Expand Up @@ -511,6 +518,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.
Expand Down Expand Up @@ -625,6 +633,15 @@ data class CreateEventRequest(
*/
fun notetaker(notetaker: EventNotetakerRequest) = apply { this.notetaker = notetaker }

/**
* 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 <a href="https://developers.google.com/calendar/api/v3/reference/colors">Google Calendar Colors</a>
*/
fun colorId(colorId: String) = apply { this.colorId = colorId }

/**
* Builds the [CreateEventRequest] object.
* @return [CreateEventRequest] object.
Expand All @@ -647,6 +664,7 @@ data class CreateEventRequest(
capacity,
hideParticipant,
notetaker,
colorId,
)
}
}
7 changes: 7 additions & 0 deletions src/main/kotlin/com/nylas/models/Event.kt
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,13 @@ data class Event(
*/
@Json(name = "original_start_time")
val originalStartTime: Long? = null,
/**
* 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 <a href="https://developers.google.com/calendar/api/v3/reference/colors">Google Calendar Colors</a>
*/
@Json(name = "color_id")
val colorId: String? = null,
) {
/**
* Get the type of object.
Expand Down
18 changes: 18 additions & 0 deletions src/main/kotlin/com/nylas/models/UpdateEventRequest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,13 @@ data class UpdateEventRequest(
*/
@Json(name = "notetaker")
val notetaker: EventNotetakerRequest? = null,
/**
* 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 <a href="https://developers.google.com/calendar/api/v3/reference/colors">Google Calendar Colors</a>
*/
@Json(name = "color_id")
val colorId: String? = null,
) {
/**
* This sealed class represents the different types of event time configurations.
Expand Down Expand Up @@ -597,6 +604,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.
Expand Down Expand Up @@ -719,6 +727,15 @@ data class UpdateEventRequest(
*/
fun notetaker(notetaker: EventNotetakerRequest) = apply { this.notetaker = notetaker }

/**
* Update 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 <a href="https://developers.google.com/calendar/api/v3/reference/colors">Google Calendar Colors</a>
*/
fun colorId(colorId: String) = apply { this.colorId = colorId }

/**
* Builds the [UpdateEventRequest] object.
* @return [UpdateEventRequest] object.
Expand All @@ -741,6 +758,7 @@ data class UpdateEventRequest(
capacity,
hideParticipant,
notetaker,
colorId,
)
}
}
49 changes: 48 additions & 1 deletion src/test/kotlin/com/nylas/resources/EventsTests.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ import org.mockito.kotlin.*
import java.lang.reflect.Type
import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.test.assertFalse
import kotlin.test.assertIs
import kotlin.test.assertTrue

class EventsTests {
private val mockHttpClient: OkHttpClient = Mockito.mock(OkHttpClient::class.java)
Expand Down Expand Up @@ -111,7 +113,8 @@ class EventsTests {
"audio_recording": true,
"transcription": true
}
}
},
"color_id": "7"
}
""".trimIndent(),
)
Expand Down Expand Up @@ -171,6 +174,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
Expand Down Expand Up @@ -439,6 +443,45 @@ 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 `Event with existing ConferencingProvider still works properly`() {
// This test verifies that the original Event model continues to work with the original ConferencingProvider enum
Expand Down Expand Up @@ -899,6 +942,7 @@ class EventsTests {
transcription = true,
),
),
colorId = "7",
)
val createEventQueryParams =
CreateEventQueryParams(
Expand All @@ -923,6 +967,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
Expand All @@ -941,6 +986,7 @@ class EventsTests {
transcription = true,
),
),
colorId = "11",
)
val updateEventQueryParams =
UpdateEventQueryParams(
Expand All @@ -965,6 +1011,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
Expand Down
Loading