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:微信客服支持获取视频号绑定状态 #493

Merged
merged 2 commits into from
Sep 30, 2021
Merged
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
49 changes: 49 additions & 0 deletions work/kf/other.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package kf

import (
"encoding/json"
"fmt"

"github.com/silenceper/wechat/v2/util"
)

const (
//获取视频号绑定状态
corpQualification = "https://qyapi.weixin.qq.com/cgi-bin/kf/get_corp_qualification?access_token=%s"
)

// CorpQualificationSchema 获取视频号绑定状态响应内容
type CorpQualificationSchema struct {
util.CommonError
WechatChannelsBinding bool `json:"wechat_channels_binding"` // 当企业具有绑定成功的视频号时,返回true,否则返回false。 1. 企业申请绑定视频号且由视频号管理员确认后,才为绑定成功状态 2. 至少有一个绑定成功的视频号就会返回true
}

// GetCorpQualification 获取视频号绑定状态
// 微信客服可接待的客户数,和企业是否已完成主体验证、是否绑定视频号相关。
//
// 企业未完成主体验证时,微信客服仅可累计接待100位客户
// 企业已验证但未绑定视频号时,微信客服仅可累计接待10000位客户
// 企业已验证且已绑定视频号时,微信客服可接待的客户数不受限制
//
// 开发者可获取状态后,在应用等地方提示企业去完成主体验证或绑定视频号。
func (r *Client) GetCorpQualification() (info CorpQualificationSchema, err error) {
var (
accessToken string
data []byte
)
accessToken, err = r.ctx.GetAccessToken()
if err != nil {
return
}
data, err = util.HTTPGet(fmt.Sprintf(corpQualification, accessToken))
if err != nil {
return info, err
}
if err = json.Unmarshal(data, &info); err != nil {
return
}
if info.ErrCode != 0 {
return info, NewSDKErr(info.ErrCode, info.ErrMsg)
}
return info, nil
}