-
Notifications
You must be signed in to change notification settings - Fork 79
/
job_item.go
35 lines (28 loc) · 894 Bytes
/
job_item.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
package intercom
// A JobItem is an item to be processed as part of a bulk Job
type JobItem struct {
Method string `json:"method"`
DataType string `json:"data_type"`
Data interface{} `json:"data"`
}
// NewUserJobItem creates a JobItem that holds an User.
// It can take either a JOB_POST (for updates) or JOB_DELETE (for deletes) method.
func NewUserJobItem(user *User, method JobItemMethod) *JobItem {
return &JobItem{Method: method.String(), DataType: "user", Data: user}
}
// NewEventJobItem creates a JobItem that holds an Event.
func NewEventJobItem(event *Event) *JobItem {
return &JobItem{Method: JOB_POST.String(), DataType: "event", Data: event}
}
type JobItemMethod int
const (
JOB_POST JobItemMethod = iota
JOB_DELETE
)
var jobItemMethods = [...]string{
"post",
"delete",
}
func (state JobItemMethod) String() string {
return jobItemMethods[state]
}