From c76dfc3e81567152ab9fdd5a940f5039b213ef32 Mon Sep 17 00:00:00 2001 From: David Lobe Date: Mon, 18 Dec 2023 16:38:40 +0100 Subject: [PATCH] feat: add mail_v3 functionality for reply_to_list Add reply_to_list functionality. --- helpers/mail/mail_v3.go | 7 +++++++ helpers/mail/mail_v3_test.go | 11 +++++++++++ 2 files changed, 18 insertions(+) diff --git a/helpers/mail/mail_v3.go b/helpers/mail/mail_v3.go index 6d7ac6b4..5f2616d3 100644 --- a/helpers/mail/mail_v3.go +++ b/helpers/mail/mail_v3.go @@ -37,6 +37,7 @@ type SGMailV3 struct { MailSettings *MailSettings `json:"mail_settings,omitempty"` TrackingSettings *TrackingSettings `json:"tracking_settings,omitempty"` ReplyTo *Email `json:"reply_to,omitempty"` + ReplyToList []*Email `json:"reply_to_list,omitempty"` } // Personalization holds mail body struct @@ -232,6 +233,12 @@ func (s *SGMailV3) SetReplyTo(e *Email) *SGMailV3 { return s } +// SetReplyToList ... +func (s *SGMailV3) SetReplyToList(e []*Email) *SGMailV3 { + s.ReplyToList = e + return s +} + // SetTemplateID ... func (s *SGMailV3) SetTemplateID(templateID string) *SGMailV3 { s.TemplateID = templateID diff --git a/helpers/mail/mail_v3_test.go b/helpers/mail/mail_v3_test.go index 28af9192..90fa3794 100644 --- a/helpers/mail/mail_v3_test.go +++ b/helpers/mail/mail_v3_test.go @@ -96,6 +96,17 @@ func TestV3SetReplyTo(t *testing.T) { assert.Equal(t, address, m.ReplyTo.Address, fmt.Sprintf("address should be %s, got %s", address, e.Address)) } +func TestV3SetReplyToList(t *testing.T) { + m := NewV3Mail() + replyTos := []*Email{ + NewEmail("Example User", "test@example.com"), + NewEmail("Example User", "test@example.com"), + } + m.SetReplyToList(replyTos) + + assert.Equal(t, len(replyTos), len(m.ReplyToList), fmt.Sprintf("length of To should be %d, got %d", len(replyTos), len(m.ReplyToList))) +} + func TestV3SetTemplateID(t *testing.T) { m := NewV3Mail()