-
Notifications
You must be signed in to change notification settings - Fork 20
/
email_created.go
41 lines (35 loc) · 1.11 KB
/
email_created.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package events
import (
"github.com/nyaruka/goflow/flows"
)
func init() {
RegisterType(TypeEmailCreated, func() flows.Event { return &EmailCreatedEvent{} })
}
// TypeEmailCreated is our type for the email event
const TypeEmailCreated string = "email_created"
// EmailCreatedEvent events are created when an action wants to send an email.
//
// {
// "type": "email_created",
// "created_on": "2006-01-02T15:04:05Z",
// "addresses": ["foo@bar.com"],
// "subject": "Your activation token",
// "body": "Your activation token is AAFFKKEE"
// }
//
// @event email_created
type EmailCreatedEvent struct {
BaseEvent
Addresses []string `json:"addresses" validate:"required,min=1"`
Subject string `json:"subject" validate:"required"`
Body string `json:"body"`
}
// NewEmailCreatedEvent returns a new email event with the passed in subject, body and emails
func NewEmailCreatedEvent(addresses []string, subject string, body string) *EmailCreatedEvent {
return &EmailCreatedEvent{
BaseEvent: NewBaseEvent(TypeEmailCreated),
Addresses: addresses,
Subject: subject,
Body: body,
}
}