-
Notifications
You must be signed in to change notification settings - Fork 174
/
client.go
95 lines (68 loc) · 2.76 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
85
86
87
88
89
90
91
92
93
94
95
package linkedCorp
import (
"context"
"github.com/ArtisanCloud/PowerLibs/v3/object"
"github.com/ArtisanCloud/PowerWeChat/v3/src/kernel"
"github.com/ArtisanCloud/PowerWeChat/v3/src/work/user/response"
)
type Client struct {
BaseClient *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/93172
func (comp *Client) GetPermList(ctx context.Context) (*response.ResponseLinkCorpGetPermList, error) {
result := &response.ResponseLinkCorpGetPermList{}
_, err := comp.BaseClient.HttpPostJson(ctx, "cgi-bin/linkedcorp/agent/get_perm_list", nil, nil, nil, result)
return result, err
}
// 获取互联企业成员详细信息
// https://developer.work.weixin.qq.com/document/path/93171
func (comp *Client) GetUser(ctx context.Context, userID string) (*response.ResponseLinkCorpGetUser, error) {
result := &response.ResponseLinkCorpGetUser{}
options := &object.HashMap{
"userid": userID,
}
_, err := comp.BaseClient.HttpPostJson(ctx, "cgi-bin/linkedcorp/user/get", options, nil, nil, result)
return result, err
}
// 获取互联企业部门成员
// https://developer.work.weixin.qq.com/document/path/93168
func (comp *Client) GetUserSimpleList(ctx context.Context, departmentID string, fetchChild bool) (*response.ResponseLinkCorpGetUserSimpleList, error) {
result := &response.ResponseLinkCorpGetUserSimpleList{}
options := &object.HashMap{
"department_id": departmentID,
"fetch_child": fetchChild,
}
_, err := comp.BaseClient.HttpPostJson(ctx, "cgi-bin/linkedcorp/user/simplelist", options, nil, nil, result)
return result, err
}
// 获取互联企业部门成员详情
// https://developer.work.weixin.qq.com/document/path/93169
func (comp *Client) GetUserList(ctx context.Context, departmentID string, fetchChild bool) (*response.ResponseLinkCorpGetUserList, error) {
result := &response.ResponseLinkCorpGetUserList{}
options := &object.HashMap{
"department_id": departmentID,
"fetch_child": fetchChild,
}
_, err := comp.BaseClient.HttpPostJson(ctx, "cgi-bin/linkedcorp/user/list?", options, nil, nil, result)
return result, err
}
// 获取互联企业部门列表
// https://developer.work.weixin.qq.com/document/path/93170
func (comp *Client) GetDepartmentList(ctx context.Context, departmentID string) (*response.ResponseLinkCorpGetDepartmentList, error) {
result := &response.ResponseLinkCorpGetDepartmentList{}
options := &object.HashMap{
"department_id": departmentID,
}
_, err := comp.BaseClient.HttpPostJson(ctx, "cgi-bin/linkedcorp/department/list?", options, nil, nil, result)
return result, err
}