-
Notifications
You must be signed in to change notification settings - Fork 151
/
client.go
84 lines (61 loc) · 2.06 KB
/
client.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
package schedule
import (
"github.com/ArtisanCloud/PowerLibs/v2/object"
"github.com/ArtisanCloud/PowerWeChat/v2/src/kernel"
"github.com/ArtisanCloud/PowerWeChat/v2/src/kernel/power"
response2 "github.com/ArtisanCloud/PowerWeChat/v2/src/kernel/response"
"github.com/ArtisanCloud/PowerWeChat/v2/src/work/oa/schedule/response"
)
type Client struct {
*kernel.BaseClient
}
func NewClient(app kernel.ApplicationInterface) (*Client, error) {
baseClient, err := kernel.NewBaseClient(&app, nil)
if err != nil {
return nil, err
}
return &Client{
baseClient,
}, nil
}
// 创建日程
// https://developer.work.weixin.qq.com/document/path/93648
func (comp *Client) Add(schedule *power.HashMap, agentID int) (*response.ResponseScheduleAdd, error) {
result := &response.ResponseScheduleAdd{}
options := &object.HashMap{
"schedule": schedule,
"agentid": agentID,
}
_, err := comp.HttpPostJson("cgi-bin/oa/schedule/add", options, nil, nil, result)
return result, err
}
// 更新日程
// https://developer.work.weixin.qq.com/document/path/93648
func (comp *Client) Update(schedule *power.HashMap) (*response2.ResponseWork, error) {
result := &response2.ResponseWork{}
options := &object.HashMap{
"schedule": schedule,
}
_, err := comp.HttpPostJson("cgi-bin/oa/schedule/update", options, nil, nil, result)
return result, err
}
// 获取日程详情
// https://developer.work.weixin.qq.com/document/path/93648
func (comp *Client) Get(scheduleIDList []string) (*response.ResponseScheduleGet, error) {
result := &response.ResponseScheduleGet{}
options := &object.HashMap{
"schedule_id_list": scheduleIDList,
}
_, err := comp.HttpPostJson("cgi-bin/oa/schedule/get", options, nil, nil, result)
return result, err
}
// 删除日程
// https://developer.work.weixin.qq.com/document/path/93648
func (comp *Client) Del(scheduleID string) (*response2.ResponseWork, error) {
result := &response2.ResponseWork{}
options := &object.HashMap{
"schedule_id": scheduleID,
}
_, err := comp.HttpPostJson("cgi-bin/oa/schedule/del", options, nil, nil, result)
return result, err
}