-
Notifications
You must be signed in to change notification settings - Fork 19
/
contact_refreshed.go
44 lines (36 loc) · 1.12 KB
/
contact_refreshed.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 (
"encoding/json"
"github.com/nyaruka/goflow/flows"
)
func init() {
registerType(TypeContactRefreshed, func() flows.Event { return &ContactRefreshedEvent{} })
}
// TypeContactRefreshed is the type of our contact refreshed event
const TypeContactRefreshed string = "contact_refreshed"
// ContactRefreshedEvent events are generated when the resume has a contact with differences to the current session contact.
//
// {
// "type": "contact_refreshed",
// "created_on": "2006-01-02T15:04:05Z",
// "contact": {
// "uuid": "0e06f977-cbb7-475f-9d0b-a0c4aaec7f6a",
// "name": "Bob",
// "urns": ["tel:+11231234567"]
// }
// }
//
// @event contact_refreshed
type ContactRefreshedEvent struct {
baseEvent
Contact json.RawMessage `json:"contact"`
}
// NewContactRefreshed creates a new contact changed event
func NewContactRefreshed(contact *flows.Contact) *ContactRefreshedEvent {
marshalled, _ := json.Marshal(contact)
return &ContactRefreshedEvent{
baseEvent: newBaseEvent(TypeContactRefreshed),
Contact: marshalled,
}
}
var _ flows.Event = (*ContactRefreshedEvent)(nil)