node-easywechat 2.12.4 → 2.12.6
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/CHANGELOG.md +9 -0
- package/dist/OfficialAccount/CustomerService/CustomerServiceClient.d.ts +3 -1
- package/dist/OfficialAccount/CustomerService/Messenger.d.ts +1 -1
- package/dist/OfficialAccount/CustomerService/Messenger.js +1 -2
- package/dist/OfficialAccount/TemplateMessage/TemplateMessageClient.d.ts +13 -1
- package/dist/OfficialAccount/TemplateMessage/TemplateMessageClient.js +14 -1
- package/dist/OpenPlatform/Authorizer/MiniProgram/Application.d.ts +3 -0
- package/dist/OpenPlatform/Authorizer/MiniProgram/Application.js +8 -0
- package/dist/OpenPlatform/Authorizer/MiniProgram/Base/MiniProgramBaseClient.d.ts +8 -0
- package/dist/OpenPlatform/Authorizer/MiniProgram/Base/MiniProgramBaseClient.js +16 -0
- package/dist/Payment/Core/BaseClient.js +2 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import BaseClient from '../../Core/BaseClient';
|
|
2
|
+
import { Message } from '../../Core/Messages/Message';
|
|
3
|
+
import Messenger from './Messenger';
|
|
2
4
|
export default class CustomerServiceClient extends BaseClient {
|
|
3
5
|
list(): Promise<any>;
|
|
4
6
|
online(): Promise<any>;
|
|
@@ -7,7 +9,7 @@ export default class CustomerServiceClient extends BaseClient {
|
|
|
7
9
|
delete(account: string): Promise<any>;
|
|
8
10
|
invite(account: string, wechatId: string): Promise<any>;
|
|
9
11
|
setAvatar(account: string, path: string): Promise<any>;
|
|
10
|
-
message(message:
|
|
12
|
+
message(message: string | Message): Messenger;
|
|
11
13
|
send(message: object): Promise<any>;
|
|
12
14
|
showTypingStatusToUser(openid: string): Promise<any>;
|
|
13
15
|
hideTypingStatusToUser(openid: string): Promise<any>;
|
|
@@ -6,7 +6,7 @@ export default class Messenger {
|
|
|
6
6
|
protected account: string;
|
|
7
7
|
protected client: CustomerServiceClient;
|
|
8
8
|
constructor(client: CustomerServiceClient);
|
|
9
|
-
message(message:
|
|
9
|
+
message(message: string | Message): this;
|
|
10
10
|
by(account: string): this;
|
|
11
11
|
from(account: string): this;
|
|
12
12
|
to(openid: string): this;
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const Messages_1 = require("../../Core/Messages");
|
|
4
|
-
const Utils_1 = require("../../Core/Utils");
|
|
5
4
|
class Messenger {
|
|
6
5
|
constructor(client) {
|
|
7
6
|
this._message = null;
|
|
8
7
|
this.client = client;
|
|
9
8
|
}
|
|
10
9
|
message(message) {
|
|
11
|
-
if (
|
|
10
|
+
if (typeof message === 'string') {
|
|
12
11
|
message = new Messages_1.Text(message);
|
|
13
12
|
}
|
|
14
13
|
this._message = message;
|
|
@@ -5,35 +5,47 @@ export default class Client extends BaseClient {
|
|
|
5
5
|
protected required: Array<string>;
|
|
6
6
|
/**
|
|
7
7
|
* 修改账号所属行业
|
|
8
|
+
* @see https://developers.weixin.qq.com/doc/offiaccount/Message_Management/Template_Message_Interface.html#设置所属行业
|
|
8
9
|
* @param industry_id1 主行业id
|
|
9
10
|
* @param industry_id2 副行业id
|
|
10
11
|
*/
|
|
11
12
|
setIndustry(industry_id1: string, industry_id2: string): Promise<any>;
|
|
12
13
|
/**
|
|
13
14
|
* 获取支持的行业列表
|
|
15
|
+
* @see https://developers.weixin.qq.com/doc/offiaccount/Message_Management/Template_Message_Interface.html#获取设置的行业信息
|
|
14
16
|
*/
|
|
15
17
|
getIndustry(): Promise<any>;
|
|
16
18
|
/**
|
|
17
19
|
* 添加模板
|
|
20
|
+
* @see https://developers.weixin.qq.com/doc/offiaccount/Message_Management/Template_Message_Interface.html#获得模板ID
|
|
18
21
|
* @param template_id_short 模板库中模板的编号,有“TM**”和“OPENTMTM**”等形式
|
|
22
|
+
* @param keyword_name_list 选用的类目模板的关键词,按顺序传入,如果为空,或者关键词不在模板库中,会返回40246错误码
|
|
19
23
|
*/
|
|
20
|
-
addTemplate(template_id_short: string): Promise<any>;
|
|
24
|
+
addTemplate(template_id_short: string, keyword_name_list: string[]): Promise<any>;
|
|
21
25
|
/**
|
|
22
26
|
* 获取所有模板列表
|
|
27
|
+
* @see https://developers.weixin.qq.com/doc/offiaccount/Message_Management/Template_Message_Interface.html#获取模板列表
|
|
23
28
|
*/
|
|
24
29
|
getPrivateTemplates(): Promise<any>;
|
|
25
30
|
/**
|
|
26
31
|
* 删除模板
|
|
32
|
+
* @see https://developers.weixin.qq.com/doc/offiaccount/Message_Management/Template_Message_Interface.html#删除模板
|
|
27
33
|
* @param template_id 模版id
|
|
28
34
|
*/
|
|
29
35
|
deletePrivateTemplate(template_id: string): Promise<any>;
|
|
30
36
|
/**
|
|
31
37
|
* 发送模板消息
|
|
38
|
+
* @see https://developers.weixin.qq.com/doc/offiaccount/Message_Management/Template_Message_Interface.html#发送模板消息
|
|
32
39
|
* @param data 模版详情
|
|
33
40
|
*/
|
|
34
41
|
send(data: object): Promise<any>;
|
|
35
42
|
/**
|
|
36
43
|
* 发送一次性订阅消息
|
|
44
|
+
*
|
|
45
|
+
* (注意与订阅通知的区别,若是订阅通知请使用`subscribe_message`对应的API)
|
|
46
|
+
*
|
|
47
|
+
* @see [一次性订阅消息](https://developers.weixin.qq.com/doc/offiaccount/Message_Management/One-time_subscription_info.html)
|
|
48
|
+
* @see [订阅通知](https://developers.weixin.qq.com/doc/offiaccount/Subscription_Messages/intro.html)
|
|
37
49
|
* @param data 消息详情
|
|
38
50
|
*/
|
|
39
51
|
sendSubscription(data: object): Promise<any>;
|
|
@@ -23,6 +23,7 @@ class Client extends BaseClient_1.default {
|
|
|
23
23
|
}
|
|
24
24
|
/**
|
|
25
25
|
* 修改账号所属行业
|
|
26
|
+
* @see https://developers.weixin.qq.com/doc/offiaccount/Message_Management/Template_Message_Interface.html#设置所属行业
|
|
26
27
|
* @param industry_id1 主行业id
|
|
27
28
|
* @param industry_id2 副行业id
|
|
28
29
|
*/
|
|
@@ -34,27 +35,33 @@ class Client extends BaseClient_1.default {
|
|
|
34
35
|
}
|
|
35
36
|
/**
|
|
36
37
|
* 获取支持的行业列表
|
|
38
|
+
* @see https://developers.weixin.qq.com/doc/offiaccount/Message_Management/Template_Message_Interface.html#获取设置的行业信息
|
|
37
39
|
*/
|
|
38
40
|
getIndustry() {
|
|
39
41
|
return this.httpGet('cgi-bin/template/get_industry');
|
|
40
42
|
}
|
|
41
43
|
/**
|
|
42
44
|
* 添加模板
|
|
45
|
+
* @see https://developers.weixin.qq.com/doc/offiaccount/Message_Management/Template_Message_Interface.html#获得模板ID
|
|
43
46
|
* @param template_id_short 模板库中模板的编号,有“TM**”和“OPENTMTM**”等形式
|
|
47
|
+
* @param keyword_name_list 选用的类目模板的关键词,按顺序传入,如果为空,或者关键词不在模板库中,会返回40246错误码
|
|
44
48
|
*/
|
|
45
|
-
addTemplate(template_id_short) {
|
|
49
|
+
addTemplate(template_id_short, keyword_name_list) {
|
|
46
50
|
return this.httpPostJson('cgi-bin/template/api_add_template', {
|
|
47
51
|
template_id_short,
|
|
52
|
+
keyword_name_list,
|
|
48
53
|
});
|
|
49
54
|
}
|
|
50
55
|
/**
|
|
51
56
|
* 获取所有模板列表
|
|
57
|
+
* @see https://developers.weixin.qq.com/doc/offiaccount/Message_Management/Template_Message_Interface.html#获取模板列表
|
|
52
58
|
*/
|
|
53
59
|
getPrivateTemplates() {
|
|
54
60
|
return this.httpGet('cgi-bin/template/get_all_private_template');
|
|
55
61
|
}
|
|
56
62
|
/**
|
|
57
63
|
* 删除模板
|
|
64
|
+
* @see https://developers.weixin.qq.com/doc/offiaccount/Message_Management/Template_Message_Interface.html#删除模板
|
|
58
65
|
* @param template_id 模版id
|
|
59
66
|
*/
|
|
60
67
|
deletePrivateTemplate(template_id) {
|
|
@@ -64,6 +71,7 @@ class Client extends BaseClient_1.default {
|
|
|
64
71
|
}
|
|
65
72
|
/**
|
|
66
73
|
* 发送模板消息
|
|
74
|
+
* @see https://developers.weixin.qq.com/doc/offiaccount/Message_Management/Template_Message_Interface.html#发送模板消息
|
|
67
75
|
* @param data 模版详情
|
|
68
76
|
*/
|
|
69
77
|
send(data) {
|
|
@@ -72,6 +80,11 @@ class Client extends BaseClient_1.default {
|
|
|
72
80
|
}
|
|
73
81
|
/**
|
|
74
82
|
* 发送一次性订阅消息
|
|
83
|
+
*
|
|
84
|
+
* (注意与订阅通知的区别,若是订阅通知请使用`subscribe_message`对应的API)
|
|
85
|
+
*
|
|
86
|
+
* @see [一次性订阅消息](https://developers.weixin.qq.com/doc/offiaccount/Message_Management/One-time_subscription_info.html)
|
|
87
|
+
* @see [订阅通知](https://developers.weixin.qq.com/doc/offiaccount/Subscription_Messages/intro.html)
|
|
75
88
|
* @param data 消息详情
|
|
76
89
|
*/
|
|
77
90
|
sendSubscription(data) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import BaseApplication from '../../../MiniProgram/Application';
|
|
2
|
+
import MiniProgramBaseClient from './Base/MiniProgramBaseClient';
|
|
2
3
|
import CodeClient from './Code/CodeClient';
|
|
3
4
|
import DomainClient from './Domain/DomainClient';
|
|
4
5
|
import MaterialClient from './Material/MaterialClient';
|
|
@@ -8,6 +9,7 @@ import AccountClient from './Account/AccountClient';
|
|
|
8
9
|
import SettingClient from './Setting/SettingClient';
|
|
9
10
|
import TesterClient from './Tester/TesterClient';
|
|
10
11
|
export default class MiniProgram extends BaseApplication {
|
|
12
|
+
base: MiniProgramBaseClient;
|
|
11
13
|
code: CodeClient;
|
|
12
14
|
domain: DomainClient;
|
|
13
15
|
material: MaterialClient;
|
|
@@ -18,4 +20,5 @@ export default class MiniProgram extends BaseApplication {
|
|
|
18
20
|
tester: TesterClient;
|
|
19
21
|
constructor(config?: Object, prepends?: Object, id?: String);
|
|
20
22
|
registerExtraProviders(): void;
|
|
23
|
+
getVersionInfo(): Promise<any>;
|
|
21
24
|
}
|
|
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const Application_1 = __importDefault(require("../../../MiniProgram/Application"));
|
|
7
|
+
const MiniProgramBaseClient_1 = __importDefault(require("./Base/MiniProgramBaseClient"));
|
|
7
8
|
const CodeClient_1 = __importDefault(require("./Code/CodeClient"));
|
|
8
9
|
const DomainClient_1 = __importDefault(require("./Domain/DomainClient"));
|
|
9
10
|
const MaterialClient_1 = __importDefault(require("./Material/MaterialClient"));
|
|
@@ -18,6 +19,9 @@ class MiniProgram extends Application_1.default {
|
|
|
18
19
|
this.registerExtraProviders();
|
|
19
20
|
}
|
|
20
21
|
registerExtraProviders() {
|
|
22
|
+
this.offsetSet('base', function (app) {
|
|
23
|
+
return new MiniProgramBaseClient_1.default(app);
|
|
24
|
+
});
|
|
21
25
|
this.offsetSet('code', function (app) {
|
|
22
26
|
return new CodeClient_1.default(app);
|
|
23
27
|
});
|
|
@@ -43,6 +47,10 @@ class MiniProgram extends Application_1.default {
|
|
|
43
47
|
return new TesterClient_1.default(app);
|
|
44
48
|
});
|
|
45
49
|
}
|
|
50
|
+
// map to `base` module
|
|
51
|
+
getVersionInfo() {
|
|
52
|
+
return this.base.getVersionInfo.apply(this.base, arguments);
|
|
53
|
+
}
|
|
46
54
|
}
|
|
47
55
|
exports.default = MiniProgram;
|
|
48
56
|
;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import BaseClient from '../../../../MiniProgram/Base/MiniProgramBase';
|
|
2
|
+
export default class MiniProgramBaseClient extends BaseClient {
|
|
3
|
+
/**
|
|
4
|
+
* 获取小程序版本信息
|
|
5
|
+
* @see https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/code/get_versioninfo.html
|
|
6
|
+
*/
|
|
7
|
+
getVersionInfo(): Promise<any>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
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 MiniProgramBase_1 = __importDefault(require("../../../../MiniProgram/Base/MiniProgramBase"));
|
|
7
|
+
class MiniProgramBaseClient extends MiniProgramBase_1.default {
|
|
8
|
+
/**
|
|
9
|
+
* 获取小程序版本信息
|
|
10
|
+
* @see https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/code/get_versioninfo.html
|
|
11
|
+
*/
|
|
12
|
+
getVersionInfo() {
|
|
13
|
+
return this.httpPostJson('wxa/getversioninfo');
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
exports.default = MiniProgramBaseClient;
|
|
@@ -33,10 +33,10 @@ class BaseClient {
|
|
|
33
33
|
nonce_str: (0, Utils_1.randomString)(32),
|
|
34
34
|
};
|
|
35
35
|
if (this.app.config.sub_mch_id) {
|
|
36
|
-
base['sub_mch_id'] =
|
|
36
|
+
base['sub_mch_id'] = this.app.config.sub_mch_id;
|
|
37
37
|
}
|
|
38
38
|
if (this.app.config.sub_appid) {
|
|
39
|
-
base['sub_appid'] =
|
|
39
|
+
base['sub_appid'] = this.app.config.sub_appid;
|
|
40
40
|
}
|
|
41
41
|
let localParams = (0, Utils_1.merge)((0, Utils_1.merge)(base, this.prepends()), params);
|
|
42
42
|
let secretKey = yield this.app.getKey(endpoint);
|