-
Notifications
You must be signed in to change notification settings - Fork 19
/
environment_refreshed.go
47 lines (39 loc) · 1.28 KB
/
environment_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
45
46
47
package events
import (
"encoding/json"
"github.com/nyaruka/gocommon/jsonx"
"github.com/nyaruka/goflow/envs"
"github.com/nyaruka/goflow/flows"
)
func init() {
registerType(TypeEnvironmentRefreshed, func() flows.Event { return &EnvironmentRefreshedEvent{} })
}
// TypeEnvironmentRefreshed is the type of our environment changed event
const TypeEnvironmentRefreshed string = "environment_refreshed"
// EnvironmentRefreshedEvent events are sent by the caller to tell the engine to update the session environment.
//
// {
// "type": "environment_refreshed",
// "created_on": "2006-01-02T15:04:05Z",
// "environment": {
// "date_format": "YYYY-MM-DD",
// "time_format": "hh:mm",
// "timezone": "Africa/Kigali",
// "allowed_languages": ["eng", "fra"]
// }
// }
//
// @event environment_refreshed
type EnvironmentRefreshedEvent struct {
baseEvent
Environment json.RawMessage `json:"environment"`
}
// NewEnvironmentRefreshed creates a new environment changed event
func NewEnvironmentRefreshed(env envs.Environment) *EnvironmentRefreshedEvent {
marshalled, _ := jsonx.Marshal(env)
return &EnvironmentRefreshedEvent{
baseEvent: newBaseEvent(TypeEnvironmentRefreshed),
Environment: marshalled,
}
}
var _ flows.Event = (*EnvironmentRefreshedEvent)(nil)