forked from star-table/dingtalk-sdk-golang
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi_backlog_caller.go
173 lines (154 loc) · 4.71 KB
/
api_backlog_caller.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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
package sdk
import (
"fmt"
"github.com/polaris-team/dingtalk-sdk-golang/encrypt"
"github.com/polaris-team/dingtalk-sdk-golang/http"
"github.com/polaris-team/dingtalk-sdk-golang/json"
)
//Desc: 创建或更新待办模板
//Doc: https://open-doc.dingtalk.com/microapp/serverapi3/hhaed5
func (client *DingTalkClient) CreateOrUpdateBackLog(req SaveProcessRequest) (*CreateOrUpdateBackLogResp, error) {
req.AgentId = client.AgentId
body, err := json.ToJson(req)
if err != nil {
return nil, err
}
params := map[string]string{
"access_token": client.AccessToken,
"saveProcessRequest": encrypt.URLEncode(body),
}
respBody, err := http.Post("https://oapi.dingtalk.com/topapi/process/save", params, "")
if err != nil {
return nil, err
}
resp := &CreateOrUpdateBackLogResp{}
json.FromJson(respBody, resp)
return resp, err
}
//Desc: 删除待办模板
//Doc: https://open-doc.dingtalk.com/microapp/serverapi3/dvr6o6
func (client *DingTalkClient) DeleteBackLog(req DeleteBackLogReq) (*BaseResp, error) {
req.AgentId = client.AgentId
body, err := json.ToJson(req)
if err != nil {
return nil, err
}
params := map[string]string{
"access_token": client.AccessToken,
"request": encrypt.URLEncode(body),
}
respBody, err := http.Post("https://oapi.dingtalk.com/topapi/process/delete", params, "")
if err != nil {
return nil, err
}
resp := &BaseResp{}
json.FromJson(respBody, resp)
return resp, err
}
//Desc: 创建待办实例
//Doc: https://open-doc.dingtalk.com/microapp/serverapi3/gk2b3e
func (client *DingTalkClient) CreateWorkRecord(req CreateWorkRecordRequest, title *string) (*CreateWorkRecordResp, error) {
req.AgentId = client.AgentId
reqJson, err := json.ToJson(req)
if err != nil {
return nil, err
}
params := map[string]string{
"access_token": client.AccessToken,
"request": encrypt.URLEncode(reqJson),
}
if title != nil {
params["title"] = *title
}
respBody, err := http.Post("https://oapi.dingtalk.com/topapi/process/workrecord/create", params, "")
if err != nil {
return nil, err
}
resp := &CreateWorkRecordResp{}
json.FromJson(respBody, resp)
return resp, err
}
//Desc: 更新实例状态
//Doc: https://open-doc.dingtalk.com/microapp/serverapi3/vo0gqo
func (client *DingTalkClient) UpdateWorkRecord(req UpdateWorkRecordRequest) (*BaseResp, error) {
req.AgentId = client.AgentId
reqJson, err := json.ToJson(req)
if err != nil {
return nil, err
}
params := map[string]string{
"access_token": client.AccessToken,
"request": encrypt.URLEncode(reqJson),
}
respBody, err := http.Post("https://oapi.dingtalk.com/topapi/process/workrecord/update", params, "")
if err != nil {
return nil, err
}
resp := &BaseResp{}
json.FromJson(respBody, resp)
return resp, err
}
//Desc: 创建待办任务
//Doc: https://open-doc.dingtalk.com/microapp/serverapi3/ulgaro
func (client *DingTalkClient) CreateWorkRecordTask(req CreateWorkRecordTaskRequest) (*CreateWorkRecordTaskResp, error) {
req.AgentId = client.AgentId
reqJson, err := json.ToJson(req)
if err != nil {
return nil, err
}
params := map[string]string{
"access_token": client.AccessToken,
"request": encrypt.URLEncode(reqJson),
}
respBody, err := http.Post("https://oapi.dingtalk.com/topapi/process/workrecord/task/create", params, "")
if err != nil {
return nil, err
}
resp := &CreateWorkRecordTaskResp{}
json.FromJson(respBody, resp)
return resp, err
}
//Desc: 更新任务状态
//Doc: https://open-doc.dingtalk.com/microapp/serverapi3/sbl5ms
func (client *DingTalkClient) UpdateWorkRecordTask(req UpdateWorkRecordTaskRequest) (*CreateWorkRecordTaskResp, error) {
req.AgentId = client.AgentId
reqJson, err := json.ToJson(req)
fmt.Println(reqJson)
if err != nil {
return nil, err
}
params := map[string]string{
"access_token": client.AccessToken,
"request": encrypt.URLEncode(reqJson),
}
respBody, err := http.Post("https://oapi.dingtalk.com/topapi/process/workrecord/task/update", params, "")
fmt.Println(respBody)
if err != nil {
return nil, err
}
resp := &CreateWorkRecordTaskResp{}
json.FromJson(respBody, resp)
return resp, err
}
//Desc: 批量取消任务
//Doc: https://open-doc.dingtalk.com/microapp/serverapi3/cqukim
func (client *DingTalkClient) CancelTaskGroup(req CancelTaskGroupRequest) (*BaseResp, error) {
req.AgentId = client.AgentId
reqJson, err := json.ToJson(req)
fmt.Println(reqJson)
if err != nil {
return nil, err
}
params := map[string]string{
"access_token": client.AccessToken,
"request": encrypt.URLEncode(reqJson),
}
respBody, err := http.Post("https://oapi.dingtalk.com/topapi/process/workrecord/taskgroup/cancel", params, "")
fmt.Println(respBody)
if err != nil {
return nil, err
}
resp := &BaseResp{}
json.FromJson(respBody, resp)
return resp, err
}