diff --git a/CHANGELOG.md b/CHANGELOG.md index 81cfe6ef..2c32f0bf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,9 +3,15 @@ ### [Unreleased] ### Added +* Added missing webhook triggers +* Added provider field to token exchange response +* Added support for clean messages endpoint * Added support for custom headers field for Drafts and Messages * Added support for overriding various fields of outgoing requests +### Changed +* Fixed issue where attachments < 3mb were not being encoded correctly + ## [2.2.1] - Released 2024-03-05 ### Added diff --git a/src/main/kotlin/com/nylas/models/CleanMessageRequest.kt b/src/main/kotlin/com/nylas/models/CleanMessagesRequest.kt similarity index 93% rename from src/main/kotlin/com/nylas/models/CleanMessageRequest.kt rename to src/main/kotlin/com/nylas/models/CleanMessagesRequest.kt index e93af0f4..0979966f 100644 --- a/src/main/kotlin/com/nylas/models/CleanMessageRequest.kt +++ b/src/main/kotlin/com/nylas/models/CleanMessagesRequest.kt @@ -5,7 +5,7 @@ import com.squareup.moshi.Json /** * Class representation of a Nylas clean message request */ -data class CleanMessageRequest( +data class CleanMessagesRequest( /** * IDs of the email messages to clean. */ @@ -39,7 +39,7 @@ data class CleanMessageRequest( ) { /** - * Builder for the [CleanMessageRequest] class. + * Builder for the [CleanMessagesRequest] class. * @param messageId IDs of the email messages to clean. */ data class Builder( @@ -87,10 +87,10 @@ data class CleanMessageRequest( fun removeConclusionPhrases(removeConclusionPhrases: Boolean) = apply { this.removeConclusionPhrases = removeConclusionPhrases } /** - * Builds the [CleanMessageRequest] instance. - * @return The [CleanMessageRequest] instance. + * Builds the [CleanMessagesRequest] instance. + * @return The [CleanMessagesRequest] instance. */ - fun build() = CleanMessageRequest( + fun build() = CleanMessagesRequest( messageId = messageId, ignoreLinks = ignoreLinks, ignoreImages = ignoreImages, diff --git a/src/main/kotlin/com/nylas/models/CleanMessageResponse.kt b/src/main/kotlin/com/nylas/models/CleanMessagesResponse.kt similarity index 98% rename from src/main/kotlin/com/nylas/models/CleanMessageResponse.kt rename to src/main/kotlin/com/nylas/models/CleanMessagesResponse.kt index 07775ed6..9781e368 100644 --- a/src/main/kotlin/com/nylas/models/CleanMessageResponse.kt +++ b/src/main/kotlin/com/nylas/models/CleanMessagesResponse.kt @@ -2,7 +2,7 @@ package com.nylas.models import com.squareup.moshi.Json -data class CleanMessageResponse( +data class CleanMessagesResponse( /** * Grant ID of the Nylas account. */ diff --git a/src/main/kotlin/com/nylas/resources/Messages.kt b/src/main/kotlin/com/nylas/resources/Messages.kt index b85200f7..42bc5cc2 100644 --- a/src/main/kotlin/com/nylas/resources/Messages.kt +++ b/src/main/kotlin/com/nylas/resources/Messages.kt @@ -147,17 +147,17 @@ class Messages(client: NylasClient) : Resource(client, Message::class.j } /** - * Clean messages + * Remove extra information from a list of messages * @param identifier The identifier of the grant to act upon * @param requestBody The values to clean the message with * @return The list of cleaned messages */ @Throws(NylasApiError::class, NylasSdkTimeoutError::class) - fun cleanConversation(identifier: String, requestBody: CleanMessageRequest): ListResponse { + fun cleanMessages(identifier: String, requestBody: CleanMessagesRequest): ListResponse { val path = String.format("v3/grants/%s/messages/clean", identifier) - val adapter = JsonHelper.moshi().adapter(CleanMessageRequest::class.java) + val adapter = JsonHelper.moshi().adapter(CleanMessagesRequest::class.java) val serializedRequestBody = adapter.toJson(requestBody) - val responseType = Types.newParameterizedType(ListResponse::class.java, CleanMessageResponse::class.java) + val responseType = Types.newParameterizedType(ListResponse::class.java, CleanMessagesResponse::class.java) return client.executePut(path, responseType, serializedRequestBody) } } diff --git a/src/test/kotlin/com/nylas/resources/MessagesTests.kt b/src/test/kotlin/com/nylas/resources/MessagesTests.kt index 571284b8..6ce990d1 100644 --- a/src/test/kotlin/com/nylas/resources/MessagesTests.kt +++ b/src/test/kotlin/com/nylas/resources/MessagesTests.kt @@ -541,9 +541,9 @@ class MessagesTests { @Test fun `cleaning a message calls requests with the correct params`() { val messageId = "message-123" - val adapter = JsonHelper.moshi().adapter(CleanMessageRequest::class.java) - val cleanMessageRequest = - CleanMessageRequest.Builder(listOf(messageId)) + val adapter = JsonHelper.moshi().adapter(CleanMessagesRequest::class.java) + val cleanMessagesRequest = + CleanMessagesRequest.Builder(listOf(messageId)) .ignoreLinks(true) .ignoreImages(true) .imagesAsMarkdown(true) @@ -551,14 +551,14 @@ class MessagesTests { .removeConclusionPhrases(true) .build() - messages.cleanConversation(grantId, cleanMessageRequest) + messages.cleanMessages(grantId, cleanMessagesRequest) val pathCaptor = argumentCaptor() val typeCaptor = argumentCaptor() val requestBodyCaptor = argumentCaptor() val queryParamCaptor = argumentCaptor() val overrideParamCaptor = argumentCaptor() - verify(mockNylasClient).executePut>( + verify(mockNylasClient).executePut>( pathCaptor.capture(), typeCaptor.capture(), requestBodyCaptor.capture(), @@ -567,8 +567,8 @@ class MessagesTests { ) assertEquals("v3/grants/$grantId/messages/clean", pathCaptor.firstValue) - assertEquals(Types.newParameterizedType(ListResponse::class.java, CleanMessageResponse::class.java), typeCaptor.firstValue) - assertEquals(adapter.toJson(cleanMessageRequest), requestBodyCaptor.firstValue) + assertEquals(Types.newParameterizedType(ListResponse::class.java, CleanMessagesResponse::class.java), typeCaptor.firstValue) + assertEquals(adapter.toJson(cleanMessagesRequest), requestBodyCaptor.firstValue) assertNull(queryParamCaptor.firstValue) } }