node-easywechat 2.8.0 → 2.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/BaseService/Jssdk/JssdkClient.js +5 -5
- package/dist/BaseService/Media/MediaClient.js +1 -1
- package/dist/Core/AES.d.ts +1 -1
- package/dist/Core/AES.js +4 -4
- package/dist/Core/BaseAccessToken.js +2 -2
- package/dist/Core/BaseApplication.js +4 -4
- package/dist/Core/BaseClient.js +2 -2
- package/dist/Core/Cache/FileCache.js +3 -3
- package/dist/Core/Encryptor.js +3 -3
- package/dist/Core/Http/Request.js +11 -11
- package/dist/Core/Http/StreamResponse.js +1 -1
- package/dist/Core/Messages/Media.js +2 -2
- package/dist/Core/Messages/Message.js +7 -7
- package/dist/Core/Mixins/HttpMixin.js +4 -4
- package/dist/Core/ServerGuard.js +5 -5
- package/dist/Core/Utils.js +18 -18
- package/dist/MicroMerchant/Application.js +1 -1
- package/dist/MicroMerchant/Base/MicroMerchantBase.js +6 -6
- package/dist/MicroMerchant/Certficates/CertficatesClient.js +1 -1
- package/dist/MicroMerchant/Core/BaseClient.js +8 -8
- package/dist/MicroMerchant/Media/MediaClient.js +1 -1
- package/dist/MicroMerchant/MerchantConfig/MerchantConfigClient.js +1 -1
- package/dist/MicroMerchant/Meterial/MeterialClient.js +4 -4
- package/dist/MicroMerchant/Withdraw/WithdrawClient.js +2 -2
- package/dist/MiniProgram/ActivityMessage/ActivityMessageClient.js +3 -3
- package/dist/MiniProgram/AppCode/AppCodeClient.js +2 -2
- package/dist/MiniProgram/Application.d.ts +2 -0
- package/dist/MiniProgram/Application.js +5 -0
- package/dist/MiniProgram/Base/MiniProgramBase.js +1 -1
- package/dist/MiniProgram/NearbyPoi/NearbyPoiClient.js +3 -3
- package/dist/MiniProgram/OpenData/OpenDataClient.js +2 -2
- package/dist/MiniProgram/RealtimeLog/RealtimeLogClient.js +1 -1
- package/dist/MiniProgram/ShortLink/ShortLinkClient.d.ts +11 -0
- package/dist/MiniProgram/ShortLink/ShortLinkClient.js +23 -0
- package/dist/MiniProgram/SubscribeMessage/SubscribeMessageClient.js +5 -5
- package/dist/MiniProgram/UniformMessage/UniformMessageClient.js +3 -3
- package/dist/MiniProgram/UrlLink/UrlLinkClient.d.ts +6 -1
- package/dist/MiniProgram/UrlLink/UrlLinkClient.js +7 -2
- package/dist/OfficialAccount/Base/OfficialAccountBase.js +2 -2
- package/dist/OfficialAccount/Broadcasting/BroadcastingClient.js +2 -2
- package/dist/OfficialAccount/Broadcasting/MessageBuilder.js +1 -1
- package/dist/OfficialAccount/Card/Client.js +1 -1
- package/dist/OfficialAccount/Card/JssdkClient.js +2 -2
- package/dist/OfficialAccount/Card/MemberCardClient.js +1 -1
- package/dist/OfficialAccount/CustomerService/CustomerServiceClient.js +2 -2
- package/dist/OfficialAccount/CustomerService/Messenger.js +1 -1
- package/dist/OfficialAccount/DataCube/DataCubeClient.js +1 -1
- package/dist/OfficialAccount/Material/MaterialClient.js +2 -2
- package/dist/OfficialAccount/OCR/OCRClient.js +1 -1
- package/dist/OfficialAccount/Semantic/SemanticClient.js +1 -1
- package/dist/OfficialAccount/SubscribeMessage/SubscribeMessageClient.js +4 -4
- package/dist/OfficialAccount/TemplateMessage/TemplateMessageClient.js +4 -4
- package/dist/OpenPlatform/Application.js +7 -7
- package/dist/OpenPlatform/Authorizer/Auth/AccessToken.js +1 -1
- package/dist/OpenPlatform/Authorizer/OfficialAccount/Account/Client.js +1 -1
- package/dist/Payment/Application.js +4 -4
- package/dist/Payment/Bill/BillClient.js +2 -2
- package/dist/Payment/Core/BaseClient.js +8 -8
- package/dist/Payment/Jssdk/JssdkClient.js +14 -14
- package/dist/Payment/Merchant/MerchantClient.js +1 -1
- package/dist/Payment/Notify/Handler.js +5 -5
- package/dist/Payment/Notify/Refunded.js +1 -1
- package/dist/Payment/Notify/Scanned.js +2 -2
- package/dist/Payment/Order/OrderClient.js +1 -1
- package/dist/Payment/Redpack/RedpackClient.js +5 -5
- package/dist/Payment/Refund/RefundClient.js +3 -3
- package/dist/Payment/Sandbox/SandboxClient.js +1 -1
- package/dist/Payment/Transfer/TransferClient.js +1 -1
- package/dist/Work/Agent/AgentClient.js +1 -1
- package/dist/Work/Calendar/CalendarClient.js +1 -1
- package/dist/Work/Chat/ChatClient.js +1 -1
- package/dist/Work/Department/DepartmentClient.js +1 -1
- package/dist/Work/ExternalContact/Client.d.ts +45 -0
- package/dist/Work/ExternalContact/Client.js +72 -0
- package/dist/Work/ExternalContact/ContactWayClient.js +2 -2
- package/dist/Work/ExternalContact/MessageClient.js +4 -4
- package/dist/Work/ExternalContact/MessageTemplateClient.js +3 -3
- package/dist/Work/Jssdk/JssdkClient.js +3 -3
- package/dist/Work/Media/MediaClient.js +1 -1
- package/dist/Work/Message/Messenger.js +2 -2
- package/dist/Work/Schedule/ScheduleClient.js +1 -1
- package/dist/Work/User/UserClient.js +3 -3
- package/dist/index.js +1 -1
- package/node-easywechat.file_cache.easywechat.kernel.access_token.8a9684b45da7de42a06a70ba01a7005a.cache +1 -1
- package/node-easywechat.file_cache.easywechat.kernel.access_token.c3d06edaf326aad75d32f31348df787a.cache +1 -1
- package/package.json +9 -9
|
@@ -21,7 +21,7 @@ class BaseClient extends BaseClient_1.default {
|
|
|
21
21
|
httpUpload(url, files = {}, form = {}, query = {}, returnResponse = false) {
|
|
22
22
|
let formData = new form_data_1.default;
|
|
23
23
|
for (let name in files) {
|
|
24
|
-
if (Utils_1.isString(files[name])) {
|
|
24
|
+
if ((0, Utils_1.isString)(files[name])) {
|
|
25
25
|
formData.append(name, fs_1.default.createReadStream(files[name]));
|
|
26
26
|
}
|
|
27
27
|
else {
|
|
@@ -43,14 +43,14 @@ class BaseClient extends BaseClient_1.default {
|
|
|
43
43
|
let base = {
|
|
44
44
|
mch_id: this.app.config.mch_id,
|
|
45
45
|
};
|
|
46
|
-
let localParams = Utils_1.merge(Utils_1.merge(base, this.prepends()), params);
|
|
46
|
+
let localParams = (0, Utils_1.merge)((0, Utils_1.merge)(base, this.prepends()), params);
|
|
47
47
|
let secretKey = yield this.app.getKey();
|
|
48
|
-
localParams['sign'] = Utils_1.makeSignature(localParams, secretKey, localParams['sign_type'] || 'MD5');
|
|
49
|
-
let payload = Utils_1.merge(Utils_1.merge({}, options), {
|
|
48
|
+
localParams['sign'] = (0, Utils_1.makeSignature)(localParams, secretKey, localParams['sign_type'] || 'MD5');
|
|
49
|
+
let payload = (0, Utils_1.merge)((0, Utils_1.merge)({}, options), {
|
|
50
50
|
url: endpoint,
|
|
51
51
|
method,
|
|
52
52
|
responseType: 'text',
|
|
53
|
-
data: Utils_1.buildXml(localParams)
|
|
53
|
+
data: (0, Utils_1.buildXml)(localParams)
|
|
54
54
|
});
|
|
55
55
|
let response = yield this.doRequest(payload);
|
|
56
56
|
if (returnResponse) {
|
|
@@ -59,7 +59,7 @@ class BaseClient extends BaseClient_1.default {
|
|
|
59
59
|
else {
|
|
60
60
|
let body = response.data;
|
|
61
61
|
try {
|
|
62
|
-
body = yield Utils_1.parseXml(body);
|
|
62
|
+
body = yield (0, Utils_1.parseXml)(body);
|
|
63
63
|
}
|
|
64
64
|
catch (e) { }
|
|
65
65
|
return body;
|
|
@@ -77,11 +77,11 @@ class BaseClient extends BaseClient_1.default {
|
|
|
77
77
|
}
|
|
78
78
|
let rsa = new RSA_1.default;
|
|
79
79
|
rsa.setPublicKey(certificate);
|
|
80
|
-
let newParams = Utils_1.merge({}, params);
|
|
80
|
+
let newParams = (0, Utils_1.merge)({}, params);
|
|
81
81
|
newParams['cert_sn'] = serial_no;
|
|
82
82
|
let sensitive_fields = this.getSensitiveFieldsName();
|
|
83
83
|
for (let k in newParams) {
|
|
84
|
-
if (Utils_1.inArray(k, sensitive_fields)) {
|
|
84
|
+
if ((0, Utils_1.inArray)(k, sensitive_fields)) {
|
|
85
85
|
newParams[k] = rsa.encrypt(newParams[k]);
|
|
86
86
|
}
|
|
87
87
|
}
|
|
@@ -21,7 +21,7 @@ class MediaClient extends BaseClient_1.default {
|
|
|
21
21
|
throw new Error(`File does not exist, or the file is unreadable: '${file}'`);
|
|
22
22
|
}
|
|
23
23
|
let form = {
|
|
24
|
-
media_hash: yield Utils_1.md5File(file),
|
|
24
|
+
media_hash: yield (0, Utils_1.md5File)(file),
|
|
25
25
|
sign_type: 'HMAC-SHA256',
|
|
26
26
|
};
|
|
27
27
|
return this.httpUpload('secapi/mch/uploadmedia', {
|
|
@@ -11,7 +11,7 @@ class MerchantConfigClient extends BaseClient_1.default {
|
|
|
11
11
|
sub_appid: subAppId,
|
|
12
12
|
sub_mch_id: subMchId || this.app.config.sub_mch_id,
|
|
13
13
|
sign_type: 'HMAC-SHA256',
|
|
14
|
-
nonce_str: Utils_1.randomString(18),
|
|
14
|
+
nonce_str: (0, Utils_1.randomString)(18),
|
|
15
15
|
};
|
|
16
16
|
if (subscribeAppId) {
|
|
17
17
|
params['subscribe_appid'] = subscribeAppId;
|
|
@@ -7,22 +7,22 @@ const Utils_1 = require("../../Core/Utils");
|
|
|
7
7
|
const BaseClient_1 = __importDefault(require("../Core/BaseClient"));
|
|
8
8
|
class MeterialClient extends BaseClient_1.default {
|
|
9
9
|
setSettlementCard(params) {
|
|
10
|
-
let newParams = this.processParams(Utils_1.merge(Utils_1.merge({}, params), {
|
|
10
|
+
let newParams = this.processParams((0, Utils_1.merge)((0, Utils_1.merge)({}, params), {
|
|
11
11
|
sub_mch_id: params['sub_mch_id'] || this.app.config.sub_mch_id,
|
|
12
12
|
version: '1.0',
|
|
13
13
|
cert_sn: '',
|
|
14
14
|
sign_type: 'HMAC-SHA256',
|
|
15
|
-
nonce_str: Utils_1.randomString(18),
|
|
15
|
+
nonce_str: (0, Utils_1.randomString)(18),
|
|
16
16
|
}));
|
|
17
17
|
return this.safeRequest('applyment/micro/modifyarchives', newParams);
|
|
18
18
|
}
|
|
19
19
|
updateContact(params) {
|
|
20
|
-
let newParams = this.processParams(Utils_1.merge(Utils_1.merge({}, params), {
|
|
20
|
+
let newParams = this.processParams((0, Utils_1.merge)((0, Utils_1.merge)({}, params), {
|
|
21
21
|
sub_mch_id: params['sub_mch_id'] || this.app.config.sub_mch_id,
|
|
22
22
|
version: '1.0',
|
|
23
23
|
cert_sn: '',
|
|
24
24
|
sign_type: 'HMAC-SHA256',
|
|
25
|
-
nonce_str: Utils_1.randomString(18),
|
|
25
|
+
nonce_str: (0, Utils_1.randomString)(18),
|
|
26
26
|
}));
|
|
27
27
|
return this.safeRequest('applyment/micro/modifycontactinfo', newParams);
|
|
28
28
|
}
|
|
@@ -11,7 +11,7 @@ class WithdrawClient extends BaseClient_1.default {
|
|
|
11
11
|
date,
|
|
12
12
|
sub_mch_id: subMchId || this.app.config.sub_mch_id,
|
|
13
13
|
sign_type: 'HMAC-SHA256',
|
|
14
|
-
nonce_str: Utils_1.randomString(18),
|
|
14
|
+
nonce_str: (0, Utils_1.randomString)(18),
|
|
15
15
|
};
|
|
16
16
|
return this.safeRequest('fund/queryautowithdrawbydate', params);
|
|
17
17
|
}
|
|
@@ -20,7 +20,7 @@ class WithdrawClient extends BaseClient_1.default {
|
|
|
20
20
|
date,
|
|
21
21
|
sub_mch_id: subMchId || this.app.config.sub_mch_id,
|
|
22
22
|
sign_type: 'HMAC-SHA256',
|
|
23
|
-
nonce_str: Utils_1.randomString(18),
|
|
23
|
+
nonce_str: (0, Utils_1.randomString)(18),
|
|
24
24
|
};
|
|
25
25
|
return this.safeRequest('fund/reautowithdrawbydate', params);
|
|
26
26
|
}
|
|
@@ -10,7 +10,7 @@ class ActivityMessageClient extends BaseClient_1.default {
|
|
|
10
10
|
return this.httpGet('cgi-bin/message/wxopen/activityid/create');
|
|
11
11
|
}
|
|
12
12
|
updateMessage(activityId, state = 0, params = {}) {
|
|
13
|
-
if (!Utils_1.inArray(state, [0, 1, '0', '1'])) {
|
|
13
|
+
if (!(0, Utils_1.inArray)(state, [0, 1, '0', '1'])) {
|
|
14
14
|
throw new Error('"state" should be "0" or "1".');
|
|
15
15
|
}
|
|
16
16
|
params = {
|
|
@@ -25,10 +25,10 @@ class ActivityMessageClient extends BaseClient_1.default {
|
|
|
25
25
|
formatParameters(params) {
|
|
26
26
|
let formatted = [];
|
|
27
27
|
for (let key in params) {
|
|
28
|
-
if (Utils_1.inArray(key, ['member_count', 'room_limit', 'path', 'version_type'])) {
|
|
28
|
+
if ((0, Utils_1.inArray)(key, ['member_count', 'room_limit', 'path', 'version_type'])) {
|
|
29
29
|
continue;
|
|
30
30
|
}
|
|
31
|
-
if (key === 'version_type' && !Utils_1.inArray(params[key], ['develop', 'trial', 'release'])) {
|
|
31
|
+
if (key === 'version_type' && !(0, Utils_1.inArray)(params[key], ['develop', 'trial', 'release'])) {
|
|
32
32
|
throw new Error('Invalid value of attribute "version_type".');
|
|
33
33
|
}
|
|
34
34
|
formatted.push({
|
|
@@ -23,7 +23,7 @@ class AppCodeClient extends BaseClient_1.default {
|
|
|
23
23
|
*/
|
|
24
24
|
get(path, optional = {}) {
|
|
25
25
|
return __awaiter(this, void 0, void 0, function* () {
|
|
26
|
-
let params = Utils_1.merge({
|
|
26
|
+
let params = (0, Utils_1.merge)({
|
|
27
27
|
path,
|
|
28
28
|
}, optional);
|
|
29
29
|
return yield this.getStream('wxa/getwxacode', params);
|
|
@@ -36,7 +36,7 @@ class AppCodeClient extends BaseClient_1.default {
|
|
|
36
36
|
*/
|
|
37
37
|
getUnlimit(scene, optional = {}) {
|
|
38
38
|
return __awaiter(this, void 0, void 0, function* () {
|
|
39
|
-
let params = Utils_1.merge({
|
|
39
|
+
let params = (0, Utils_1.merge)({
|
|
40
40
|
scene,
|
|
41
41
|
}, optional);
|
|
42
42
|
return yield this.getStream('wxa/getwxacodeunlimit', params);
|
|
@@ -21,6 +21,7 @@ import SoterClient from './Soter/SoterClient';
|
|
|
21
21
|
import SubscribeMessageClient from './SubscribeMessage/SubscribeMessageClient';
|
|
22
22
|
import RealtimeLogClient from './RealtimeLog/RealtimeLogClient';
|
|
23
23
|
import SearchClient from './Search/SearchClient';
|
|
24
|
+
import ShortLinkClient from './ShortLink/ShortLinkClient';
|
|
24
25
|
import MediaClient from '../BaseService/Media/MediaClient';
|
|
25
26
|
import ContentSecurityClient from '../BaseService/ContentSecurity/ContentSecurityClient';
|
|
26
27
|
import { EasyWechatConfig } from '../Core/Types';
|
|
@@ -53,6 +54,7 @@ export default class MiniProgram extends BaseApplication {
|
|
|
53
54
|
subscribe_message: SubscribeMessageClient;
|
|
54
55
|
realtime_log: RealtimeLogClient;
|
|
55
56
|
search: SearchClient;
|
|
57
|
+
short_link: ShortLinkClient;
|
|
56
58
|
media: MediaClient;
|
|
57
59
|
content_security: ContentSecurityClient;
|
|
58
60
|
url_link: UrlLinkClient;
|
|
@@ -35,6 +35,7 @@ const SoterClient_1 = __importDefault(require("./Soter/SoterClient"));
|
|
|
35
35
|
const SubscribeMessageClient_1 = __importDefault(require("./SubscribeMessage/SubscribeMessageClient"));
|
|
36
36
|
const RealtimeLogClient_1 = __importDefault(require("./RealtimeLog/RealtimeLogClient"));
|
|
37
37
|
const SearchClient_1 = __importDefault(require("./Search/SearchClient"));
|
|
38
|
+
const ShortLinkClient_1 = __importDefault(require("./ShortLink/ShortLinkClient"));
|
|
38
39
|
const MediaClient_1 = __importDefault(require("../BaseService/Media/MediaClient"));
|
|
39
40
|
const ContentSecurityClient_1 = __importDefault(require("../BaseService/ContentSecurity/ContentSecurityClient"));
|
|
40
41
|
const UrlLinkClient_1 = __importDefault(require("./UrlLink/UrlLinkClient"));
|
|
@@ -68,6 +69,7 @@ class MiniProgram extends BaseApplication_1.default {
|
|
|
68
69
|
this.subscribe_message = null;
|
|
69
70
|
this.realtime_log = null;
|
|
70
71
|
this.search = null;
|
|
72
|
+
this.short_link = null;
|
|
71
73
|
this.media = null;
|
|
72
74
|
this.content_security = null;
|
|
73
75
|
this.url_link = null;
|
|
@@ -163,6 +165,9 @@ class MiniProgram extends BaseApplication_1.default {
|
|
|
163
165
|
this.offsetSet('search', function (app) {
|
|
164
166
|
return new SearchClient_1.default(app);
|
|
165
167
|
});
|
|
168
|
+
this.offsetSet('short_link', function (app) {
|
|
169
|
+
return new ShortLinkClient_1.default(app);
|
|
170
|
+
});
|
|
166
171
|
this.offsetSet('url_link', function (app) {
|
|
167
172
|
return new UrlLinkClient_1.default(app);
|
|
168
173
|
});
|
|
@@ -12,7 +12,7 @@ class MiniProgramBase extends BaseClient_1.default {
|
|
|
12
12
|
* @param optional 参数。transaction_id:支付交易号;mch_id:商户id;out_trade_no:商家订单号
|
|
13
13
|
*/
|
|
14
14
|
getPaidUnionid(openid, optional = {}) {
|
|
15
|
-
let params = Utils_1.merge({
|
|
15
|
+
let params = (0, Utils_1.merge)({
|
|
16
16
|
openid,
|
|
17
17
|
}, optional);
|
|
18
18
|
return this.httpGet('wxa/getpaidunionid', params);
|
|
@@ -11,7 +11,7 @@ class NearbyPoiClient extends BaseClient_1.default {
|
|
|
11
11
|
* @param params 地点信息
|
|
12
12
|
*/
|
|
13
13
|
add(params = {}) {
|
|
14
|
-
params = Utils_1.merge({
|
|
14
|
+
params = (0, Utils_1.merge)({
|
|
15
15
|
is_comm_nearby: '1',
|
|
16
16
|
poi_id: '',
|
|
17
17
|
}, params);
|
|
@@ -23,7 +23,7 @@ class NearbyPoiClient extends BaseClient_1.default {
|
|
|
23
23
|
* @param params 地点信息
|
|
24
24
|
*/
|
|
25
25
|
update(poiId, params = {}) {
|
|
26
|
-
params = Utils_1.merge({
|
|
26
|
+
params = (0, Utils_1.merge)({
|
|
27
27
|
is_comm_nearby: '1',
|
|
28
28
|
poi_id: poiId,
|
|
29
29
|
}, params);
|
|
@@ -55,7 +55,7 @@ class NearbyPoiClient extends BaseClient_1.default {
|
|
|
55
55
|
* @param status 0:不展示;1:展示
|
|
56
56
|
*/
|
|
57
57
|
setVisibility(poiId = '', status) {
|
|
58
|
-
if (!Utils_1.inArray(status, [0, 1, '0', '1'])) {
|
|
58
|
+
if (!(0, Utils_1.inArray)(status, [0, 1, '0', '1'])) {
|
|
59
59
|
throw new Error('status should be 0 or 1.');
|
|
60
60
|
}
|
|
61
61
|
return this.httpPostJson('wxa/setnearbypoishowstatus', {
|
|
@@ -17,7 +17,7 @@ class OpenDataClient extends BaseClient_1.default {
|
|
|
17
17
|
let query = {
|
|
18
18
|
openid: openid,
|
|
19
19
|
sig_method: 'hmac_sha256',
|
|
20
|
-
signature: Utils_1.createHmac(JSON.stringify(data), sessionKey, 'sha256'),
|
|
20
|
+
signature: (0, Utils_1.createHmac)(JSON.stringify(data), sessionKey, 'sha256'),
|
|
21
21
|
};
|
|
22
22
|
return this.httpPostJson('remove_user_storage', data, query);
|
|
23
23
|
}
|
|
@@ -28,7 +28,7 @@ class OpenDataClient extends BaseClient_1.default {
|
|
|
28
28
|
let query = {
|
|
29
29
|
openid: openid,
|
|
30
30
|
sig_method: 'hmac_sha256',
|
|
31
|
-
signature: Utils_1.createHmac(JSON.stringify(data), sessionKey, 'sha256'),
|
|
31
|
+
signature: (0, Utils_1.createHmac)(JSON.stringify(data), sessionKey, 'sha256'),
|
|
32
32
|
};
|
|
33
33
|
return this.httpPostJson('set_user_storage', data, query);
|
|
34
34
|
}
|
|
@@ -14,7 +14,7 @@ class RealtimeLogClient extends BaseClient_1.default {
|
|
|
14
14
|
* @param options 其它参数
|
|
15
15
|
*/
|
|
16
16
|
search(date, beginTime, endTime, options = {}) {
|
|
17
|
-
let params = Utils_1.merge({
|
|
17
|
+
let params = (0, Utils_1.merge)({
|
|
18
18
|
date: date,
|
|
19
19
|
begintime: beginTime,
|
|
20
20
|
endtime: endTime,
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import BaseClient from '../../Core/BaseClient';
|
|
2
|
+
export default class ShortLinkClient extends BaseClient {
|
|
3
|
+
/**
|
|
4
|
+
* 获取小程序 Short Link
|
|
5
|
+
* @param pageUrl
|
|
6
|
+
* @param pageTitle
|
|
7
|
+
* @param isPermanent
|
|
8
|
+
* @returns
|
|
9
|
+
*/
|
|
10
|
+
getShortLink(pageUrl: string, pageTitle: string, isPermanent?: boolean): Promise<any>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const BaseClient_1 = __importDefault(require("../../Core/BaseClient"));
|
|
7
|
+
class ShortLinkClient extends BaseClient_1.default {
|
|
8
|
+
/**
|
|
9
|
+
* 获取小程序 Short Link
|
|
10
|
+
* @param pageUrl
|
|
11
|
+
* @param pageTitle
|
|
12
|
+
* @param isPermanent
|
|
13
|
+
* @returns
|
|
14
|
+
*/
|
|
15
|
+
getShortLink(pageUrl, pageTitle, isPermanent = false) {
|
|
16
|
+
return this.httpPostJson('wxa/genwxashortlink', {
|
|
17
|
+
page_url: pageUrl,
|
|
18
|
+
page_title: pageTitle,
|
|
19
|
+
is_permanent: isPermanent,
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.default = ShortLinkClient;
|
|
@@ -26,9 +26,9 @@ class SubscribeMessageClient extends BaseClient_1.default {
|
|
|
26
26
|
return this.httpPostJson('cgi-bin/message/subscribe/send', params);
|
|
27
27
|
}
|
|
28
28
|
formatMessage(data) {
|
|
29
|
-
let params = Utils_1.merge(Utils_1.merge({}, this.message), data);
|
|
29
|
+
let params = (0, Utils_1.merge)((0, Utils_1.merge)({}, this.message), data);
|
|
30
30
|
for (let key in params) {
|
|
31
|
-
if (Utils_1.inArray(key, this.required) && !params[key]) {
|
|
31
|
+
if ((0, Utils_1.inArray)(key, this.required) && !params[key]) {
|
|
32
32
|
throw new Error(`Attribute "${key}" can not be empty!`);
|
|
33
33
|
}
|
|
34
34
|
}
|
|
@@ -39,13 +39,13 @@ class SubscribeMessageClient extends BaseClient_1.default {
|
|
|
39
39
|
let formatted = {}, value;
|
|
40
40
|
for (let key in data) {
|
|
41
41
|
value = {};
|
|
42
|
-
if (Utils_1.isArray(data[key]) && data[key].length == 2) {
|
|
42
|
+
if ((0, Utils_1.isArray)(data[key]) && data[key].length == 2) {
|
|
43
43
|
value = {
|
|
44
44
|
value: data[key][0],
|
|
45
45
|
color: data[key][1],
|
|
46
46
|
};
|
|
47
47
|
}
|
|
48
|
-
else if (Utils_1.isObject(data[key]) && data[key]['value']) {
|
|
48
|
+
else if ((0, Utils_1.isObject)(data[key]) && data[key]['value']) {
|
|
49
49
|
value = data[key];
|
|
50
50
|
}
|
|
51
51
|
else {
|
|
@@ -101,7 +101,7 @@ class SubscribeMessageClient extends BaseClient_1.default {
|
|
|
101
101
|
start,
|
|
102
102
|
limit,
|
|
103
103
|
};
|
|
104
|
-
if (Utils_1.isArray(ids)) {
|
|
104
|
+
if ((0, Utils_1.isArray)(ids)) {
|
|
105
105
|
query.ids = ids.join(',');
|
|
106
106
|
}
|
|
107
107
|
return this.httpGet('wxaapi/newtmpl/getpubtemplatetitles', query);
|
|
@@ -29,7 +29,7 @@ class UniformMessageClient extends TemplateMessageClient_1.default {
|
|
|
29
29
|
this.required = ['touser', 'template_id', 'form_id', 'miniprogram', 'appid'];
|
|
30
30
|
}
|
|
31
31
|
formatMessage(data) {
|
|
32
|
-
let params = Utils_1.merge(Utils_1.merge({}, this.message), data);
|
|
32
|
+
let params = (0, Utils_1.merge)((0, Utils_1.merge)({}, this.message), data);
|
|
33
33
|
if (!params['touser']) {
|
|
34
34
|
throw new Error('Attribute "touser" can not be empty!');
|
|
35
35
|
}
|
|
@@ -55,9 +55,9 @@ class UniformMessageClient extends TemplateMessageClient_1.default {
|
|
|
55
55
|
return params;
|
|
56
56
|
}
|
|
57
57
|
baseFormat(data = {}, defaultData = {}) {
|
|
58
|
-
let params = Utils_1.merge(Utils_1.merge({}, defaultData), data);
|
|
58
|
+
let params = (0, Utils_1.merge)((0, Utils_1.merge)({}, defaultData), data);
|
|
59
59
|
for (let key in params) {
|
|
60
|
-
if (Utils_1.inArray(key, this.required) && !params[key] && !defaultData[key]) {
|
|
60
|
+
if ((0, Utils_1.inArray)(key, this.required) && !params[key] && !defaultData[key]) {
|
|
61
61
|
throw new Error(`Attribute "${key}" can not be empty!`);
|
|
62
62
|
}
|
|
63
63
|
params[key] = params[key] || defaultData[key];
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import BaseClient from '../../Core/BaseClient';
|
|
2
|
-
export default class
|
|
2
|
+
export default class UrlLinkClient extends BaseClient {
|
|
3
|
+
/**
|
|
4
|
+
* 获取小程序 URL Link
|
|
5
|
+
* @param params
|
|
6
|
+
* @returns
|
|
7
|
+
*/
|
|
3
8
|
generate(params?: object): Promise<any>;
|
|
4
9
|
}
|
|
@@ -4,9 +4,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const BaseClient_1 = __importDefault(require("../../Core/BaseClient"));
|
|
7
|
-
class
|
|
7
|
+
class UrlLinkClient extends BaseClient_1.default {
|
|
8
|
+
/**
|
|
9
|
+
* 获取小程序 URL Link
|
|
10
|
+
* @param params
|
|
11
|
+
* @returns
|
|
12
|
+
*/
|
|
8
13
|
generate(params = {}) {
|
|
9
14
|
return this.httpPostJson('wxa/generate_urllink', params);
|
|
10
15
|
}
|
|
11
16
|
}
|
|
12
|
-
exports.default =
|
|
17
|
+
exports.default = UrlLinkClient;
|
|
@@ -22,11 +22,11 @@ class OfficialAccountBase extends BaseClient_1.default {
|
|
|
22
22
|
return this.httpGet('cgi-bin/getcallbackip');
|
|
23
23
|
}
|
|
24
24
|
checkCallbackUrl(action = 'all', operator = 'DEFAULT') {
|
|
25
|
-
if (!Utils_1.inArray(action, ['dns', 'ping', 'all'], true)) {
|
|
25
|
+
if (!(0, Utils_1.inArray)(action, ['dns', 'ping', 'all'], true)) {
|
|
26
26
|
throw new Error('The action must be dns, ping, all.');
|
|
27
27
|
}
|
|
28
28
|
operator = operator.toUpperCase();
|
|
29
|
-
if (!Utils_1.inArray(operator, ['CHINANET', 'UNICOM', 'CAP', 'DEFAULT'], true)) {
|
|
29
|
+
if (!(0, Utils_1.inArray)(operator, ['CHINANET', 'UNICOM', 'CAP', 'DEFAULT'], true)) {
|
|
30
30
|
throw new Error('The operator must be CHINANET, UNICOM, CAP, DEFAULT.');
|
|
31
31
|
}
|
|
32
32
|
return this.httpPostJson('cgi-bin/callback/check', {
|
|
@@ -49,10 +49,10 @@ class BroadcastingClient extends BaseClient_1.default {
|
|
|
49
49
|
*/
|
|
50
50
|
sendMessage(message, reception = null, attributes = {}) {
|
|
51
51
|
let msg = (new MessageBuilder_1.default).message(message).with(attributes).toAll();
|
|
52
|
-
if (Utils_1.isNumber(reception) && reception > 0) {
|
|
52
|
+
if ((0, Utils_1.isNumber)(reception) && reception > 0) {
|
|
53
53
|
msg.toTag(reception);
|
|
54
54
|
}
|
|
55
|
-
else if (Utils_1.isArray(reception)) {
|
|
55
|
+
else if ((0, Utils_1.isArray)(reception)) {
|
|
56
56
|
msg.toUsers(reception);
|
|
57
57
|
}
|
|
58
58
|
return this.send(msg.build());
|
|
@@ -50,7 +50,7 @@ class MessageBuilder {
|
|
|
50
50
|
if (!prepends) {
|
|
51
51
|
prepends = this._to;
|
|
52
52
|
}
|
|
53
|
-
let message = Utils_1.merge(Utils_1.merge(Utils_1.merge({}, prepends), content), this._attributes);
|
|
53
|
+
let message = (0, Utils_1.merge)((0, Utils_1.merge)((0, Utils_1.merge)({}, prepends), content), this._attributes);
|
|
54
54
|
return message;
|
|
55
55
|
}
|
|
56
56
|
buildForPreview(by, user) {
|
|
@@ -114,7 +114,7 @@ class Client extends BaseClient_1.default {
|
|
|
114
114
|
status: res.getStatusCode(),
|
|
115
115
|
headers: res.getHeaders(),
|
|
116
116
|
body: res.getContent(),
|
|
117
|
-
url: baseUrl + '?' + Utils_1.buildQueryString(params),
|
|
117
|
+
url: baseUrl + '?' + (0, Utils_1.buildQueryString)(params),
|
|
118
118
|
};
|
|
119
119
|
});
|
|
120
120
|
}
|
|
@@ -43,8 +43,8 @@ class JssdkClient extends JssdkClient_1.default {
|
|
|
43
43
|
}
|
|
44
44
|
attachExtension(cardId, extension = {}) {
|
|
45
45
|
return __awaiter(this, void 0, void 0, function* () {
|
|
46
|
-
let timestamp = Utils_1.getTimestamp();
|
|
47
|
-
let nonce_str = Utils_1.randomString(6);
|
|
46
|
+
let timestamp = (0, Utils_1.getTimestamp)();
|
|
47
|
+
let nonce_str = (0, Utils_1.randomString)(6);
|
|
48
48
|
let ticket = yield this.getTicket()['ticket'];
|
|
49
49
|
let ext = {
|
|
50
50
|
timestamp,
|
|
@@ -19,7 +19,7 @@ class MemberCardClient extends Client_1.default {
|
|
|
19
19
|
* @param settings 会员卡激活时的选项
|
|
20
20
|
*/
|
|
21
21
|
setActivationForm(cardId, settings) {
|
|
22
|
-
let params = Utils_1.merge({
|
|
22
|
+
let params = (0, Utils_1.merge)({
|
|
23
23
|
card_id: cardId,
|
|
24
24
|
}, settings);
|
|
25
25
|
return this.httpPostJson('card/membercard/activateuserform/set', params);
|
|
@@ -68,8 +68,8 @@ class CustomerServiceClient extends BaseClient_1.default {
|
|
|
68
68
|
}
|
|
69
69
|
messages(startTime, endTime, msgId = 1, number = 10000) {
|
|
70
70
|
return this.httpPostJson('customservice/msgrecord/getmsglist', {
|
|
71
|
-
starttime: Utils_1.getTimestamp(startTime),
|
|
72
|
-
endtime: Utils_1.getTimestamp(endTime),
|
|
71
|
+
starttime: (0, Utils_1.getTimestamp)(startTime),
|
|
72
|
+
endtime: (0, Utils_1.getTimestamp)(endTime),
|
|
73
73
|
msgid: msgId,
|
|
74
74
|
number: number,
|
|
75
75
|
});
|
|
@@ -193,7 +193,7 @@ class DataCubeClient extends BaseClient_1.default {
|
|
|
193
193
|
return this.query('datacube/getcardmembercarddetail', from, to, ext);
|
|
194
194
|
}
|
|
195
195
|
query(api, from, to, ext = {}) {
|
|
196
|
-
let params = Utils_1.merge({
|
|
196
|
+
let params = (0, Utils_1.merge)({
|
|
197
197
|
begin_date: from,
|
|
198
198
|
end_date: to,
|
|
199
199
|
}, ext);
|
|
@@ -70,10 +70,10 @@ class MaterialClient extends BaseClient_1.default {
|
|
|
70
70
|
if (!file) {
|
|
71
71
|
throw new Error(`File does not exist, or the file is unreadable: '${file}'`);
|
|
72
72
|
}
|
|
73
|
-
if (Utils_1.isString(file)) {
|
|
73
|
+
if ((0, Utils_1.isString)(file)) {
|
|
74
74
|
file = fs_1.default.createReadStream(file);
|
|
75
75
|
}
|
|
76
|
-
if (!Utils_1.inArray(type, this.allowTypes)) {
|
|
76
|
+
if (!(0, Utils_1.inArray)(type, this.allowTypes)) {
|
|
77
77
|
throw new Error(`Unsupported media type: '${type}'`);
|
|
78
78
|
}
|
|
79
79
|
let formData = new form_data_1.default();
|
|
@@ -19,7 +19,7 @@ class OCRClient extends BaseClient_1.default {
|
|
|
19
19
|
* @param type
|
|
20
20
|
*/
|
|
21
21
|
idCard(img_url, type = 'photo') {
|
|
22
|
-
if (!Utils_1.inArray(type, this.allowTypes, true)) {
|
|
22
|
+
if (!(0, Utils_1.inArray)(type, this.allowTypes, true)) {
|
|
23
23
|
throw new Error(`Unsupported type: '${type}'`);
|
|
24
24
|
}
|
|
25
25
|
return this.httpPost('cv/ocr/idcard', {
|
|
@@ -13,7 +13,7 @@ class SemanticClient extends BaseClient_1.default {
|
|
|
13
13
|
* @param optional 其它参数。属性:latitude,纬度,与城市二选一;longitude,经度,与城市二选一;city,城市,与经纬度二选一;region,区域名称,在城市存在的情况下可省;uid,用户唯一id(非开发者id);
|
|
14
14
|
*/
|
|
15
15
|
query(keyword, categories, optional = {}) {
|
|
16
|
-
let params = Utils_1.merge({
|
|
16
|
+
let params = (0, Utils_1.merge)({
|
|
17
17
|
query: keyword,
|
|
18
18
|
category: categories,
|
|
19
19
|
appid: this.app.config.app_id,
|
|
@@ -82,9 +82,9 @@ class SubscribeMessageClient extends BaseClient_1.default {
|
|
|
82
82
|
return this.httpPostJson(this.API_SEND, params);
|
|
83
83
|
}
|
|
84
84
|
formatMessage(data) {
|
|
85
|
-
let params = Utils_1.merge(Utils_1.merge({}, this.message), data);
|
|
85
|
+
let params = (0, Utils_1.merge)((0, Utils_1.merge)({}, this.message), data);
|
|
86
86
|
for (let key in params) {
|
|
87
|
-
if (Utils_1.inArray(key, this.required) && !params[key]) {
|
|
87
|
+
if ((0, Utils_1.inArray)(key, this.required) && !params[key]) {
|
|
88
88
|
throw new Error(`Attribute "${key}" can not be empty!`);
|
|
89
89
|
}
|
|
90
90
|
}
|
|
@@ -95,12 +95,12 @@ class SubscribeMessageClient extends BaseClient_1.default {
|
|
|
95
95
|
let formatted = {}, value;
|
|
96
96
|
for (let key in data) {
|
|
97
97
|
value = {};
|
|
98
|
-
if (Utils_1.isArray(data[key]) && data[key].length == 2) {
|
|
98
|
+
if ((0, Utils_1.isArray)(data[key]) && data[key].length == 2) {
|
|
99
99
|
value = {
|
|
100
100
|
value: data[key][0],
|
|
101
101
|
};
|
|
102
102
|
}
|
|
103
|
-
else if (Utils_1.isObject(data[key]) && data[key]['value']) {
|
|
103
|
+
else if ((0, Utils_1.isObject)(data[key]) && data[key]['value']) {
|
|
104
104
|
value = data[key];
|
|
105
105
|
}
|
|
106
106
|
else {
|
|
@@ -79,9 +79,9 @@ class Client extends BaseClient_1.default {
|
|
|
79
79
|
return this.httpPostJson('cgi-bin/message/template/subscribe', params);
|
|
80
80
|
}
|
|
81
81
|
formatMessage(data) {
|
|
82
|
-
let params = Utils_1.merge(Utils_1.merge({}, this.message), data);
|
|
82
|
+
let params = (0, Utils_1.merge)((0, Utils_1.merge)({}, this.message), data);
|
|
83
83
|
for (let key in params) {
|
|
84
|
-
if (Utils_1.inArray(key, this.required) && !params[key]) {
|
|
84
|
+
if ((0, Utils_1.inArray)(key, this.required) && !params[key]) {
|
|
85
85
|
throw new Error(`Attribute "${key}" can not be empty!`);
|
|
86
86
|
}
|
|
87
87
|
}
|
|
@@ -92,13 +92,13 @@ class Client extends BaseClient_1.default {
|
|
|
92
92
|
let formatted = {}, value;
|
|
93
93
|
for (let key in data) {
|
|
94
94
|
value = {};
|
|
95
|
-
if (Utils_1.isArray(data[key]) && data[key].length == 2) {
|
|
95
|
+
if ((0, Utils_1.isArray)(data[key]) && data[key].length == 2) {
|
|
96
96
|
value = {
|
|
97
97
|
value: data[key][0],
|
|
98
98
|
color: data[key][1],
|
|
99
99
|
};
|
|
100
100
|
}
|
|
101
|
-
else if (Utils_1.isObject(data[key]) && data[key]['value']) {
|
|
101
|
+
else if ((0, Utils_1.isObject)(data[key]) && data[key]['value']) {
|
|
102
102
|
value = data[key];
|
|
103
103
|
}
|
|
104
104
|
else {
|