Skip to content

Commit

Permalink
Add "from" field to CreateDraftRequest (#233)
Browse files Browse the repository at this point in the history
The SDK should allow setting the "from" address. This was a feature in
v2 and is available in the v3 API. Many accounts have "from" aliases or
valid alternate "from" addresses that can be used when sending emails.

# 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.

Co-authored-by: Mostafa Rashed <[email protected]>
  • Loading branch information
burtonrhodes and mrashed-dev authored Jun 26, 2024
1 parent d173b93 commit 65399f6
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/main/kotlin/com/nylas/models/CreateDraftRequest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ import com.squareup.moshi.Json
* Class representing a request to create a draft.
*/
data class CreateDraftRequest(
/**
* From address. (Optional) If not provided, the default address will be used.
*/
@Json(name = "from")
val from: List<EmailName>? = null,
/**
* An array of message recipients.
*/
Expand Down Expand Up @@ -72,6 +77,7 @@ data class CreateDraftRequest(
* Builder for [CreateDraftRequest].
*/
class Builder {
private var from: List<EmailName>? = null
private var to: List<EmailName>? = null
private var bcc: List<EmailName>? = null
private var cc: List<EmailName>? = null
Expand All @@ -85,6 +91,13 @@ data class CreateDraftRequest(
private var trackingOptions: TrackingOptions? = null
private var customHeaders: List<CustomHeader>? = null

/**
* Sets the from address.
* @param from The from address.
* @return The builder.
*/
fun from(from: List<EmailName>?) = apply { this.from = from }

/**
* Sets the recipients.
* @param to The recipients.
Expand Down Expand Up @@ -176,6 +189,7 @@ data class CreateDraftRequest(
*/
fun build() =
CreateDraftRequest(
from,
to,
bcc,
cc,
Expand Down

0 comments on commit 65399f6

Please sign in to comment.