Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the response type for listing of scheduled messages #250

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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

### Unreleased
* Added support for `Accept-Encoding: gzip` in HTTP headers
* Fixed response type for returning list of scheduled messages

### [2.5.0] - Released 2024-09-25

Expand Down
4 changes: 2 additions & 2 deletions src/main/kotlin/com/nylas/resources/Messages.kt
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,9 @@ class Messages(client: NylasClient) : Resource<Message>(client, Message::class.j
*/
@Throws(NylasApiError::class, NylasSdkTimeoutError::class)
@JvmOverloads
fun listScheduledMessages(identifier: String, overrides: RequestOverrides? = null): Response<ScheduledMessagesList> {
fun listScheduledMessages(identifier: String, overrides: RequestOverrides? = null): ListResponse<ScheduledMessage> {
val path = String.format("v3/grants/%s/messages/schedules", identifier)
val responseType = Types.newParameterizedType(Response::class.java, ScheduledMessagesList::class.java)
val responseType = Types.newParameterizedType(ListResponse::class.java, ScheduledMessage::class.java)
return client.executeGet(path, responseType, overrides = overrides)
}

Expand Down
4 changes: 2 additions & 2 deletions src/test/kotlin/com/nylas/resources/MessagesTests.kt
Original file line number Diff line number Diff line change
Expand Up @@ -300,15 +300,15 @@ class MessagesTests {
val typeCaptor = argumentCaptor<Type>()
val queryParamCaptor = argumentCaptor<IQueryParams>()
val overrideParamCaptor = argumentCaptor<RequestOverrides>()
verify(mockNylasClient).executeGet<Response<Message>>(
verify(mockNylasClient).executeGet<ListResponse<ScheduledMessage>>(
pathCaptor.capture(),
typeCaptor.capture(),
queryParamCaptor.capture(),
overrideParamCaptor.capture(),
)

assertEquals("v3/grants/$grantId/messages/schedules", pathCaptor.firstValue)
assertEquals(Types.newParameterizedType(Response::class.java, ScheduledMessagesList::class.java), typeCaptor.firstValue)
assertEquals(Types.newParameterizedType(ListResponse::class.java, ScheduledMessage::class.java), typeCaptor.firstValue)
assertNull(queryParamCaptor.firstValue)
}

Expand Down
Loading