Skip to content

Commit e3a7cec

Browse files
committed
feat:支持【升级服务】配置
1 parent aca6b7d commit e3a7cec

File tree

1 file changed

+89
-0
lines changed

1 file changed

+89
-0
lines changed

upgrade.go

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
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+
upgradeServiceConfigAddr = " https://qyapi.weixin.qq.com/cgi-bin/kf/customer/get_upgrade_service_config?access_token=%s"
13+
// 为客户升级为专员或客户群服务
14+
upgradeService = "https://qyapi.weixin.qq.com/cgi-bin/kf/customer/upgrade_service?access_token=%s"
15+
//为客户取消推荐
16+
upgradeServiceCancel = "https://qyapi.weixin.qq.com/cgi-bin/kf/customer/cancel_upgrade_service?access_token=%s"
17+
)
18+
19+
// UpgradeServiceConfigSchema 获取配置的专员与客户群
20+
type UpgradeServiceConfigSchema struct {
21+
BaseModel
22+
MemberRange struct{
23+
UserIDList []string `json:"userid_list"` // 专员userid列表
24+
DepartmentIDList []string `json:"department_id_list"` // 专员部门列表
25+
} `json:"member_range"` // 专员服务配置范围
26+
GroupChatRange struct{
27+
ChatIDList []string `json:"chat_id_list"` // 客户群列表
28+
} `json:"groupchat_range"` // 客户群配置范围
29+
}
30+
31+
// UpgradeServiceConfig 获取配置的专员与客户群
32+
func (r *Client) UpgradeServiceConfig() (info UpgradeServiceConfigSchema, err error) {
33+
data, err := util.HttpGet(fmt.Sprintf(upgradeServiceConfigAddr, r.accessToken))
34+
if err != nil {
35+
return info, err
36+
}
37+
_ = json.Unmarshal(data, &info)
38+
if info.ErrCode != 0 {
39+
return info, errors.New(info.ErrMsg)
40+
}
41+
return info, nil
42+
}
43+
44+
// UpgradeServiceOptions 为客户升级为专员或客户群服务请求参数
45+
type UpgradeServiceOptions struct {
46+
OpenKFID string `json:"open_kfid"` // 客服帐号ID
47+
ExternalUserID string `json:"external_userid"` // 微信客户的external_userid
48+
Type int `json:"type"` // 表示是升级到专员服务还是客户群服务。1:专员服务。2:客户群服务
49+
Member struct{
50+
UserID string `json:"userid"` // 服务专员的userid
51+
Wording string `json:"wording"` // 推荐语
52+
} `json:"member"` // 推荐的服务专员,type等于1时有效
53+
GroupChat struct{
54+
ChatID string `json:"chat_id"` // 客户群id
55+
Wording string `json:"wording"` // 推荐语
56+
} `json:"groupchat"` // 推荐的客户群,type等于2时有效
57+
}
58+
59+
// UpgradeService 为客户升级为专员或客户群服务
60+
func (r *Client) UpgradeService(options UpgradeServiceOptions) (info BaseModel, err error) {
61+
data, err := util.HttpPost(fmt.Sprintf(upgradeService, r.accessToken), options)
62+
if err != nil {
63+
return info, err
64+
}
65+
_ = json.Unmarshal(data, &info)
66+
if info.ErrCode != 0 {
67+
return info, errors.New(info.ErrMsg)
68+
}
69+
return info, nil
70+
}
71+
72+
// UpgradeServiceCancelOptions 为客户取消推荐
73+
type UpgradeServiceCancelOptions struct {
74+
OpenKFID string `json:"open_kfid"` // 客服帐号ID
75+
ExternalUserID string `json:"external_userid"` // 微信客户的external_userid
76+
}
77+
78+
// UpgradeServiceCancel 为客户取消推荐
79+
func (r *Client) UpgradeServiceCancel(options UpgradeServiceCancelOptions) (info BaseModel, err error) {
80+
data, err := util.HttpPost(fmt.Sprintf(upgradeServiceCancel, r.accessToken), options)
81+
if err != nil {
82+
return info, err
83+
}
84+
_ = json.Unmarshal(data, &info)
85+
if info.ErrCode != 0 {
86+
return info, errors.New(info.ErrMsg)
87+
}
88+
return info, nil
89+
}

0 commit comments

Comments
 (0)