Skip to content
Open
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## [Unreleased]

### Added
* `GetFreeBusyRequest.tentativeAsBusy` mapped to the `tentative_as_busy` request field while preserving the existing Java constructor overload for backward compatibility

### Changed
* Clarify that event `default` visibility is Google-only

Expand Down
7 changes: 6 additions & 1 deletion src/main/kotlin/com/nylas/models/GetFreeBusyRequest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import com.squareup.moshi.Json
/**
* Class representation of a Nylas get free-busy request
*/
data class GetFreeBusyRequest(
data class GetFreeBusyRequest @JvmOverloads constructor(
/**
* Unix timestamp representing the start of the time block for assessing the account's free/busy schedule.
*/
Expand All @@ -21,4 +21,9 @@ data class GetFreeBusyRequest(
*/
@Json(name = "emails")
val emails: List<String>,
/**
* When true, tentative events are counted as busy.
*/
@Json(name = "tentative_as_busy")
val tentativeAsBusy: Boolean? = null,
)
33 changes: 33 additions & 0 deletions src/test/kotlin/com/nylas/resources/CalendarsTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,38 @@ class CalendarsTest {
assertEquals(2, cal.notetaker?.rules?.participantFilter?.participantsGte)
assertEquals(10, cal.notetaker?.rules?.participantFilter?.participantsLte)
}

@Test
fun `GetFreeBusyRequest serializes tentative as busy when set`() {
val adapter = JsonHelper.moshi().adapter(GetFreeBusyRequest::class.java)
val request = GetFreeBusyRequest(
startTime = 1620000000,
endTime = 1620003600,
emails = listOf("test@nylas.com"),
tentativeAsBusy = true,
)

val json = adapter.toJson(request)
val deserialized = adapter.fromJson(json)!!

assertEquals(true, deserialized.tentativeAsBusy)
}

@Test
fun `GetFreeBusyRequest legacy constructor remains backward compatible`() {
val adapter = JsonHelper.moshi().adapter(GetFreeBusyRequest::class.java)
val request = GetFreeBusyRequest(
1620000000,
1620003600,
listOf("test@nylas.com"),
)

val json = adapter.toJson(request)
val deserialized = adapter.fromJson(json)!!

assertEquals(null, deserialized.tentativeAsBusy)
assertEquals(false, json.contains("tentative_as_busy"))
}
}

@Nested
Expand Down Expand Up @@ -923,6 +955,7 @@ class CalendarsTest {
startTime = 1620000000,
endTime = 1620000000,
emails = listOf("test@nylas.com"),
tentativeAsBusy = true,
)

calendars.getFreeBusy(grantId, getFreeBusyRequest)
Expand Down
Loading