-
Notifications
You must be signed in to change notification settings - Fork 20
/
email_created.go
44 lines (38 loc) · 1.24 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
42
43
44
package events
import "github.com/nyaruka/goflow/flows"
// TypeEmailCreated is our type for the email event
const TypeEmailCreated string = "email_created"
// EmailCreatedEvent events are created for each recipient which should receive 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(),
Addresses: addresses,
Subject: subject,
Body: body,
}
}
// Type returns the type of this event
func (a *EmailCreatedEvent) Type() string { return TypeEmailCreated }
// Apply applies this event to the given run
func (e *EmailCreatedEvent) Apply(run flows.FlowRun) error {
return nil
}