-
Notifications
You must be signed in to change notification settings - Fork 20
/
contact_field_changed.go
40 lines (34 loc) · 1.18 KB
/
contact_field_changed.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
package events
import (
"github.com/nyaruka/goflow/assets"
"github.com/nyaruka/goflow/flows"
)
func init() {
registerType(TypeContactFieldChanged, func() flows.Event { return &ContactFieldChangedEvent{} })
}
// TypeContactFieldChanged is the type of our save to contact event
const TypeContactFieldChanged string = "contact_field_changed"
// ContactFieldChangedEvent events are created when a custom field value of the contact has been changed.
// A null values indicates that the field value has been cleared.
//
// {
// "type": "contact_field_changed",
// "created_on": "2006-01-02T15:04:05Z",
// "field": {"key": "gender", "name": "Gender"},
// "value": {"text": "Male"}
// }
//
// @event contact_field_changed
type ContactFieldChangedEvent struct {
baseEvent
Field *assets.FieldReference `json:"field" validate:"required"`
Value *flows.Value `json:"value"`
}
// NewContactFieldChanged returns a new save to contact event
func NewContactFieldChanged(field *flows.Field, value *flows.Value) *ContactFieldChangedEvent {
return &ContactFieldChangedEvent{
baseEvent: newBaseEvent(TypeContactFieldChanged),
Field: field.Reference(),
Value: value,
}
}