-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
89 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
package WeChatCustomerServiceSDK | ||
|
||
import ( | ||
"encoding/json" | ||
"errors" | ||
"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, errors.New(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, errors.New(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, errors.New(info.ErrMsg) | ||
} | ||
return info, nil | ||
} |