-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnotification_test.go
92 lines (76 loc) · 1.62 KB
/
notification_test.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
package dingtalk
import (
"testing"
)
func TestSendWorkerNotification(t *testing.T) {
client, err := NewDingtalkClientWithEnv()
if err != nil {
t.Error(err)
}
msg := TextMessage{
Msgtype: "text",
Text: Text{
Content: "测试",
},
}
params := &SendWorkerNotificationParams{
UseridList: "",
AgentID: "",
MSG: msg,
}
data, _, err := client.SendWorkerNotification(params)
if err != nil {
t.Error(err)
}
t.Log(data)
}
func TestGetWorkerNotificationResult(t *testing.T) {
client, err := NewDingtalkClientWithEnv()
if err != nil {
t.Error(err)
}
params := &GetWorkerNotificationResultParams{
TaskID: 0,
AgentID: 0,
}
data, _, err := client.GetWorkerNotificationResult(params)
if err != nil {
t.Error(err)
}
t.Log(data)
}
type ActionCard struct {
Msgtype string `json:"msgtype"`
ActionCard ActionCardDetail `json:"action_card"`
}
type ActionCardDetail struct {
Title string `json:"title"`
Markdown string `json:"markdown"`
SingleTitle string `json:"single_title"`
SingleUrl string `json:"single_url"`
}
func TestSendActionCardWorkerNotification(t *testing.T) {
client, err := NewDingtalkClientWithParams("", "")
if err != nil {
t.Error(err)
}
message := ActionCard{
Msgtype: "action_card",
ActionCard: ActionCardDetail{
Title: "",
Markdown: "Markdown",
SingleTitle: "点击进入工单系统",
SingleUrl: "",
},
}
params := &SendWorkerNotificationParams{
UseridList: "",
AgentID: "",
MSG: message,
}
data, _, err := client.SendWorkerNotification(params)
if err != nil {
t.Error(err)
}
t.Log(data)
}