-
Notifications
You must be signed in to change notification settings - Fork 20
/
email_created.go
49 lines (41 loc) · 1.4 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
45
46
47
48
49
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
engineOnlyEvent
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 (e *EmailCreatedEvent) Type() string { return TypeEmailCreated }
// Validate validates our event is valid and has all the assets it needs
func (e *EmailCreatedEvent) Validate(assets flows.SessionAssets) error {
return nil
}
// Apply applies this event to the given run
func (e *EmailCreatedEvent) Apply(run flows.FlowRun) error {
return nil
}