Skip to content

Commit

Permalink
return 后无需await
Browse files Browse the repository at this point in the history
  • Loading branch information
JacksonTian committed Apr 8, 2017
1 parent 443479b commit 2cb232a
Show file tree
Hide file tree
Showing 28 changed files with 176 additions and 176 deletions.
48 changes: 24 additions & 24 deletions lib/api_card.js
Expand Up @@ -36,7 +36,7 @@ exports.uploadLogo = async function (filepath) {
headers: form.headers(),
stream: form
};
return await this.request(url, opts);
return this.request(url, opts);
};

/**
Expand All @@ -49,7 +49,7 @@ exports.addLocations = async function (locations) {
};
var token = await this.ensureAccessToken();
var url = 'https://api.weixin.qq.com/card/location/batchadd?access_token=' + token.accessToken;
return await this.request(url, postJSON(data));
return this.request(url, postJSON(data));
};

exports.getLocations = async function (offset, count) {
Expand All @@ -59,20 +59,20 @@ exports.getLocations = async function (offset, count) {
};
var token = await this.ensureAccessToken();
var url = 'https://api.weixin.qq.com/card/location/batchget?access_token=' + token.accessToken;
return await this.request(url, postJSON(data));
return this.request(url, postJSON(data));
};

exports.getColors = async function () {
var token = await this.ensureAccessToken();
var url = 'https://api.weixin.qq.com/card/getcolors?access_token=' + token.accessToken;
return await this.request(url, {dataType: 'json'});
return this.request(url, {dataType: 'json'});
};

exports.createCard = async function (card) {
var token = await this.ensureAccessToken();
var url = 'https://api.weixin.qq.com/card/create?access_token=' + token.accessToken;
var data = {card: card};
return await this.request(url, postJSON(data));
return this.request(url, postJSON(data));
};

exports.getRedirectUrl = function (url, encryptCode, cardId) {
Expand All @@ -88,7 +88,7 @@ exports.createQRCode = async function (card) {
card: card
}
};
return await this.request(url, postJSON(data));
return this.request(url, postJSON(data));
};

exports.consumeCode = async function (code, cardId) {
Expand All @@ -98,7 +98,7 @@ exports.consumeCode = async function (code, cardId) {
code: code,
card_id: cardId
};
return await this.request(url, postJSON(data));
return this.request(url, postJSON(data));
};

exports.decryptCode = async function (encryptCode) {
Expand All @@ -107,7 +107,7 @@ exports.decryptCode = async function (encryptCode) {
var data = {
encrypt_code: encryptCode
};
return await this.request(url, postJSON(data));
return this.request(url, postJSON(data));
};

exports.deleteCard = async function (cardId) {
Expand All @@ -116,7 +116,7 @@ exports.deleteCard = async function (cardId) {
var data = {
card_id: cardId
};
return await this.request(url, postJSON(data));
return this.request(url, postJSON(data));
};

exports.getCode = async function (code, cardId) {
Expand All @@ -126,7 +126,7 @@ exports.getCode = async function (code, cardId) {
if (cardId) {
data.card_id = cardId;
}
return await this.request(url, postJSON(data));
return this.request(url, postJSON(data));
};

exports.getCards = async function (offset, count, status_list) {
Expand All @@ -139,7 +139,7 @@ exports.getCards = async function (offset, count, status_list) {
if (status_list) {
data.status_list = status_list;
}
return await this.request(url, postJSON(data));
return this.request(url, postJSON(data));
};

exports.getCard = async function (cardId) {
Expand All @@ -148,7 +148,7 @@ exports.getCard = async function (cardId) {
var data = {
card_id: cardId
};
return await this.request(url, postJSON(data));
return this.request(url, postJSON(data));
};
/**
* 获取用户已领取的卡券
Expand All @@ -173,7 +173,7 @@ exports.getCardList = async function (openid, cardId) {
'openid': openid,
'card_id': cardId
};
return await this.request(url, postJSON(data));
return this.request(url, postJSON(data));
};

exports.updateCode = async function (code, cardId, newcode) {
Expand All @@ -184,7 +184,7 @@ exports.updateCode = async function (code, cardId, newcode) {
card_id: cardId,
newcode: newcode
};
return await this.request(url, postJSON(data));
return this.request(url, postJSON(data));
};

exports.unavailableCode = async function (code, cardId) {
Expand All @@ -196,7 +196,7 @@ exports.unavailableCode = async function (code, cardId) {
if (cardId) {
data.card_id = cardId;
}
return await this.request(url, postJSON(data));
return this.request(url, postJSON(data));
};

exports.updateCard = async function (cardId, cardInfo) {
Expand All @@ -206,7 +206,7 @@ exports.updateCard = async function (cardId, cardInfo) {
card_id: cardId,
member_card: cardInfo
};
return await this.request(url, postJSON(data));
return this.request(url, postJSON(data));
};

exports.updateCardStock = async function (cardId, num) {
Expand All @@ -220,31 +220,31 @@ exports.updateCardStock = async function (cardId, num) {
} else {
data.reduce_stock_value = Math.abs(num);
}
return await this.request(url, postJSON(data));
return this.request(url, postJSON(data));
};

exports.activateMembercard = async function (info) {
var token = await this.ensureAccessToken();
var url = 'https://api.weixin.qq.com/card/membercard/activate?access_token=' + token.accessToken;
return await this.request(url, postJSON(info));
return this.request(url, postJSON(info));
};

exports.updateMembercard = async function (info) {
var token = await this.ensureAccessToken();
var url = 'https://api.weixin.qq.com/card/membercard/updateuser?access_token=' + token.accessToken;
return await this.request(url, postJSON(info));
return this.request(url, postJSON(info));
};

exports.updateMovieTicket = async function (info) {
var token = await this.ensureAccessToken();
var url = 'https://api.weixin.qq.com/card/movieticket/updateuser?access_token=' + token.accessToken;
return await this.request(url, postJSON(info));
return this.request(url, postJSON(info));
};

exports.checkInBoardingPass = async function (info) {
var token = await this.ensureAccessToken();
var url = 'https://api.weixin.qq.com/card/boardingpass/checkin?access_token=' + token.accessToken;
return await this.request(url, postJSON(info));
return this.request(url, postJSON(info));
};

exports.updateLuckyMonkeyBalance = async function (code, cardId, balance) {
Expand All @@ -255,17 +255,17 @@ exports.updateLuckyMonkeyBalance = async function (code, cardId, balance) {
'card_id': cardId,
'balance': balance
};
return await this.request(url, postJSON(data));
return this.request(url, postJSON(data));
};

exports.updateMeetingTicket = async function (info) {
var token = await this.ensureAccessToken();
var url = 'https://api.weixin.qq.com/card/meetingticket/updateuser?access_token=' + token.accessToken;
return await this.request(url, postJSON(info));
return this.request(url, postJSON(info));
};

exports.setTestWhitelist = async function (info) {
var token = await this.ensureAccessToken();
var url = 'https://api.weixin.qq.com/card/testwhitelist/set?access_token=' + token.accessToken;
return await this.request(url, postJSON(info));
return this.request(url, postJSON(info));
};
4 changes: 2 additions & 2 deletions lib/api_common.js
Expand Up @@ -146,7 +146,7 @@ class API {
delete urlobj.search;
}

return await this.request(liburl.format(urlobj), opts, retry - 1);
return this.request(liburl.format(urlobj), opts, retry - 1);
}

throw err;
Expand Down Expand Up @@ -198,7 +198,7 @@ class API {
if (token && (accessToken = AccessToken(token.accessToken, token.expireTime)).isValid()) {
return accessToken;
}
return await this.getAccessToken();
return this.getAccessToken();
}
}

Expand Down
18 changes: 9 additions & 9 deletions lib/api_custom_service.js
Expand Up @@ -51,7 +51,7 @@ exports.getRecords = async function (opts) {
var token = await this.ensureAccessToken();
// https://api.weixin.qq.com/customservice/msgrecord/getrecord?access_token=ACCESS_TOKEN
var url = this.customservicePrefix + 'msgrecord/getrecord?access_token=' + token.accessToken;
return await this.request(url, postJSON(opts));
return this.request(url, postJSON(opts));
};

/**
Expand Down Expand Up @@ -88,7 +88,7 @@ exports.getCustomServiceList = async function () {
var token = await this.ensureAccessToken();
// https://api.weixin.qq.com/cgi-bin/customservice/getkflist?access_token= ACCESS_TOKEN
var url = this.prefix + 'customservice/getkflist?access_token=' + token.accessToken;
return await this.request(url, {dataType: 'json'});
return this.request(url, {dataType: 'json'});
};

/**
Expand Down Expand Up @@ -123,7 +123,7 @@ exports.getOnlineCustomServiceList = async function () {
var token = await this.ensureAccessToken();
// https://api.weixin.qq.com/cgi-bin/customservice/getonlinekflist?access_token= ACCESS_TOKEN
var url = this.prefix + 'customservice/getonlinekflist?access_token=' + token.accessToken;
return await this.request(url, {dataType: 'json'});
return this.request(url, {dataType: 'json'});
};

/**
Expand Down Expand Up @@ -152,7 +152,7 @@ exports.addKfAccount = async function (account, nick) {
'nickname': nick
};

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

/**
Expand Down Expand Up @@ -182,7 +182,7 @@ exports.inviteworker = async function (account, wx) {
'invite_wx': wx
};

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

/**
Expand Down Expand Up @@ -211,7 +211,7 @@ exports.updateKfAccount = async function (account, nick) {
'nickname': nick
};

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

/**
Expand All @@ -235,7 +235,7 @@ exports.deleteKfAccount = async function (account) {
var prefix = 'https://api.weixin.qq.com/';
var url = prefix + 'customservice/kfaccount/del?access_token=' + token.accessToken + '&kf_account=' + account;

return await this.request(url, {dataType: 'json'});
return this.request(url, {dataType: 'json'});
};

/**
Expand Down Expand Up @@ -269,7 +269,7 @@ exports.setKfAccountAvatar = async function (account, filepath) {
headers: form.headers(),
stream: form
};
return await this.request(url, opts);
return this.request(url, opts);
};

/**
Expand Down Expand Up @@ -298,5 +298,5 @@ exports.createKfSession = async function(account, openid) {
openid: openid
};

return await this.request(url, postJSON(data));
return this.request(url, postJSON(data));
};
2 changes: 1 addition & 1 deletion lib/api_datacube.js
Expand Up @@ -71,6 +71,6 @@ methods.forEach(function (method) {
end_date: end
};
var url = 'https://api.weixin.qq.com/datacube/' + method.toLowerCase() + '?access_token=' + token.accessToken;
return await this.request(url, postJSON(data));
return this.request(url, postJSON(data));
};
});

0 comments on commit 2cb232a

Please sign in to comment.