-
Notifications
You must be signed in to change notification settings - Fork 20
/
environment_refreshed.go
47 lines (39 loc) · 1.29 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/goflow/flows"
"github.com/nyaruka/goflow/utils"
)
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",
// "default_language": "eng",
// "allowed_languages": ["eng", "fra"]
// }
// }
//
// @event environment_refreshed
type EnvironmentRefreshedEvent struct {
BaseEvent
Environment json.RawMessage `json:"environment"`
}
// NewEnvironmentRefreshedEvent creates a new environment changed event
func NewEnvironmentRefreshedEvent(env utils.Environment) *EnvironmentRefreshedEvent {
marshalled, _ := json.Marshal(env)
return &EnvironmentRefreshedEvent{
BaseEvent: NewBaseEvent(TypeEnvironmentRefreshed),
Environment: marshalled,
}
}
var _ flows.Event = (*EnvironmentRefreshedEvent)(nil)