Skip to content

Commit

Permalink
1. 根据新版客服,删除新增客服和设置客服账号的密码(password)字段 (#38)
Browse files Browse the repository at this point in the history
2. 删除重复函数(inviteworker)
3. 添加新版客服创建会话接口(createKfSession)
  • Loading branch information
JacksonTian committed Nov 15, 2016
2 parents 63e5c97 + 1bb2871 commit cce5b65
Showing 1 changed file with 33 additions and 6 deletions.
39 changes: 33 additions & 6 deletions lib/api_custom_service.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ var md5 = function (input) {

/**
* 添加客服账号
* 详细请看:http://mp.weixin.qq.com/wiki/9/6fff6f191ef92c126b043ada035cc935.html * Examples:
* 详细请看:http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1458044813&token=&lang=zh_CN * Examples:
* ```
* var result = yield api.addKfAccount('test@test', 'nickname', 'password');
* ```
Expand All @@ -154,8 +154,7 @@ exports.addKfAccount = function* (account, nick, password) {
var url = prefix + 'customservice/kfaccount/add?access_token=' + token.accessToken;
var data = {
'kf_account': account,
'nickname': nick,
'password': md5(password),
'nickname': nick
};

return yield this.request(url, postJSON(data));
Expand Down Expand Up @@ -220,7 +219,7 @@ exports.inviteworker = function* (account, wx) {

/**
* 设置客服账号
* 详细请看:http://mp.weixin.qq.com/wiki/9/6fff6f191ef92c126b043ada035cc935.html * Examples:
* 详细请看:http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1458044813&token=&lang=zh_CN * Examples:
* ```
* api.updateKfAccount('test@test', 'nickname', 'password');
* ```
Expand All @@ -242,8 +241,7 @@ exports.updateKfAccount = function* (account, nick, password) {
var url = prefix + 'customservice/kfaccount/update?access_token=' + token.accessToken;
var data = {
'kf_account': account,
'nickname': nick,
'password': md5(password)
'nickname': nick
};

return yield this.request(url, postJSON(data));
Expand Down Expand Up @@ -306,3 +304,32 @@ exports.setKfAccountAvatar = function* (account, filepath) {
};
return yield this.request(url, opts);
};

/**
* 创建客服会话
* 详细请看:http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1458044820&token=&lang=zh_CN * Examples:
* ```
* api.createKfSession('test@test', 'OPENID');
* ```
* Result:
* ```
* {
* "errcode" : 0,
* "errmsg" : "ok",
* }
* ```
* @param {String} account 账号名字,格式为:前缀@公共号名字
* @param {String} openid openid
*/
exports.createKfSession = function*(account, openid) {
var token = yield * this.ensureAccessToken();
// https://api.weixin.qq.com/customservice/kfsession/create?access_token=ACCESS_TOKEN
var prefix = 'https://api.weixin.qq.com/';
var url = prefix + 'customservice/kfsession/create?access_token=' + token.accessToken;
var data = {
kf_account: account,
openid: openid
}

return yield * this.request(url, postJSON(data));
};

0 comments on commit cce5b65

Please sign in to comment.