-
Notifications
You must be signed in to change notification settings - Fork 152
/
client.go
56 lines (43 loc) · 1.5 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
package serviceState
import (
"github.com/ArtisanCloud/PowerLibs/v2/object"
"github.com/ArtisanCloud/PowerWeChat/v2/src/kernel"
response2 "github.com/ArtisanCloud/PowerWeChat/v2/src/kernel/response"
"github.com/ArtisanCloud/PowerWeChat/v2/src/work/accountService/serviceState/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://work.weixin.qq.com/api/doc/90000/90135/94669
func (comp *Client) Get(openKFID string, externalUserID string) (*response.ResponseServiceStateGet, error) {
result := &response.ResponseServiceStateGet{}
options := &object.HashMap{
"open_kfid": openKFID,
"external_userid": externalUserID,
}
_, err := comp.HttpPostJson("cgi-bin/kf/service_state/get", options, nil, nil, result)
return result, err
}
// 变更会话状态
// https://work.weixin.qq.com/api/doc/90000/90135/94669
func (comp *Client) Trans(openKFID string, externalUserID string, serviceState int, servicerUserID string) (*response2.ResponseWork, error) {
result := &response2.ResponseWork{}
options := &object.HashMap{
"open_kfid": openKFID,
"external_userid": externalUserID,
"service_state": serviceState,
"servicer_userid": servicerUserID,
}
_, err := comp.HttpPostJson("cgi-bin/kf/service_state/trans", options, nil, nil, result)
return result, err
}