-
Notifications
You must be signed in to change notification settings - Fork 164
/
client.go
55 lines (40 loc) · 1.36 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
package agent
import (
"fmt"
"github.com/ArtisanCloud/PowerLibs/v2/object"
"github.com/ArtisanCloud/PowerWeChat/v2/src/kernel"
"github.com/ArtisanCloud/PowerWeChat/v2/src/work/agent/request"
"github.com/ArtisanCloud/PowerWeChat/v2/src/work/agent/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/90227
func (comp *Client) Get(agentID int) (*response.ResponseAgentGet, error) {
result := &response.ResponseAgentGet{}
_, err := comp.HttpPostJson("cgi-bin/agent/get", nil, &object.StringMap{
"agentid": fmt.Sprintf("%d", agentID),
}, nil, result)
return result, err
}
// https://developer.work.weixin.qq.com/document/path/90228
func (comp *Client) Set(data *request.RequestAgentSet) (*response.ResponseAgentSet, error) {
result := &response.ResponseAgentSet{}
_, err := comp.HttpPostJson("cgi-bin/agent/set", data, nil, nil, result)
return result, err
}
// https://developer.work.weixin.qq.com/document/path/90227
func (comp *Client) List() (*response.ResponseAgentList, error) {
result := &response.ResponseAgentList{}
_, err := comp.HttpGet("cgi-bin/agent/list", nil, nil, result)
return result, err
}