Skip to content

Commit

Permalink
Make from optional for Message and Draft models (#204)
Browse files Browse the repository at this point in the history
# Description
This PR makes the `from` field optional for both messages and drafts,
aligning it to the API.

# License
<!-- Your PR comment must contain the following line for us to merge the
PR. -->
I confirm that this contribution is made under the terms of the MIT
license and that I have the authority necessary to make this
contribution on behalf of its copyright owner.
  • Loading branch information
mrashed-dev authored Feb 8, 2024
1 parent 2f99817 commit 42cd063
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Unreleased

* Fix schema issue in the `Event` model
* Fix schema issue in the `Event`, `Message`, and `Draft` models

## [2.0.0] - Released 2024-02-05

Expand Down
10 changes: 5 additions & 5 deletions src/main/kotlin/com/nylas/models/Draft.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@ class Draft(
*/
@Json(name = "grant_id")
val grantId: String,
/**
* An array of message senders.
*/
@Json(name = "from")
val from: List<EmailName>,
/**
* Unix timestamp of when the message was received by the mail server.
* This may be different from the unverified Date header in raw message object.
Expand All @@ -32,6 +27,11 @@ class Draft(
*/
@Json(name = "object")
private val obj: String = "draft",
/**
* An array of message senders.
*/
@Json(name = "from")
val from: List<EmailName>? = null,
/**
* An array of bcc recipients.
*/
Expand Down
10 changes: 5 additions & 5 deletions src/main/kotlin/com/nylas/models/Message.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@ data class Message(
*/
@Json(name = "grant_id")
val grantId: String,
/**
* An array of message senders.
*/
@Json(name = "from")
val from: List<EmailName>,
/**
* The type of object.
*/
@Json(name = "object")
private val obj: String = "message",
/**
* An array of message senders.
*/
@Json(name = "from")
val from: List<EmailName>? = null,
/**
* The unique identifier for the message.
* Note: The ID may not be present for scheduled messages until the message is sent.
Expand Down
6 changes: 3 additions & 3 deletions src/test/kotlin/com/nylas/resources/DraftsTests.kt
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,9 @@ class DraftsTests {
assertEquals(2, draft.folders?.size)
assertEquals("8l6c4d11y1p4dm4fxj52whyr9", draft.folders?.first())
assertEquals("d9zkcr2tljpu3m4qpj7l2hbr0", draft.folders?.last())
assertEquals(1, draft.from.size)
assertEquals("Daenerys Targaryen", draft.from.first().name)
assertEquals("[email protected]", draft.from.first().email)
assertEquals(1, draft.from?.size)
assertEquals("Daenerys Targaryen", draft.from?.first()?.name)
assertEquals("[email protected]", draft.from?.first()?.email)
assertEquals("41009df5-bf11-4c97-aa18-b285b5f2e386", draft.grantId)
assertEquals("5d3qmne77v32r8l4phyuksl2x", draft.id)
assertEquals("draft", draft.getObject())
Expand Down
6 changes: 3 additions & 3 deletions src/test/kotlin/com/nylas/resources/MessagesTests.kt
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,9 @@ class MessagesTests {
assertEquals(2, message.folders?.size)
assertEquals("8l6c4d11y1p4dm4fxj52whyr9", message.folders?.get(0))
assertEquals("d9zkcr2tljpu3m4qpj7l2hbr0", message.folders?.get(1))
assertEquals(1, message.from.size)
assertEquals("Daenerys Targaryen", message.from[0].name)
assertEquals("[email protected]", message.from[0].email)
assertEquals(1, message.from?.size)
assertEquals("Daenerys Targaryen", message.from?.get(0)?.name)
assertEquals("[email protected]", message.from?.get(0)?.email)
assertEquals("41009df5-bf11-4c97-aa18-b285b5f2e386", message.grantId)
assertEquals("5d3qmne77v32r8l4phyuksl2x", message.id)
assertEquals("message", message.getObject())
Expand Down

0 comments on commit 42cd063

Please sign in to comment.