-
Notifications
You must be signed in to change notification settings - Fork 174
/
client.go
53 lines (40 loc) · 1.33 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
package pstncc
import (
"context"
"github.com/ArtisanCloud/PowerLibs/v3/object"
"github.com/ArtisanCloud/PowerWeChat/v3/src/kernel"
"github.com/ArtisanCloud/PowerWeChat/v3/src/work/oa/pstncc/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/91627
func (comp *Client) Call(ctx context.Context, calleeUserID []string) (*response.ResponsePSTNCCCall, error) {
result := &response.ResponsePSTNCCCall{}
options := &object.HashMap{
"callee_userid": calleeUserID,
}
_, err := comp.BaseClient.HttpPostJson(ctx, "cgi-bin/pstncc/call", options, nil, nil, result)
return result, err
}
// 获取接听状态
// https://developer.work.weixin.qq.com/document/path/91628
func (comp *Client) GetStates(ctx context.Context, calleeUserID string, callID string) (*response.ResponsePSTNCCGetStates, error) {
result := &response.ResponsePSTNCCGetStates{}
options := &object.HashMap{
"callee_userid": calleeUserID,
"callid": callID,
}
_, err := comp.BaseClient.HttpPostJson(ctx, "cgi-bin/pstncc/getstates", options, nil, nil, result)
return result, err
}