-
Notifications
You must be signed in to change notification settings - Fork 146
/
client.go
59 lines (43 loc) · 1.75 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
package corpgroup
import (
"context"
"fmt"
"github.com/ArtisanCloud/PowerLibs/v3/object"
"github.com/ArtisanCloud/PowerWeChat/v3/src/kernel"
"github.com/ArtisanCloud/PowerWeChat/v3/src/work/corpgroup/response"
)
type Client struct {
BaseClient *kernel.BaseClient
}
// 获取应用共享信息
// https://developer.work.weixin.qq.com/document/path/93403
func (comp *Client) GetAppShareInfo(ctx context.Context, agentID int) (*response.ResponseCorpGroupListAPPShareInfo, error) {
result := &response.ResponseCorpGroupListAPPShareInfo{}
params := &object.StringMap{
"agentid": fmt.Sprintf("%d", agentID),
}
_, err := comp.BaseClient.HttpPostJson(ctx, "cgi-bin/corpgroup/corp/list_app_share_info", nil, params, nil, result)
return result, err
}
// 获取下级企业的access_token
// https://developer.work.weixin.qq.com/document/path/93359
func (comp *Client) GetToken(ctx context.Context, corpID string, agentID string) (*response.ResponseCorpGroupGetToken, error) {
result := &response.ResponseCorpGroupGetToken{}
params := &object.HashMap{
"corpid": corpID,
"agentid": agentID,
}
_, err := comp.BaseClient.HttpPostJson(ctx, "cgi-bin/corpgroup/corp/gettoken", params, nil, nil, result)
return result, err
}
// 获取下级企业的小程序session
// https://developer.work.weixin.qq.com/document/path/93355
func (comp *Client) GetMiniProgramTransferSession(ctx context.Context, userID string, sessionKey string) (*response.ResponseCorpGroupTransferSession, error) {
result := &response.ResponseCorpGroupTransferSession{}
params := &object.HashMap{
"userid": userID,
"session_key": sessionKey,
}
_, err := comp.BaseClient.HttpPostJson(ctx, "cgi-bin/corpgroup/miniprogram/transfer_session?", params, nil, nil, result)
return result, err
}