Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 企业微信-微信客服,客服账号列表接口支持分页拉取,接待人员增加部门ID #798

Open
wants to merge 1 commit into
base: v2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 34 additions & 4 deletions work/kf/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ type AccountAddSchema struct {
}

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

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

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

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

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

// AccountPagingRequest 分页获取客服账号列表请求
type AccountPagingRequest struct {
Offset int `json:"offset"`
Limit int `json:"limit"`
}

// AccountPaging 分页获取客服账号列表
// see https://developer.work.weixin.qq.com/document/path/94661
func (r *Client) AccountPaging(req *AccountPagingRequest) (*AccountListSchema, error) {
var (
accessToken string
err error
)
if accessToken, err = r.ctx.GetAccessToken(); err != nil {
return nil, err
}
var response []byte
if response, err = util.PostJSON(fmt.Sprintf(accountListAddr, accessToken), req); err != nil {
return nil, err
}
result := &AccountListSchema{}
err = util.DecodeWithError(response, result, "AccountPaging")
return result, err
}

// AddContactWayOptions 获取客服账号链接
// 1.若scene非空,返回的客服链接开发者可拼接scene_param=SCENE_PARAM参数使用,用户进入会话事件会将SCENE_PARAM原样返回。其中SCENE_PARAM需要urlencode,且长度不能超过128字节。
// 如 https://work.weixin.qq.com/kf/kfcbf8f8d07ac7215f?enc_scene=ENCGFSDF567DF&scene_param=a%3D1%26b%3D2
Expand All @@ -158,6 +187,7 @@ type AddContactWaySchema struct {
}

// AddContactWay 获取客服账号链接
// see https://developer.work.weixin.qq.com/document/path/94665
func (r *Client) AddContactWay(options AddContactWayOptions) (info AddContactWaySchema, err error) {
var (
accessToken string
Expand Down
13 changes: 8 additions & 5 deletions work/kf/servicer.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,17 @@ const (

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

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

Expand Down
Loading