Skip to content

Commit

Permalink
feat: add mail_v3 functionality for reply_to_list
Browse files Browse the repository at this point in the history
Add reply_to_list functionality.
  • Loading branch information
lopezator committed Dec 19, 2023
1 parent 574e54c commit c76dfc3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
7 changes: 7 additions & 0 deletions helpers/mail/mail_v3.go
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
11 changes: 11 additions & 0 deletions helpers/mail/mail_v3_test.go
Expand Up @@ -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()

Expand Down

0 comments on commit c76dfc3

Please sign in to comment.