-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathworkers.go
49 lines (44 loc) · 1.12 KB
/
workers.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
package worker
import (
"fmt"
"github.com/conductor-sdk/conductor-go/sdk/model"
)
func GetUserInfo(task *model.Task) (interface{}, error) {
userId, err := GetValueFromTaskInputData(task, "userId")
if err != nil {
return nil, err
}
userInfo := NewUserInfo("User X", userId)
userInfo.Email = fmt.Sprintf("%[email protected]", userId)
userInfo.PhoneNumber = "555-555-5555"
return userInfo, nil
}
func SendEmail(task *model.Task) (interface{}, error) {
taskResult := model.NewTaskResultFromTask(task)
email, err := GetValueFromTaskInputData(task, "email")
if err != nil {
return nil, err
}
taskResult.Logs = []model.TaskExecLog{
{
Log: "sent email to: " + email,
},
}
taskResult.Status = model.CompletedTask
return taskResult, nil
}
func SendSms(task *model.Task) (interface{}, error) {
taskResult := model.NewTaskResultFromTask(task)
phoneNumber, err := GetValueFromTaskInputData(task, "phoneNumber")
if err != nil {
return nil, err
}
taskResult.Logs = append(
taskResult.Logs,
model.TaskExecLog{
Log: "sent sms to: " + phoneNumber,
},
)
taskResult.Status = model.CompletedTask
return taskResult, nil
}