Skip to content

Commit d0a9507

Browse files
authored
TA-3804: add tentative-as-busy to calendar request (#334)
1 parent 3b233de commit d0a9507

3 files changed

Lines changed: 42 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
## [Unreleased]
44

5+
### Added
6+
* `GetFreeBusyRequest.tentativeAsBusy` mapped to the `tentative_as_busy` request field while preserving the existing Java constructor overload for backward compatibility
7+
58
### Changed
69
* Clarify that event `default` visibility is Google-only
710

src/main/kotlin/com/nylas/models/GetFreeBusyRequest.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import com.squareup.moshi.Json
55
/**
66
* Class representation of a Nylas get free-busy request
77
*/
8-
data class GetFreeBusyRequest(
8+
data class GetFreeBusyRequest @JvmOverloads constructor(
99
/**
1010
* Unix timestamp representing the start of the time block for assessing the account's free/busy schedule.
1111
*/
@@ -21,4 +21,9 @@ data class GetFreeBusyRequest(
2121
*/
2222
@Json(name = "emails")
2323
val emails: List<String>,
24+
/**
25+
* When true, tentative events are counted as busy.
26+
*/
27+
@Json(name = "tentative_as_busy")
28+
val tentativeAsBusy: Boolean? = null,
2429
)

src/test/kotlin/com/nylas/resources/CalendarsTest.kt

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,38 @@ class CalendarsTest {
101101
assertEquals(2, cal.notetaker?.rules?.participantFilter?.participantsGte)
102102
assertEquals(10, cal.notetaker?.rules?.participantFilter?.participantsLte)
103103
}
104+
105+
@Test
106+
fun `GetFreeBusyRequest serializes tentative as busy when set`() {
107+
val adapter = JsonHelper.moshi().adapter(GetFreeBusyRequest::class.java)
108+
val request = GetFreeBusyRequest(
109+
startTime = 1620000000,
110+
endTime = 1620003600,
111+
emails = listOf("test@nylas.com"),
112+
tentativeAsBusy = true,
113+
)
114+
115+
val json = adapter.toJson(request)
116+
val deserialized = adapter.fromJson(json)!!
117+
118+
assertEquals(true, deserialized.tentativeAsBusy)
119+
}
120+
121+
@Test
122+
fun `GetFreeBusyRequest legacy constructor remains backward compatible`() {
123+
val adapter = JsonHelper.moshi().adapter(GetFreeBusyRequest::class.java)
124+
val request = GetFreeBusyRequest(
125+
1620000000,
126+
1620003600,
127+
listOf("test@nylas.com"),
128+
)
129+
130+
val json = adapter.toJson(request)
131+
val deserialized = adapter.fromJson(json)!!
132+
133+
assertEquals(null, deserialized.tentativeAsBusy)
134+
assertEquals(false, json.contains("tentative_as_busy"))
135+
}
104136
}
105137

106138
@Nested
@@ -923,6 +955,7 @@ class CalendarsTest {
923955
startTime = 1620000000,
924956
endTime = 1620000000,
925957
emails = listOf("test@nylas.com"),
958+
tentativeAsBusy = true,
926959
)
927960

928961
calendars.getFreeBusy(grantId, getFreeBusyRequest)

0 commit comments

Comments
 (0)