-
Notifications
You must be signed in to change notification settings - Fork 165
/
client.go
95 lines (67 loc) · 3.25 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 transfer
import (
"context"
"github.com/ArtisanCloud/PowerLibs/v3/object"
"github.com/ArtisanCloud/PowerWeChat/v3/src/kernel"
"github.com/ArtisanCloud/PowerWeChat/v3/src/work/externalContact/transfer/request"
"github.com/ArtisanCloud/PowerWeChat/v3/src/work/externalContact/transfer/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/92125
func (comp *Client) TransferCustomer(ctx context.Context, options *request.RequestTransferCustomer) (*response.ResponseTransferCustomer, error) {
result := &response.ResponseTransferCustomer{}
_, err := comp.BaseClient.HttpPostJson(ctx, "cgi-bin/externalcontact/transfer_customer", options, nil, nil, result)
return result, err
}
// 查询客户接替状态
// https://developer.work.weixin.qq.com/document/path/94088
func (comp *Client) TransferResult(ctx context.Context, options *request.RequestTransferResult) (*response.ResponseTransferResult, error) {
result := &response.ResponseTransferResult{}
_, err := comp.BaseClient.HttpPostJson(ctx, "cgi-bin/externalcontact/transfer_result", options, nil, nil, result)
return result, err
}
// 获取待分配的离职成员列表
// https://developer.work.weixin.qq.com/document/path/92125
func (comp *Client) GetUnassignedList(ctx context.Context, pageID int, cursor string, pageSize int) (*response.ResponseResignedGetUnassignedList, error) {
result := &response.ResponseResignedGetUnassignedList{}
options := &object.HashMap{
"page_id": pageID,
"cursor": cursor,
"page_size": pageSize,
}
_, err := comp.BaseClient.HttpPostJson(ctx, "cgi-bin/externalcontact/get_unassigned_list", options, nil, nil, result)
return result, err
}
// 分配离职成员的客户
// https://developer.work.weixin.qq.com/document/path/94081
func (comp *Client) ResignedTransferCustomer(ctx context.Context, options *request.RequestResignedTransferCustomer) (*response.ResponseResignedTransferCustomer, error) {
result := &response.ResponseResignedTransferCustomer{}
_, err := comp.BaseClient.HttpPostJson(ctx, "cgi-bin/externalcontact/resigned/transfer_customer", options, nil, nil, result)
return result, err
}
// 查询客户接替状态
// https://developer.work.weixin.qq.com/document/path/94082
func (comp *Client) ResignedTransferResult(ctx context.Context, options *request.RequestResignedTransferResult) (*response.ResponseResignedTransferResult, error) {
result := &response.ResponseResignedTransferResult{}
_, err := comp.BaseClient.HttpPostJson(ctx, "cgi-bin/externalcontact/resigned/transfer_result", options, nil, nil, result)
return result, err
}
// 分配离职成员的客户群
// https://developer.work.weixin.qq.com/document/path/92127
func (comp *Client) GroupChatTransfer(ctx context.Context, options *request.RequestGroupChatTransfer) (*response.ResponseGroupChatTransfer, error) {
result := &response.ResponseGroupChatTransfer{}
_, err := comp.BaseClient.HttpPostJson(ctx, "cgi-bin/externalcontact/groupchat/transfer", options, nil, nil, result)
return result, err
}