Skip to content

Commit

Permalink
add: Support send_each_at mail header
Browse files Browse the repository at this point in the history
  • Loading branch information
yudppp committed Mar 3, 2022
1 parent 542c69c commit b8069cc
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
6 changes: 6 additions & 0 deletions helpers/mail/mail_v3.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ type Personalization struct {
DynamicTemplateData map[string]interface{} `json:"dynamic_template_data,omitempty"`
Categories []string `json:"categories,omitempty"`
SendAt int `json:"send_at,omitempty"`
SendEachAt []int `json:"send_each_at,omitempty"`
}

// Email holds email name and address info
Expand Down Expand Up @@ -369,6 +370,11 @@ func (p *Personalization) SetSendAt(sendAt int) {
p.SendAt = sendAt
}

// SetSendEachAt ...
func (p *Personalization) SetSendEachAt(sendEachAt []int) {
p.SendEachAt = sendEachAt
}

// NewAttachment ...
func NewAttachment() *Attachment {
return &Attachment{}
Expand Down
12 changes: 12 additions & 0 deletions helpers/mail/mail_v3_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,18 @@ func TestV3PersonalizationSetSendAt(t *testing.T) {
assert.Equal(t, sendAt, p.SendAt, fmt.Sprintf("sendat should be %d, got %d", sendAt, p.SendAt))
}

func TestV3PersonalizationSetSendEachAt(t *testing.T) {
sendAts := []int{
time.Now().Second(),
time.Now().AddDate(0, 0, 1).Second(),
}

p := NewPersonalization()
p.SetSendEachAt(sendAts)

assert.Equal(t, len(sendAts), len(p.SendEachAt), fmt.Sprintf("length of SendEachAt should be %d, got %d", len(sendAts), len(p.SendEachAt)))
}

func TestV3NewAttachment(t *testing.T) {
assert.NotNil(t, NewAttachment(), "NewAttachment() shouldn't return nil")
}
Expand Down

0 comments on commit b8069cc

Please sign in to comment.