-
Notifications
You must be signed in to change notification settings - Fork 152
/
client.go
150 lines (110 loc) · 4.66 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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
package externalContact
import (
"github.com/ArtisanCloud/PowerLibs/v2/object"
"github.com/ArtisanCloud/PowerSocialite/v2/src/response/weCom"
"github.com/ArtisanCloud/PowerWeChat/v2/src/kernel"
response2 "github.com/ArtisanCloud/PowerWeChat/v2/src/kernel/response"
response3 "github.com/ArtisanCloud/PowerWeChat/v2/src/work/externalContact/groupChat/response"
"github.com/ArtisanCloud/PowerWeChat/v2/src/work/externalContact/request"
"github.com/ArtisanCloud/PowerWeChat/v2/src/work/externalContact/response"
"strconv"
)
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/92571
func (comp *Client) GetFollowUsers() (*response.ResponseGetFollowUserList, error) {
result := &response.ResponseGetFollowUserList{}
_, err := comp.HttpGet("cgi-bin/externalcontact/get_follow_user_list", nil, nil, result)
return result, err
}
// 获取外部联系人列表.
// https://work.weixin.qq.com/api/doc/90000/90135/92113
func (comp *Client) List(userID string) (*response.ResponseGetList, error) {
result := &response.ResponseGetList{}
_, err := comp.HttpGet("cgi-bin/externalcontact/list", &object.StringMap{
"userid": userID,
}, nil, result)
return result, err
}
// 获取外部联系人详情.
// https://work.weixin.qq.com/api/doc/90000/90135/92114
func (comp *Client) Get(externalUserID string, cursor string) (*weCom.ResponseGetExternalContact, error) {
result := &weCom.ResponseGetExternalContact{}
_, err := comp.HttpGet("cgi-bin/externalcontact/get", &object.StringMap{
"external_userid": externalUserID,
"cursor": cursor,
}, nil, result)
return result, err
}
// 批量获取客户详情.
// https://open.work.weixin.qq.com/api/doc/90000/90135/92994
func (comp *Client) BatchGet(userID []string, cursor string, limit int) (*response.ResponseBatchGetByUser, error) {
result := &response.ResponseBatchGetByUser{}
options := &object.HashMap{
"userid_list": userID,
"cursor": cursor,
"limit": limit,
}
_, err := comp.HttpPostJson("cgi-bin/externalcontact/batch/get_by_user", options, nil, nil, result)
return result, err
}
// 修改客户备注信息.
// https://work.weixin.qq.com/api/doc/90000/90135/92115
func (comp *Client) Remark(data *request.RequestExternalContactRemark) (*response2.ResponseWork, error) {
result := &response2.ResponseWork{}
_, err := comp.HttpPostJson("cgi-bin/externalcontact/remark", data, nil, nil, result)
return result, err
}
// 获取离职成员的客户列表.
// https://work.weixin.qq.com/api/doc#90000/90135/91563
func (comp *Client) GetUnassigned(pageID int, pageSize int) (*response.ResponseGetUnassignedList, error) {
result := &response.ResponseGetUnassignedList{}
_, err := comp.HttpPostJson("cgi-bin/externalcontact/get_unassigned_list", &object.HashMap{
"page_id": strconv.Itoa(pageID),
"page_size": strconv.Itoa(pageSize),
}, nil, nil, result)
return result, err
}
// 离职成员的外部联系人再分配.
// https://developer.work.weixin.qq.com/document/path/94081
func (comp *Client) Transfer(externalUserID []string, handoverUserID string, takeoverUserID string) (*response.ResponseGetTransferedCustomerList, error) {
result := &response.ResponseGetTransferedCustomerList{}
_, err := comp.HttpPostJson("cgi-bin/externalcontact/transfer_customer", &object.HashMap{
"handover_userid": handoverUserID,
"takeover_userid": takeoverUserID,
"external_userid": externalUserID,
}, nil, nil, result)
return result, err
}
// 离职成员的群再分配.
// https://work.weixin.qq.com/api/doc/90000/90135/92127
func (comp *Client) TransferGroupChat(chatIDs []string, newOwner string) (*response3.ResponseGroupChatTransfer, error) {
result := &response3.ResponseGroupChatTransfer{}
_, err := comp.HttpPostJson("cgi-bin/externalcontact/groupchat/transfer", &object.HashMap{
"chat_id_list": chatIDs,
"new_owner": newOwner,
}, nil, nil, result)
return result, err
}
// 查询客户接替结果.
// https://work.weixin.qq.com/api/doc/90000/90135/94082
func (comp *Client) GetResignedTransferResult(handoverUserID string, takeoverUserID string, cursor string) (*response.ResponseGetTransferedCustomerList, error) {
result := &response.ResponseGetTransferedCustomerList{}
_, err := comp.HttpPostJson("cgi-bin/externalcontact/resigned/transfer_result?", &object.StringMap{
"handover_userid": handoverUserID,
"takeover_userid": takeoverUserID,
"cursor": cursor,
}, nil, nil, result)
return result, err
}