-
Notifications
You must be signed in to change notification settings - Fork 19
/
resthook_called.go
46 lines (39 loc) · 1.18 KB
/
resthook_called.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
package events
import (
"encoding/json"
"github.com/nyaruka/goflow/flows"
)
func init() {
RegisterType(TypeResthookCalled, func() flows.Event { return &ResthookCalledEvent{} })
}
// TypeResthookCalled is the type for our resthook events
const TypeResthookCalled string = "resthook_called"
// ResthookCalledEvent events are created when a resthook is called. The event contains
// the payload that will be sent to any subscribers of that resthook. Note that this event is
// created regardless of whether there any subscriberes for that resthook.
//
// {
// "type": "resthook_called",
// "created_on": "2006-01-02T15:04:05Z",
// "resthook": "success",
// "payload": {
// "contact:":{
// "name":"Bob"
// }
// }
// }
//
// @event resthook_called
type ResthookCalledEvent struct {
BaseEvent
Resthook string `json:"resthook"`
Payload json.RawMessage `json:"payload"`
}
// NewResthookCalledEvent returns a new webhook called event
func NewResthookCalledEvent(resthook string, payload json.RawMessage) *ResthookCalledEvent {
return &ResthookCalledEvent{
BaseEvent: NewBaseEvent(TypeResthookCalled),
Resthook: resthook,
Payload: payload,
}
}