-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathtransfer_customer.go
176 lines (160 loc) · 5.84 KB
/
transfer_customer.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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
package wework
import (
"github.com/go-laoji/wecom-go-sdk/v2/internal"
)
type TransferCustomerRequest struct {
HandoverUserId string `json:"handover_userid" validate:"required"`
TakeoverUserId string `json:"takeover_userid" validate:"required"`
ExternalUserId []string `json:"external_userid" validate:"required"`
TransferSuccessMsg string `json:"transfer_success_msg,omitempty" validate:"omitempty,max=200"`
}
type TransferCustomerResponse struct {
internal.BizResponse
Customer []struct {
ExternalUserId string `json:"external_userid"`
ErrCode int `json:"errcode"`
}
}
// TransferCustomer 分配在职成员的客户
// 企业可通过此接口,转接在职成员的客户给其他成员。
// 参考连接 https://open.work.weixin.qq.com/api/doc/90001/90143/94096
func (ww *weWork) TransferCustomer(corpId uint, request TransferCustomerRequest) (resp TransferCustomerResponse) {
if ok := validate.Struct(request); ok != nil {
resp.ErrCode = 500
resp.ErrorMsg = ok.Error()
return
}
_, err := ww.getRequest(corpId).SetBody(request).SetResult(&resp).
Post("/cgi-bin/externalcontact/transfer_customer")
if err != nil {
resp.ErrCode = 500
resp.ErrorMsg = err.Error()
}
return
}
type TransferResultRequest struct {
HandoverUserId string `json:"handover_userid" validate:"required"`
TakeoverUserId string `json:"takeover_userid" validate:"required"`
Cursor string `json:"cursor"`
}
type TransferResultResponse struct {
internal.BizResponse
Customer []struct {
ExternalUserId string `json:"external_userid"`
Status int `json:"status"`
TakeoverTime uint64 `json:"takeover_time"`
} `json:"customer"`
NextCursor string `json:"next_cursor"`
}
// TransferResult 查询客户接替状态
// 企业和第三方可通过此接口查询在职成员的客户转接情况。
// 参考连接 https://open.work.weixin.qq.com/api/doc/90001/90143/94097
func (ww *weWork) TransferResult(corpId uint, request TransferResultRequest) (resp TransferResultResponse) {
if ok := validate.Struct(request); ok != nil {
resp.ErrCode = 500
resp.ErrorMsg = ok.Error()
return
}
_, err := ww.getRequest(corpId).SetBody(request).SetResult(&resp).
Post("/cgi-bin/externalcontact/transfer_result")
if err != nil {
resp.ErrCode = 500
resp.ErrorMsg = err.Error()
}
return
}
type UnAssignedRequest struct {
PageId int `json:"page_id" validate:"required_without=Cursor,omitempty"`
PageSize int `json:"page_size" validate:"max=1000"`
Cursor string `json:"cursor" validate:"required_without=PageId,omitempty"`
}
type UnAssignedInfo struct {
HandoverUserId string `json:"handover_userid"`
ExternalUserId string `json:"external_userid"`
DimissionTime uint64 `json:"dimission_time"`
}
type UnAssignedResponse struct {
internal.BizResponse
Info []UnAssignedInfo `json:"info"`
IsLast bool `json:"is_last"`
NextCursor string `json:"next_cursor"`
}
// GetUnassignedList 获取待分配的离职成员列表
// 参考连接 https://open.work.weixin.qq.com/api/doc/90001/90143/92273
func (ww *weWork) GetUnassignedList(corpId uint, request UnAssignedRequest) (resp UnAssignedResponse) {
if ok := validate.Struct(request); ok != nil {
resp.ErrCode = 500
resp.ErrorMsg = ok.Error()
return
}
_, err := ww.getRequest(corpId).SetBody(request).SetResult(&resp).
Post("/cgi-bin/externalcontact/get_unassigned_list")
if err != nil {
resp.ErrCode = 500
resp.ErrorMsg = err.Error()
}
return
}
// TransferCustomerResigned 分配离职成员的客户;不可设置 TransferSuccessMsg
// handover_userid必须是已离职用户
// external_userid必须是handover_userid的客户
// 参考连接 https://open.work.weixin.qq.com/api/doc/90001/90143/94100
func (ww *weWork) TransferCustomerResigned(corpId uint, request TransferCustomerRequest) (resp TransferCustomerResponse) {
if ok := validate.Struct(request); ok != nil {
resp.ErrCode = 500
resp.ErrorMsg = ok.Error()
return
}
_, err := ww.getRequest(corpId).SetBody(request).SetResult(&resp).
Post("/cgi-bin/externalcontact/resigned/transfer_customer")
if err != nil {
resp.ErrCode = 500
resp.ErrorMsg = err.Error()
}
return
}
// TransferResultResigned 查询客户接替状态
// 参考连接 https://open.work.weixin.qq.com/api/doc/90001/90143/94101
func (ww *weWork) TransferResultResigned(corpId uint, request TransferResultRequest) (resp TransferResultResponse) {
if ok := validate.Struct(request); ok != nil {
resp.ErrCode = 500
resp.ErrorMsg = ok.Error()
return
}
_, err := ww.getRequest(corpId).SetBody(request).SetResult(&resp).
Post("/cgi-bin/externalcontact/resigned/transfer_result")
if err != nil {
resp.ErrCode = 500
resp.ErrorMsg = err.Error()
}
return
}
type GroupChatTransferRequest struct {
ChatIdList []string `json:"chat_id_list"`
NewOwner string `json:"new_owner"`
}
type GroupChatTransferResponse struct {
internal.BizResponse
FailedChatList []struct {
ChatId string `json:"chat_id"`
ErrCode int `json:"errcode"`
ErrMsg string `json:"errmsg"`
} `json:"failed_chat_list"`
}
// TransferGroupChat 分配离职成员的客户群
// 可通过此接口,将已离职成员为群主的群,分配给另一个客服成员
// 群主离职了的客户群,才可继承
// 继承给的新群主,必须是配置了客户联系功能的成员
// 继承给的新群主,必须有设置实名
// 继承给的新群主,必须有激活企业微信
// 同一个人的群,限制每天最多分配300个给新群主
// 参考连接 https://open.work.weixin.qq.com/api/doc/90001/90143/93242
func (ww *weWork) TransferGroupChat(corpId uint, request GroupChatTransferRequest) (resp GroupChatTransferResponse) {
_, err := ww.getRequest(corpId).SetBody(request).SetResult(&resp).
Post("/cgi-bin/externalcontact/groupchat/transfer")
if err != nil {
resp.ErrCode = 500
resp.ErrorMsg = err.Error()
}
return
}