示例#1
0
文件: sesson.go 项目: Wang/wechat
// 获取客服的会话列表
//  开发者可以通过本接口获取某个客服正在接待的会话列表。
func GetSessionList(clt *mp.Client, kfAccount string) (list []Session, err error) {
	var result struct {
		mp.Error
		SessionList []Session `json:"sessionlist"`
	}

	// TODO
	//	incompleteURL := "https://api.weixin.qq.com/customservice/kfsession/getsessionlist?kf_account=" +
	//		url.QueryEscape(kfAccount) + "&access_token="
	incompleteURL := "https://api.weixin.qq.com/customservice/kfsession/getsessionlist?kf_account=" +
		kfAccount + "&access_token="
	if err = clt.GetJSON(incompleteURL, &result); err != nil {
		return
	}

	if result.ErrCode != mp.ErrCodeOK {
		err = &result.Error
		return
	}
	for i, l := 0, result.SessionList; i < len(l); i++ {
		l[i].KfAccount = kfAccount
	}
	list = result.SessionList
	return
}
示例#2
0
文件: kf_list.go 项目: Wang/wechat
// 获取在线客服接待信息.
func OnlineKfList(clt *mp.Client) (kfList []OnlineKfInfo, err error) {
	var result struct {
		mp.Error
		OnlineKfInfoList []OnlineKfInfo `json:"kf_online_list"`
	}

	incompleteURL := "https://api.weixin.qq.com/cgi-bin/customservice/getonlinekflist?access_token="
	if err = clt.GetJSON(incompleteURL, &result); err != nil {
		return
	}

	if result.ErrCode != mp.ErrCodeOK {
		err = &result.Error
		return
	}
	kfList = result.OnlineKfInfoList
	return
}
示例#3
0
文件: color.go 项目: Wang/wechat
// 获取卡券最新的颜色列表.
func GetColors(clt *mp.Client) (colors []Color, err error) {
	var result struct {
		mp.Error
		Colors []Color `json:"colors"`
	}

	incompleteURL := "https://api.weixin.qq.com/card/getcolors?access_token="
	if err = clt.GetJSON(incompleteURL, &result); err != nil {
		return
	}

	if result.ErrCode != mp.ErrCodeOK {
		err = &result.Error
		return
	}
	colors = result.Colors
	return
}
示例#4
0
文件: account.go 项目: Wang/wechat
// 删除客服账号
func DeleteKfAccount(clt *mp.Client, kfAccount string) (err error) {
	var result mp.Error

	// TODO
	//	incompleteURL := "https://api.weixin.qq.com/customservice/kfaccount/del?kf_account=" +
	//		url.QueryEscape(kfAccount) + "&access_token="
	incompleteURL := "https://api.weixin.qq.com/customservice/kfaccount/del?kf_account=" +
		kfAccount + "&access_token="
	if err = clt.GetJSON(incompleteURL, &result); err != nil {
		return
	}

	if result.ErrCode != mp.ErrCodeOK {
		err = &result
		return
	}
	return
}
示例#5
0
文件: account.go 项目: Wang/wechat
// 查询审核状态
func GetAuditStatus(clt *mp.Client) (status *AuditStatus, err error) {
	var result struct {
		mp.Error
		AuditStatus `json:"data"`
	}

	incompleteURL := "https://api.weixin.qq.com/shakearound/account/auditstatus?access_token="
	if err = clt.GetJSON(incompleteURL, &result); err != nil {
		return
	}

	if result.ErrCode != mp.ErrCodeOK {
		err = &result.Error
		return
	}
	status = &result.AuditStatus
	return
}
示例#6
0
文件: sesson.go 项目: Wang/wechat
// 获取客户的会话
func GetSession(clt *mp.Client, openId string) (ss *Session, err error) {
	var result struct {
		mp.Error
		Session
	}

	incompleteURL := "https://api.weixin.qq.com/customservice/kfsession/getsession?openid=" +
		url.QueryEscape(openId) + "&access_token="
	if err = clt.GetJSON(incompleteURL, &result); err != nil {
		return
	}

	if result.ErrCode != mp.ErrCodeOK {
		err = &result.Error
		return
	}
	result.Session.OpenId = openId
	ss = &result.Session
	return
}
示例#7
0
文件: sesson.go 项目: Wang/wechat
// 获取未接入会话列表
//  开发者可以通过本接口获取当前正在等待队列中的会话列表,此接口最多返回最早进入队列的100个未接入会话。
func GetWaitSessionList(clt *mp.Client) (list []Session, totalCount int, err error) {
	var result struct {
		mp.Error
		TotalCount  int       `json:"count"`
		SessionList []Session `json:"waitcaselist"`
	}

	incompleteURL := "https://api.weixin.qq.com/customservice/kfsession/getwaitcase?access_token="
	if err = clt.GetJSON(incompleteURL, &result); err != nil {
		return
	}

	if result.ErrCode != mp.ErrCodeOK {
		err = &result.Error
		return
	}
	list = result.SessionList
	totalCount = result.TotalCount
	return
}