Skip to content

Commit a5776bc

Browse files
committed
feat: 企业微信-微信客服,客服账号列表接口支持分页拉取,接待人员增加部门ID
1 parent 2e07088 commit a5776bc

File tree

2 files changed

+42
-9
lines changed

2 files changed

+42
-9
lines changed

work/kf/account.go

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ type AccountAddSchema struct {
3333
}
3434

3535
// AccountAdd 添加客服账号
36+
// see https://developer.work.weixin.qq.com/document/path/94662
3637
func (r *Client) AccountAdd(options AccountAddOptions) (info AccountAddSchema, err error) {
3738
var (
3839
accessToken string
@@ -59,6 +60,7 @@ type AccountDelOptions struct {
5960
}
6061

6162
// AccountDel 删除客服账号
63+
// see https://developer.work.weixin.qq.com/document/path/94663
6264
func (r *Client) AccountDel(options AccountDelOptions) (info util.CommonError, err error) {
6365
var (
6466
accessToken string
@@ -86,7 +88,8 @@ type AccountUpdateOptions struct {
8688
MediaID string `json:"media_id"` // 客服头像临时素材。可以调用上传临时素材接口获取, 不多于128个字节
8789
}
8890

89-
// AccountUpdate 修复客服账号
91+
// AccountUpdate 修改客服账号
92+
// see https://developer.work.weixin.qq.com/document/path/94664
9093
func (r *Client) AccountUpdate(options AccountUpdateOptions) (info util.CommonError, err error) {
9194
var (
9295
accessToken string
@@ -109,9 +112,10 @@ func (r *Client) AccountUpdate(options AccountUpdateOptions) (info util.CommonEr
109112

110113
// AccountInfoSchema 客服详情
111114
type AccountInfoSchema struct {
112-
OpenKFID string `json:"open_kfid"` // 客服帐号ID
113-
Name string `json:"name"` // 客服帐号名称
114-
Avatar string `json:"avatar"` // 客服头像URL
115+
OpenKFID string `json:"open_kfid"` // 客服帐号ID
116+
Name string `json:"name"` // 客服帐号名称
117+
Avatar string `json:"avatar"` // 客服头像URL
118+
ManagePrivilege bool `json:"manage_privilege"` // 当前调用接口的应用身份,是否有该客服账号的管理权限(编辑客服账号信息、分配会话和收发消息)
115119
}
116120

117121
// AccountListSchema 获取客服账号列表响应内容
@@ -141,6 +145,31 @@ func (r *Client) AccountList() (info AccountListSchema, err error) {
141145
return info, nil
142146
}
143147

148+
// AccountPagingRequest 分页获取客服账号列表请求
149+
type AccountPagingRequest struct {
150+
Offset int `json:"offset"`
151+
Limit int `json:"limit"`
152+
}
153+
154+
// AccountPaging 分页获取客服账号列表
155+
// see https://developer.work.weixin.qq.com/document/path/94661
156+
func (r *Client) AccountPaging(req *AccountPagingRequest) (*AccountListSchema, error) {
157+
var (
158+
accessToken string
159+
err error
160+
)
161+
if accessToken, err = r.ctx.GetAccessToken(); err != nil {
162+
return nil, err
163+
}
164+
var response []byte
165+
if response, err = util.PostJSON(fmt.Sprintf(accountListAddr, accessToken), req); err != nil {
166+
return nil, err
167+
}
168+
result := &AccountListSchema{}
169+
err = util.DecodeWithError(response, result, "AccountPaging")
170+
return result, err
171+
}
172+
144173
// AddContactWayOptions 获取客服账号链接
145174
// 1.若scene非空,返回的客服链接开发者可拼接scene_param=SCENE_PARAM参数使用,用户进入会话事件会将SCENE_PARAM原样返回。其中SCENE_PARAM需要urlencode,且长度不能超过128字节。
146175
// 如 https://work.weixin.qq.com/kf/kfcbf8f8d07ac7215f?enc_scene=ENCGFSDF567DF&scene_param=a%3D1%26b%3D2
@@ -158,6 +187,7 @@ type AddContactWaySchema struct {
158187
}
159188

160189
// AddContactWay 获取客服账号链接
190+
// see https://developer.work.weixin.qq.com/document/path/94665
161191
func (r *Client) AddContactWay(options AddContactWayOptions) (info AddContactWaySchema, err error) {
162192
var (
163193
accessToken string

work/kf/servicer.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,17 @@ const (
1818

1919
// ReceptionistOptions 添加接待人员请求参数
2020
type ReceptionistOptions struct {
21-
OpenKFID string `json:"open_kfid"` // 客服帐号ID
22-
UserIDList []string `json:"userid_list"` // 接待人员userid列表。第三方应用填密文userid,即open_userid 可填充个数:1 ~ 100。超过100个需分批调用。
21+
OpenKFID string `json:"open_kfid"` // 客服帐号ID
22+
UserIDList []string `json:"userid_list"` // 接待人员userid列表。第三方应用填密文userid,即open_userid 可填充个数:1 ~ 100。超过100个需分批调用。
23+
DepartmentIDList []int `json:"department_id_list"` // 接待人员部门id列表 可填充个数:0 ~ 100。超过100个需分批调用。
2324
}
2425

2526
// ReceptionistSchema 添加接待人员响应内容
2627
type ReceptionistSchema struct {
2728
util.CommonError
2829
ResultList []struct {
29-
UserID string `json:"userid"`
30+
UserID string `json:"userid"`
31+
DepartmentID int `json:"department_id"`
3032
util.CommonError
3133
} `json:"result_list"`
3234
}
@@ -79,8 +81,9 @@ func (r *Client) ReceptionistDel(options ReceptionistOptions) (info Receptionist
7981
type ReceptionistListSchema struct {
8082
util.CommonError
8183
ReceptionistList []struct {
82-
UserID string `json:"userid"` // 接待人员的userid。第三方应用获取到的为密文userid,即open_userid
83-
Status int `json:"status"` // 接待人员的接待状态。0:接待中,1:停止接待。第三方应用需具有“管理帐号、分配会话和收发消息”权限才可获取
84+
UserID string `json:"userid"` // 接待人员的userid。第三方应用获取到的为密文userid,即open_userid
85+
Status int `json:"status"` // 接待人员的接待状态。0:接待中,1:停止接待。第三方应用需具有“管理帐号、分配会话和收发消息”权限才可获取
86+
DepartmentID int `json:"department_id"` // 接待人员部门的id
8487
} `json:"servicer_list"`
8588
}
8689

0 commit comments

Comments
 (0)