-
Notifications
You must be signed in to change notification settings - Fork 8
/
upgrade.go
136 lines (124 loc) · 5.2 KB
/
upgrade.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
package WeChatCustomerServiceSDK
import (
"encoding/json"
"fmt"
"github.com/NICEXAI/WeChatCustomerServiceSDK/util"
)
const (
//获取配置的专员与客户群
upgradeServiceConfigAddr = "https://qyapi.weixin.qq.com/cgi-bin/kf/customer/get_upgrade_service_config?access_token=%s"
// 为客户升级为专员或客户群服务
upgradeService = "https://qyapi.weixin.qq.com/cgi-bin/kf/customer/upgrade_service?access_token=%s"
//为客户取消推荐
upgradeServiceCancel = "https://qyapi.weixin.qq.com/cgi-bin/kf/customer/cancel_upgrade_service?access_token=%s"
)
// UpgradeServiceConfigSchema 获取配置的专员与客户群
type UpgradeServiceConfigSchema struct {
BaseModel
MemberRange struct {
UserIDList []string `json:"userid_list"` // 专员userid列表
DepartmentIDList []string `json:"department_id_list"` // 专员部门列表
} `json:"member_range"` // 专员服务配置范围
GroupChatRange struct {
ChatIDList []string `json:"chat_id_list"` // 客户群列表
} `json:"groupchat_range"` // 客户群配置范围
}
// UpgradeServiceConfig 获取配置的专员与客户群
func (r *Client) UpgradeServiceConfig() (info UpgradeServiceConfigSchema, err error) {
data, err := util.HttpGet(fmt.Sprintf(upgradeServiceConfigAddr, r.accessToken))
if err != nil {
return info, err
}
_ = json.Unmarshal(data, &info)
if info.ErrCode != 0 {
return info, NewSDKErr(info.ErrCode, info.ErrMsg)
}
return info, nil
}
// UpgradeServiceOptions 为客户升级为专员或客户群服务请求参数
type UpgradeServiceOptions struct {
OpenKFID string `json:"open_kfid"` // 客服帐号ID
ExternalUserID string `json:"external_userid"` // 微信客户的external_userid
Type int `json:"type"` // 表示是升级到专员服务还是客户群服务。1:专员服务。2:客户群服务
Member struct {
UserID string `json:"userid"` // 服务专员的userid
Wording string `json:"wording"` // 推荐语
} `json:"member"` // 推荐的服务专员,type等于1时有效
GroupChat struct {
ChatID string `json:"chat_id"` // 客户群id
Wording string `json:"wording"` // 推荐语
} `json:"groupchat"` // 推荐的客户群,type等于2时有效
}
// UpgradeService 为客户升级为专员或客户群服务
func (r *Client) UpgradeService(options UpgradeServiceOptions) (info BaseModel, err error) {
data, err := util.HttpPost(fmt.Sprintf(upgradeService, r.accessToken), options)
if err != nil {
return info, err
}
_ = json.Unmarshal(data, &info)
if info.ErrCode != 0 {
return info, NewSDKErr(info.ErrCode, info.ErrMsg)
}
return info, nil
}
// UpgradeMemberServiceOptions 为客户升级为专员服务请求参数
type UpgradeMemberServiceOptions struct {
OpenKFID string `json:"open_kfid"` // 客服帐号ID
ExternalUserID string `json:"external_userid"` // 微信客户的external_userid
Type int `json:"type"` // 表示是升级到专员服务还是客户群服务。1:专员服务
Member struct {
UserID string `json:"userid"` // 服务专员的userid
Wording string `json:"wording"` // 推荐语
} `json:"member"` // 推荐的服务专员,type等于1时有效
}
// UpgradeMemberService 为客户升级为专员服务
func (r *Client) UpgradeMemberService(options UpgradeMemberServiceOptions) (info BaseModel, err error) {
data, err := util.HttpPost(fmt.Sprintf(upgradeService, r.accessToken), options)
if err != nil {
return info, err
}
_ = json.Unmarshal(data, &info)
if info.ErrCode != 0 {
return info, NewSDKErr(info.ErrCode, info.ErrMsg)
}
return info, nil
}
// UpgradeServiceGroupChatOptions 为客户升级为客户群服务请求参数
type UpgradeServiceGroupChatOptions struct {
OpenKFID string `json:"open_kfid"` // 客服帐号ID
ExternalUserID string `json:"external_userid"` // 微信客户的external_userid
Type int `json:"type"` // 表示是升级到专员服务还是客户群服务。2:客户群服务
GroupChat struct {
ChatID string `json:"chat_id"` // 客户群id
Wording string `json:"wording"` // 推荐语
} `json:"groupchat"` // 推荐的客户群,type等于2时有效
}
// UpgradeGroupChatService 为客户升级为客户群服务
func (r *Client) UpgradeGroupChatService(options UpgradeServiceGroupChatOptions) (info BaseModel, err error) {
data, err := util.HttpPost(fmt.Sprintf(upgradeService, r.accessToken), options)
if err != nil {
return info, err
}
_ = json.Unmarshal(data, &info)
if info.ErrCode != 0 {
return info, NewSDKErr(info.ErrCode, info.ErrMsg)
}
return info, nil
}
// UpgradeServiceCancelOptions 为客户取消推荐
type UpgradeServiceCancelOptions struct {
OpenKFID string `json:"open_kfid"` // 客服帐号ID
ExternalUserID string `json:"external_userid"` // 微信客户的external_userid
}
// UpgradeServiceCancel 为客户取消推荐
func (r *Client) UpgradeServiceCancel(options UpgradeServiceCancelOptions) (info BaseModel, err error) {
data, err := util.HttpPost(fmt.Sprintf(upgradeServiceCancel, r.accessToken), options)
if err != nil {
return info, err
}
_ = json.Unmarshal(data, &info)
if info.ErrCode != 0 {
return info, NewSDKErr(info.ErrCode, info.ErrMsg)
}
return info, nil
}