Skip to content

Commit 09e66e6

Browse files
authored
TW-3961: include grantID in get folders response (#313)
1 parent e36d2b9 commit 09e66e6

4 files changed

Lines changed: 48 additions & 2 deletions

File tree

‎.claude/instructions.md‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,23 @@ Your job is to maintain parity with the API to ensure that the SDK supports all
99

1010
When asked to add support for a new feature, query parameter, or API endpoint, follow this workflow:
1111

12+
### 0. Analyse Backward Compatibility FIRST (before proposing any plan)
13+
14+
Before writing a plan or touching any code, explicitly analyse whether the proposed changes are backward compatible for existing SDK consumers (both Kotlin and Java).
15+
16+
Check all of the following:
17+
- **Source compatibility (Kotlin)**: Does changing a type (e.g. `String` → `String?`) break existing call sites that assume non-nullability?
18+
- **Source compatibility (Java)**: Does the change affect compiled Java code that uses the SDK?
19+
- **Binary compatibility (JVM)**: Does the bytecode signature of any public method change?
20+
- **Constructor/data class compatibility**: Does changing a field's type or default break existing construction patterns?
21+
22+
If the change is **NOT** backward compatible, output this warning in your response before anything else:
23+
24+
> # ⚠️ WARNING: THIS CHANGE IS NOT BACKWARD COMPATIBLE ⚠️
25+
> Existing SDK consumers will be broken. Do not proceed without explicit user approval or a backward-compatible alternative.
26+
27+
If a backward-compatible alternative exists (e.g. using `String = ""` instead of `String?` to keep Moshi happy while preserving non-nullability), prefer it and explain why.
28+
1229
### 1. Understand the Codebase
1330
- Scan the project structure
1431
- Understand the architecture and how it's organized

‎CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
* `metadataPair` field on `ListMessagesQueryParams` (and its `Builder`) for filtering messages by metadata key-value pairs via the `metadata_pair` query parameter. (#319)
2121

2222
### Fixed
23+
* `Folder.id` and `Folder.grantId` now default to empty strings so deserialization no longer fails when either field is absent from the API response due to the `select` query parameter
2324
* `ConferencingProvider`, `CreateEventAutoConferencingProvider`, and `CreateEventManualConferencingProvider` now deserialize to `null` instead of throwing a `JsonDataException` when the API returns an unrecognized provider name (e.g. `"Hangouts"`). (#320)
2425
* `url`, `originalErrorMessage`, and `timeout` are now exposed as readable properties on `NylasSdkRemoteClosedError` and `NylasSdkTimeoutError`. (#320)
2526
* Thread IDs containing `/` are now URL-encoded before being interpolated into request paths, preventing malformed URLs when using `Threads.find()`, `update()`, or `destroy()`. (#318)

‎src/main/kotlin/com/nylas/models/Folder.kt‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ data class Folder(
1010
* A globally unique object identifier.
1111
*/
1212
@Json(name = "id")
13-
val id: String,
13+
val id: String = "",
1414
/**
1515
* A Grant ID of the Nylas account.
1616
*/
1717
@Json(name = "grant_id")
18-
val grantId: String,
18+
val grantId: String = "",
1919
/**
2020
* Folder name
2121
*/

‎src/test/kotlin/com/nylas/resources/FoldersTests.kt‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,34 @@ class FoldersTests {
7575
assertEquals(0, folder.totalCount)
7676
assertEquals(listOf("\\SENT"), folder.attributes)
7777
}
78+
79+
@Test
80+
fun `Folder deserializes correctly when grant_id is absent due to select`() {
81+
val adapter = JsonHelper.moshi().adapter(Folder::class.java)
82+
val jsonBuffer = Buffer().writeUtf8(
83+
"""{ "id": "SENT", "name": "SENT", "object": "folder" }""",
84+
)
85+
86+
val folder = adapter.fromJson(jsonBuffer)!!
87+
assertIs<Folder>(folder)
88+
assertEquals("SENT", folder.id)
89+
assertEquals("", folder.grantId)
90+
assertEquals("SENT", folder.name)
91+
}
92+
93+
@Test
94+
fun `Folder deserializes correctly when both id and grant_id are absent due to select`() {
95+
val adapter = JsonHelper.moshi().adapter(Folder::class.java)
96+
val jsonBuffer = Buffer().writeUtf8(
97+
"""{ "name": "SENT", "object": "folder" }""",
98+
)
99+
100+
val folder = adapter.fromJson(jsonBuffer)!!
101+
assertIs<Folder>(folder)
102+
assertEquals("", folder.id)
103+
assertEquals("", folder.grantId)
104+
assertEquals("SENT", folder.name)
105+
}
78106
}
79107

80108
@Nested

0 commit comments

Comments
 (0)