From e22a3b5910ae49b59b2f9f25d39553295a4ecf5a Mon Sep 17 00:00:00 2001 From: Kewyn Akshlley Date: Tue, 16 Jan 2024 14:17:12 -0300 Subject: [PATCH] fix: Fix wrong reference to reply_to attribute (#27) --- .../emails/model/CreateEmailOptions.java | 52 ++++++++++--------- 1 file changed, 27 insertions(+), 25 deletions(-) diff --git a/src/main/java/com/resend/services/emails/model/CreateEmailOptions.java b/src/main/java/com/resend/services/emails/model/CreateEmailOptions.java index c12641b..e6dd696 100644 --- a/src/main/java/com/resend/services/emails/model/CreateEmailOptions.java +++ b/src/main/java/com/resend/services/emails/model/CreateEmailOptions.java @@ -2,10 +2,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; /** * Represents a request to send an email. @@ -204,9 +201,7 @@ public Builder to(String... recipients) { if (this.to == null) { this.to = new ArrayList<>(); } - for (String recipient : recipients) { - this.to.add(recipient); - } + this.to.addAll(Arrays.asList(recipients)); return this; } @@ -267,9 +262,7 @@ public Builder cc(String... recipients) { if (this.cc == null) { this.cc = new ArrayList<>(); } - for (String recipient : recipients) { - this.cc.add(recipient); - } + this.cc.addAll(Arrays.asList(recipients)); return this; } @@ -280,7 +273,10 @@ public Builder cc(String... recipients) { * @return This builder instance for method chaining. */ public Builder cc(List cc) { - this.cc = cc; + if (this.cc == null) { + this.cc = new ArrayList<>(); + } + this.cc.addAll(cc); return this; } @@ -309,9 +305,7 @@ public Builder bcc(String... recipients) { if (this.bcc == null) { this.bcc = new ArrayList<>(); } - for (String recipient : recipients) { - this.bcc.add(recipient); - } + this.bcc.addAll(Arrays.asList(recipients)); return this; } @@ -322,7 +316,12 @@ public Builder bcc(String... recipients) { * @return This builder instance for method chaining. */ public Builder bcc(List recipients) { - this.bcc = recipients; + if (this.bcc == null) { + this.bcc = new ArrayList<>(); + } + + this.bcc.addAll(recipients); + return this; } @@ -350,9 +349,7 @@ public Builder replyTo(String... recipients) { if (this.replyTo == null) { this.replyTo = new ArrayList<>(); } - for (String recipient : recipients) { - this.replyTo.add(recipient); - } + this.replyTo.addAll(Arrays.asList(recipients)); return this; } @@ -363,7 +360,12 @@ public Builder replyTo(String... recipients) { * @return This builder instance for method chaining. */ public Builder replyTo(List recipients) { - this.replyTo = replyTo; + if (this.replyTo == null) { + this.replyTo = new ArrayList<>(); + } + + this.replyTo.addAll(recipients); + return this; } @@ -429,9 +431,9 @@ public Builder attachments(Attachment... attachments) { if (this.attachments == null) { this.attachments = new ArrayList<>(); } - for (Attachment attachment : attachments) { - this.attachments.add(attachment); - } + + this.attachments.addAll(Arrays.asList(attachments)); + return this; } @@ -470,9 +472,9 @@ public Builder tags(Tag... tags) { if (this.tags == null) { this.tags = new ArrayList<>(); } - for (Tag tag : tags) { - this.tags.add(tag); - } + + this.tags.addAll(Arrays.asList(tags)); + return this; }