1+ package WeChatCustomerServiceSDK
2+
3+ import (
4+ "encoding/json"
5+ "errors"
6+ "fmt"
7+ "github.com/NICEXAI/WeChatCustomerServiceSDK/util"
8+ )
9+
10+ const (
11+ //添加接待人员
12+ receptionistAddAddr = "https://qyapi.weixin.qq.com/cgi-bin/kf/servicer/add?access_token=%s"
13+ //删除接待人员
14+ receptionistDelAddr = "https://qyapi.weixin.qq.com/cgi-bin/kf/servicer/del?access_token=%s"
15+ //获取接待人员列表
16+ receptionistListAddr = "https://qyapi.weixin.qq.com/cgi-bin/kf/servicer/list?access_token=%s&open_kfid=%s"
17+ )
18+
19+ // ReceptionistOptions 添加接待人员请求参数
20+ type ReceptionistOptions struct {
21+ OpenKFID string `json:"open_kfid"` // 客服帐号ID
22+ UserIDList []string `json:"userid_list"` // 接待人员userid列表
23+ }
24+
25+ // ReceptionistSchema 添加接待人员响应内容
26+ type ReceptionistSchema struct {
27+ BaseModel
28+ ResultList []struct {
29+ UserID string
30+ BaseModel
31+ }
32+ }
33+
34+ // ReceptionistAdd 添加接待人员
35+ func (r * Client ) ReceptionistAdd (options ReceptionistOptions ) (info ReceptionistSchema , err error ) {
36+ data , err := util .HttpPost (fmt .Sprintf (receptionistAddAddr , r .accessToken ), options )
37+ if err != nil {
38+ return info , err
39+ }
40+ _ = json .Unmarshal (data , & info )
41+ if info .ErrCode != 0 {
42+ return info , errors .New (info .ErrMsg )
43+ }
44+ return info , nil
45+ }
46+
47+ // ReceptionistDel 删除接待人员
48+ func (r * Client ) ReceptionistDel (options ReceptionistOptions ) (info ReceptionistSchema , err error ) {
49+ data , err := util .HttpPost (fmt .Sprintf (receptionistDelAddr , r .accessToken ), options )
50+ if err != nil {
51+ return info , err
52+ }
53+ _ = json .Unmarshal (data , & info )
54+ if info .ErrCode != 0 {
55+ return info , errors .New (info .ErrMsg )
56+ }
57+ return info , nil
58+ }
59+
60+ // ReceptionistListSchema 获取接待人员列表响应内容
61+ type ReceptionistListSchema struct {
62+ BaseModel
63+ ReceptionistList []struct {
64+ UserID string `json:"userid"` // 接待人员的userid。第三方应用获取到的为密文userid,即open_userid
65+ Status int `json:"status"` // 接待人员的接待状态。0:接待中,1:停止接待。第三方应用需具有“管理帐号、分配会话和收发消息”权限才可获取
66+ } `json:"servicer_list"`
67+ }
68+
69+ // ReceptionistList 获取接待人员列表
70+ func (r * Client ) ReceptionistList (kfID string ) (info ReceptionistListSchema , err error ) {
71+ data , err := util .HttpGet (fmt .Sprintf (receptionistListAddr , r .accessToken , kfID ))
72+ if err != nil {
73+ return info , err
74+ }
75+ _ = json .Unmarshal (data , & info )
76+ if info .ErrCode != 0 {
77+ return info , errors .New (info .ErrMsg )
78+ }
79+ return info , nil
80+ }
0 commit comments