-
Notifications
You must be signed in to change notification settings - Fork 37
/
api_todo.go
73 lines (62 loc) · 2.79 KB
/
api_todo.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
/*
* Copyright 2020 zhaoyunxing.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package dingtalk
import (
"fmt"
"net/http"
"net/url"
"github.com/zhaoyunxing92/dingtalk/v2/constant"
"github.com/zhaoyunxing92/dingtalk/v2/request"
"github.com/zhaoyunxing92/dingtalk/v2/response"
)
// CreateTodo 新增钉钉待办任务
func (ding *DingTalk) CreateTodo(res *request.CreateTodo) (req response.CreateTodo, err error) {
query := url.Values{}
query.Set("operatorId", res.CreatorId)
return req, ding.Request(http.MethodPost, fmt.Sprintf(constant.CreateTodoKey, res.CreatorId), nil, res, &req)
}
// GetTodoDetail 获取钉钉待办任务详情
func (ding *DingTalk) GetTodoDetail(unionId, taskId string) (req response.GetTodoDetail, err error) {
return req, ding.Request(http.MethodPost, fmt.Sprintf(constant.GetTodoDetailKey, unionId, taskId), nil,
nil, &req)
}
// DeleteTodo 删除钉钉待办任务
func (ding *DingTalk) DeleteTodo(unionId, taskId string) (req response.DeleteTodo, err error) {
query := url.Values{}
query.Set("operatorId", unionId)
return req, ding.Request(http.MethodDelete, fmt.Sprintf(constant.DeleteTodoKey, unionId, taskId), query,
nil, &req)
}
// UpdateTodo 更新钉钉待办任务
func (ding *DingTalk) UpdateTodo(res *request.UpdateTodo) (req response.UpdateTodo, err error) {
return req, ding.Request(http.MethodPut, fmt.Sprintf(constant.UpdateTodoKey, res.UnionId, res.TaskId),
nil, res, &req)
}
// UpdateTodoDone 更新钉钉待办执行者状态
func (ding *DingTalk) UpdateTodoDone(res *request.UpdateTodoDone) (req response.UpdateTodo, err error) {
return req, ding.Request(http.MethodPut, fmt.Sprintf(constant.UpdateTodoDoneKey, res.UnionId, res.TaskId),
nil, res, &req)
}
// GetTodoListBySourceId 根据sourceId获取钉钉待办任务详情
func (ding *DingTalk) GetTodoListBySourceId(unionId, sourceId string) (req response.GetTodoDetail, err error) {
return req, ding.Request(http.MethodGet, fmt.Sprintf(constant.GetTodoListBySourceIdKey, unionId, sourceId),
nil, nil, &req)
}
// GetTodoList 查询企业下用户待办列表
func (ding *DingTalk) GetTodoList(unionId, token string, done bool) (req response.GetTodoList, err error) {
return req, ding.Request(http.MethodPost, fmt.Sprintf(constant.GetTodoListKey, unionId), nil,
request.NewGetTodoList(token, done), &req)
}