-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathevent.go
60 lines (49 loc) · 1.33 KB
/
event.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
48
49
50
51
52
53
54
55
56
57
58
59
60
package pio
import "time"
const (
EventTypeSet = "$set"
EventTypeUnset = "$unset"
EventTypeDelete = "$delete"
)
type Event struct {
Event string `json:"event"`
EntityType string `json:"entityType"`
EntityID string `json:"entityId"`
TargetEntityType string `json:"targetEntityType"`
TargetEntityID string `json:"targetEntityId"`
Properties map[string]interface{} `json:"properties"`
EventTime time.Time `json:"eventTime"`
}
func NewEvent(name string) *Event {
return &Event{
Event: name,
}
}
func (e *Event) SetEvent(name string) *Event {
e.Event = name
return e
}
func (e *Event) SetEntityType(entityType string) *Event {
e.EntityType = entityType
return e
}
func (e *Event) SetEntityID(entityID string) *Event {
e.EntityID = entityID
return e
}
func (e *Event) SetTargetEntityType(targetEntityType string) *Event {
e.TargetEntityType = targetEntityType
return e
}
func (e *Event) SetTargetEntityID(targetEntityID string) *Event {
e.TargetEntityID = targetEntityID
return e
}
func (e *Event) SetProperties(properties map[string]interface{}) *Event {
e.Properties = properties
return e
}
func (e *Event) SetEventTime(eventTime time.Time) *Event {
e.EventTime = eventTime
return e
}