node-easywechat 2.7.2 → 2.8.0

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.
@@ -10,6 +10,7 @@ import CustomerServiceClient from '../OfficialAccount/CustomerService/CustomerSe
10
10
  import UniformMessageClient from './UniformMessage/UniformMessageClient';
11
11
  import ActivityMessageClient from './ActivityMessage/ActivityMessageClient';
12
12
  import OpenDataClient from './OpenData/OpenDataClient';
13
+ import PhoneNumberClient from './PhoneNumber/PhoneNumberClient';
13
14
  import PluginClient from './Plugin/PluginClient';
14
15
  import PluginDevClient from './Plugin/PluginDevClient';
15
16
  import MiniProgramBase from './Base/MiniProgramBase';
@@ -23,6 +24,7 @@ import SearchClient from './Search/SearchClient';
23
24
  import MediaClient from '../BaseService/Media/MediaClient';
24
25
  import ContentSecurityClient from '../BaseService/ContentSecurity/ContentSecurityClient';
25
26
  import { EasyWechatConfig } from '../Core/Types';
27
+ import UrlLinkClient from './UrlLink/UrlLinkClient';
26
28
  import UrlSchemeClient from './UrlScheme/UrlSchemeClient';
27
29
  import RiskControlClient from './RiskControl/RiskControlClient';
28
30
  import LiveClient from './Live/LiveClient';
@@ -40,6 +42,7 @@ export default class MiniProgram extends BaseApplication {
40
42
  uniform_message: UniformMessageClient;
41
43
  activity_message: ActivityMessageClient;
42
44
  open_data: OpenDataClient;
45
+ phone_number: PhoneNumberClient;
43
46
  plugin: PluginClient;
44
47
  plugin_dev: PluginDevClient;
45
48
  base: MiniProgramBase;
@@ -52,6 +55,7 @@ export default class MiniProgram extends BaseApplication {
52
55
  search: SearchClient;
53
56
  media: MediaClient;
54
57
  content_security: ContentSecurityClient;
58
+ url_link: UrlLinkClient;
55
59
  url_scheme: UrlSchemeClient;
56
60
  risk_control: RiskControlClient;
57
61
  live: LiveClient;
@@ -24,6 +24,7 @@ const CustomerServiceClient_1 = __importDefault(require("../OfficialAccount/Cust
24
24
  const UniformMessageClient_1 = __importDefault(require("./UniformMessage/UniformMessageClient"));
25
25
  const ActivityMessageClient_1 = __importDefault(require("./ActivityMessage/ActivityMessageClient"));
26
26
  const OpenDataClient_1 = __importDefault(require("./OpenData/OpenDataClient"));
27
+ const PhoneNumberClient_1 = __importDefault(require("./PhoneNumber/PhoneNumberClient"));
27
28
  const PluginClient_1 = __importDefault(require("./Plugin/PluginClient"));
28
29
  const PluginDevClient_1 = __importDefault(require("./Plugin/PluginDevClient"));
29
30
  const MiniProgramBase_1 = __importDefault(require("./Base/MiniProgramBase"));
@@ -36,6 +37,7 @@ const RealtimeLogClient_1 = __importDefault(require("./RealtimeLog/RealtimeLogCl
36
37
  const SearchClient_1 = __importDefault(require("./Search/SearchClient"));
37
38
  const MediaClient_1 = __importDefault(require("../BaseService/Media/MediaClient"));
38
39
  const ContentSecurityClient_1 = __importDefault(require("../BaseService/ContentSecurity/ContentSecurityClient"));
40
+ const UrlLinkClient_1 = __importDefault(require("./UrlLink/UrlLinkClient"));
39
41
  const UrlSchemeClient_1 = __importDefault(require("./UrlScheme/UrlSchemeClient"));
40
42
  const RiskControlClient_1 = __importDefault(require("./RiskControl/RiskControlClient"));
41
43
  const LiveClient_1 = __importDefault(require("./Live/LiveClient"));
@@ -55,6 +57,7 @@ class MiniProgram extends BaseApplication_1.default {
55
57
  this.uniform_message = null;
56
58
  this.activity_message = null;
57
59
  this.open_data = null;
60
+ this.phone_number = null;
58
61
  this.plugin = null;
59
62
  this.plugin_dev = null;
60
63
  this.base = null;
@@ -67,6 +70,7 @@ class MiniProgram extends BaseApplication_1.default {
67
70
  this.search = null;
68
71
  this.media = null;
69
72
  this.content_security = null;
73
+ this.url_link = null;
70
74
  this.url_scheme = null;
71
75
  this.risk_control = null;
72
76
  this.live = null;
@@ -126,6 +130,9 @@ class MiniProgram extends BaseApplication_1.default {
126
130
  this.offsetSet('open_data', function (app) {
127
131
  return new OpenDataClient_1.default(app);
128
132
  });
133
+ this.offsetSet('phone_number', function (app) {
134
+ return new PhoneNumberClient_1.default(app);
135
+ });
129
136
  this.offsetSet('plugin', function (app) {
130
137
  return new PluginClient_1.default(app);
131
138
  });
@@ -156,6 +163,9 @@ class MiniProgram extends BaseApplication_1.default {
156
163
  this.offsetSet('search', function (app) {
157
164
  return new SearchClient_1.default(app);
158
165
  });
166
+ this.offsetSet('url_link', function (app) {
167
+ return new UrlLinkClient_1.default(app);
168
+ });
159
169
  this.offsetSet('url_scheme', function (app) {
160
170
  return new UrlSchemeClient_1.default(app);
161
171
  });
@@ -0,0 +1,10 @@
1
+ import BaseClient from '../../Core/BaseClient';
2
+ export default class PhoneNumber extends BaseClient {
3
+ /**
4
+ * 获取用户手机号
5
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/phonenumber/phonenumber.getPhoneNumber.html
6
+ * @param code [前端获取code方法](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/getPhoneNumber.html)
7
+ * @returns
8
+ */
9
+ getUserPhoneNumber(code: string): Promise<any>;
10
+ }
@@ -0,0 +1,20 @@
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 PhoneNumber extends BaseClient_1.default {
8
+ /**
9
+ * 获取用户手机号
10
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/phonenumber/phonenumber.getPhoneNumber.html
11
+ * @param code [前端获取code方法](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/getPhoneNumber.html)
12
+ * @returns
13
+ */
14
+ getUserPhoneNumber(code) {
15
+ return this.httpPostJson('wxa/business/getuserphonenumber', {
16
+ code
17
+ });
18
+ }
19
+ }
20
+ exports.default = PhoneNumber;
@@ -10,4 +10,7 @@ export default class UnionClient extends BaseClient {
10
10
  getOrderInfo(orderIdList: string[]): Promise<any>;
11
11
  searchOrder(page?: number, startTimestamp?: string, endTimestamp?: string, commissionStatus?: string): Promise<any>;
12
12
  getFeaturedProducts(params: object): Promise<any>;
13
+ getTargetPlanInfo(params: object): Promise<any>;
14
+ applyJoinTargetPlan(params: object): Promise<any>;
15
+ getTargetPlanStatus(params: object): Promise<any>;
13
16
  }
@@ -56,5 +56,14 @@ class UnionClient extends BaseClient_1.default {
56
56
  getFeaturedProducts(params) {
57
57
  return this.httpGet('union/promoter/product/select', params);
58
58
  }
59
+ getTargetPlanInfo(params) {
60
+ return this.httpGet('union/promoter/target/plan_info', params);
61
+ }
62
+ applyJoinTargetPlan(params) {
63
+ return this.httpPostJson('union/promoter/target/apply_target', params);
64
+ }
65
+ getTargetPlanStatus(params) {
66
+ return this.httpGet('union/promoter/target/apply_status', params);
67
+ }
59
68
  }
60
69
  exports.default = UnionClient;
@@ -0,0 +1,4 @@
1
+ import BaseClient from '../../Core/BaseClient';
2
+ export default class UrlLink extends BaseClient {
3
+ generate(params?: object): Promise<any>;
4
+ }
@@ -0,0 +1,12 @@
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 UrlLink extends BaseClient_1.default {
8
+ generate(params = {}) {
9
+ return this.httpPostJson('wxa/generate_urllink', params);
10
+ }
11
+ }
12
+ exports.default = UrlLink;
@@ -23,4 +23,16 @@ export default class JssdkClient extends BaseClient {
23
23
  * @param json 是否返回json字符串,默认:true
24
24
  */
25
25
  shareAddressConfig(accessToken: string | AccessToken, json?: Boolean): Promise<any>;
26
+ /**
27
+ * 生成联系人配置
28
+ * @param params
29
+ * @param json 是否返回JSON字符串,默认:false
30
+ */
31
+ contractConfig(params: object, json?: Boolean): Promise<any>;
32
+ /**
33
+ * 生成小程序红包配置
34
+ * @param pkg
35
+ * @param json 是否返回JSON字符串,默认:false
36
+ */
37
+ miniprogramRedpackConfig(pkg: string, json?: Boolean): Promise<any>;
26
38
  }
@@ -86,5 +86,37 @@ class JssdkClient extends JssdkClient_1.default {
86
86
  return json ? JSON.stringify(params) : params;
87
87
  });
88
88
  }
89
+ /**
90
+ * 生成联系人配置
91
+ * @param params
92
+ * @param json 是否返回JSON字符串,默认:false
93
+ */
94
+ contractConfig(params, json = false) {
95
+ return __awaiter(this, void 0, void 0, function* () {
96
+ params['appid'] = this.app.config.app_id;
97
+ params['timestamp'] = Utils_1.getTimestamp() + '';
98
+ params['sign'] = Utils_1.makeSignature(params, this.app.config.key, 'md5');
99
+ return json ? JSON.stringify(params) : params;
100
+ });
101
+ }
102
+ /**
103
+ * 生成小程序红包配置
104
+ * @param pkg
105
+ * @param json 是否返回JSON字符串,默认:false
106
+ */
107
+ miniprogramRedpackConfig(pkg, json = false) {
108
+ return __awaiter(this, void 0, void 0, function* () {
109
+ let params = {
110
+ appId: this.app.config.app_id,
111
+ timeStamp: Utils_1.getTimestamp() + '',
112
+ nonceStr: Utils_1.randomString(16),
113
+ package: pkg,
114
+ };
115
+ params['paySign'] = Utils_1.makeSignature(params, '', 'md5');
116
+ params['signType'] = 'MD5';
117
+ delete params.appId;
118
+ return json ? JSON.stringify(params) : params;
119
+ });
120
+ }
89
121
  }
90
122
  exports.default = JssdkClient;
@@ -1,23 +1,166 @@
1
1
  import BaseClient from '../../Core/BaseClient';
2
2
  export default class ExternalContactClient extends BaseClient {
3
+ /**
4
+ * 获取配置了客户联系功能的成员列表
5
+ * @see https://work.weixin.qq.com/api/doc#90000/90135/91554
6
+ * @returns
7
+ */
3
8
  getFollowUsers(): Promise<any>;
9
+ /**
10
+ * 获取外部联系人列表
11
+ * @see https://work.weixin.qq.com/api/doc#90000/90135/91555
12
+ * @param userId
13
+ * @returns
14
+ */
4
15
  list(userId: string): Promise<any>;
16
+ /**
17
+ * 获取外部联系人详情
18
+ * @see https://work.weixin.qq.com/api/doc#90000/90135/91556
19
+ * @param externalUserId
20
+ * @returns
21
+ */
5
22
  get(externalUserId: string): Promise<any>;
6
- batchGet(userId: string, cursor?: string, limit?: number): Promise<any>;
7
- batchGetByUser(userId: string, cursor?: string, limit?: number): Promise<any>;
23
+ /**
24
+ * 批量获取客户详情
25
+ * @see https://work.weixin.qq.com/api/doc/90000/90135/92994
26
+ * @param userIdList
27
+ * @param cursor
28
+ * @param limit
29
+ * @returns
30
+ */
31
+ batchGet(userIdList: string[], cursor?: string, limit?: number): Promise<any>;
32
+ /**
33
+ * 批量获取外部联系人详情
34
+ * @see https://work.weixin.qq.com/api/doc/90001/90143/93010
35
+ * @param userIdList
36
+ * @param cursor
37
+ * @param limit
38
+ * @returns
39
+ */
40
+ batchGetByUser(userIdList: string[], cursor?: string, limit?: number): Promise<any>;
41
+ /**
42
+ * 修改客户备注信息
43
+ * @see https://work.weixin.qq.com/api/doc/90000/90135/92115
44
+ * @param data
45
+ * @returns
46
+ */
8
47
  remark(data: object): Promise<any>;
48
+ /**
49
+ * 获取离职成员的客户列表
50
+ * @see https://work.weixin.qq.com/api/doc/90000/90135/92124
51
+ * @param pageId
52
+ * @param pageSize
53
+ * @param cursor
54
+ * @returns
55
+ */
9
56
  getUnassigned(pageId?: number, pageSize?: number, cursor?: string): Promise<any>;
57
+ /**
58
+ * 离职成员的外部联系人再分配
59
+ * @see https://work.weixin.qq.com/api/doc#90000/90135/91564
60
+ * @param externalUserId
61
+ * @param handoverUserId
62
+ * @param takeoverUserId
63
+ * @param transferSuccessMessage
64
+ * @returns
65
+ */
10
66
  transfer(externalUserId: string, handoverUserId: string, takeoverUserId: string, transferSuccessMessage: string): Promise<any>;
67
+ /**
68
+ * 分配在职成员的客户
69
+ * @see https://work.weixin.qq.com/api/doc/90000/90135/92125
70
+ * @param externalUserId
71
+ * @param handoverUserId
72
+ * @param takeoverUserId
73
+ * @param transferSuccessMessage
74
+ * @returns
75
+ */
11
76
  transferCustomer(externalUserId: string, handoverUserId: string, takeoverUserId: string, transferSuccessMessage: string): Promise<any>;
77
+ /**
78
+ * 分配离职成员的客户
79
+ * @see https://work.weixin.qq.com/api/doc/90000/90135/94081
80
+ * @param externalUserId
81
+ * @param handoverUserId
82
+ * @param takeoverUserId
83
+ * @returns
84
+ */
12
85
  resignedTransferCustomer(externalUserId: string, handoverUserId: string, takeoverUserId: string): Promise<any>;
86
+ /**
87
+ * 离职成员的群再分配
88
+ * @see https://work.weixin.qq.com/api/doc/90000/90135/92127
89
+ * @param chatIds
90
+ * @param newOwner
91
+ * @returns
92
+ */
13
93
  transferGroupChat(chatIds: string[], newOwner: string): Promise<any>;
94
+ /**
95
+ * 查询客户接替状态
96
+ * @see https://work.weixin.qq.com/api/doc/90000/90135/94082
97
+ * @param handoverUserId
98
+ * @param takeoverUserId
99
+ * @param cursor
100
+ * @returns
101
+ */
14
102
  transferResult(handoverUserId: string, takeoverUserId: string, cursor?: string): Promise<any>;
103
+ /**
104
+ * 查询客户接替结果
105
+ * @see https://work.weixin.qq.com/api/doc/90001/90143/93009
106
+ * @param externalUserId
107
+ * @param handoverUserId
108
+ * @param takeoverUserId
109
+ * @returns
110
+ */
15
111
  getTransferResult(externalUserId: string, handoverUserId: string, takeoverUserId: string): Promise<any>;
112
+ /**
113
+ * 获取客户群列表
114
+ * @see https://work.weixin.qq.com/api/doc/90000/90135/92120
115
+ * @param data
116
+ * @returns
117
+ */
16
118
  getGroupChats(data: object): Promise<any>;
17
- getGroupChat(chatId: string): Promise<any>;
119
+ /**
120
+ * 获取客户群详情
121
+ * @see https://work.weixin.qq.com/api/doc/90000/90135/92122
122
+ * @param chatId
123
+ * @param needName
124
+ * @returns
125
+ */
126
+ getGroupChat(chatId: string, needName?: number): Promise<any>;
127
+ /**
128
+ * 获取企业标签库
129
+ * @see https://work.weixin.qq.com/api/doc/90000/90135/92117#获取企业标签库
130
+ * @param tagIds
131
+ * @param groupIds
132
+ * @returns
133
+ */
18
134
  getCorpTags(tagIds: string[], groupIds: string[]): Promise<any>;
135
+ /**
136
+ * 添加企业客户标签
137
+ * @see https://work.weixin.qq.com/api/doc/90000/90135/92117#添加企业客户标签
138
+ * @param data
139
+ * @returns
140
+ */
19
141
  addCorpTag(data: object): Promise<any>;
142
+ /**
143
+ * 编辑企业客户标签
144
+ * @see https://work.weixin.qq.com/api/doc/90000/90135/92117#编辑企业客户标签
145
+ * @param id
146
+ * @param name
147
+ * @param order
148
+ * @returns
149
+ */
20
150
  updateCorpTag(id: string, name?: string, order?: number): Promise<any>;
151
+ /**
152
+ * 删除企业客户标签
153
+ * @see https://work.weixin.qq.com/api/doc/90000/90135/92117#删除企业客户标签
154
+ * @param tagId
155
+ * @param groupId
156
+ * @returns
157
+ */
21
158
  deleteCorpTag(tagId: string[], groupId: string[]): Promise<any>;
159
+ /**
160
+ * 编辑客户企业标签
161
+ * @see https://work.weixin.qq.com/api/doc/90000/90135/92118
162
+ * @param data
163
+ * @returns
164
+ */
22
165
  markTags(data: object): Promise<any>;
23
166
  }
@@ -5,43 +5,105 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const BaseClient_1 = __importDefault(require("../../Core/BaseClient"));
7
7
  class ExternalContactClient extends BaseClient_1.default {
8
+ /**
9
+ * 获取配置了客户联系功能的成员列表
10
+ * @see https://work.weixin.qq.com/api/doc#90000/90135/91554
11
+ * @returns
12
+ */
8
13
  getFollowUsers() {
9
14
  return this.httpGet('cgi-bin/externalcontact/get_follow_user_list');
10
15
  }
16
+ /**
17
+ * 获取外部联系人列表
18
+ * @see https://work.weixin.qq.com/api/doc#90000/90135/91555
19
+ * @param userId
20
+ * @returns
21
+ */
11
22
  list(userId) {
12
23
  return this.httpGet('cgi-bin/externalcontact/list', {
13
24
  userid: userId,
14
25
  });
15
26
  }
27
+ /**
28
+ * 获取外部联系人详情
29
+ * @see https://work.weixin.qq.com/api/doc#90000/90135/91556
30
+ * @param externalUserId
31
+ * @returns
32
+ */
16
33
  get(externalUserId) {
17
34
  return this.httpGet('cgi-bin/externalcontact/get', {
18
35
  external_userid: externalUserId,
19
36
  });
20
37
  }
21
- batchGet(userId, cursor = '', limit = 1) {
38
+ /**
39
+ * 批量获取客户详情
40
+ * @see https://work.weixin.qq.com/api/doc/90000/90135/92994
41
+ * @param userIdList
42
+ * @param cursor
43
+ * @param limit
44
+ * @returns
45
+ */
46
+ batchGet(userIdList, cursor = '', limit = 1) {
22
47
  return this.httpPostJson('cgi-bin/externalcontact/batch/get_by_user', {
23
- userid: userId,
48
+ userid_list: userIdList,
24
49
  cursor,
25
50
  limit,
26
51
  });
27
52
  }
28
- batchGetByUser(userId, cursor = '', limit = 1) {
53
+ /**
54
+ * 批量获取外部联系人详情
55
+ * @see https://work.weixin.qq.com/api/doc/90001/90143/93010
56
+ * @param userIdList
57
+ * @param cursor
58
+ * @param limit
59
+ * @returns
60
+ */
61
+ batchGetByUser(userIdList, cursor = '', limit = 1) {
29
62
  return this.httpPostJson('cgi-bin/externalcontact/batch/get_by_user', {
30
- userid: userId,
63
+ userid_list: userIdList,
31
64
  cursor,
32
65
  limit,
33
66
  });
34
67
  }
68
+ /**
69
+ * 修改客户备注信息
70
+ * @see https://work.weixin.qq.com/api/doc/90000/90135/92115
71
+ * @param data
72
+ * @returns
73
+ */
35
74
  remark(data) {
36
75
  return this.httpPostJson('cgi-bin/externalcontact/remark', data);
37
76
  }
77
+ /**
78
+ * 获取离职成员的客户列表
79
+ * @see https://work.weixin.qq.com/api/doc/90000/90135/92124
80
+ * @param pageId
81
+ * @param pageSize
82
+ * @param cursor
83
+ * @returns
84
+ */
38
85
  getUnassigned(pageId = 0, pageSize = 1000, cursor = null) {
39
- return this.httpPostJson('cgi-bin/externalcontact/get_unassigned_list', {
86
+ let params = {
40
87
  page_id: pageId,
41
88
  page_size: pageSize,
42
89
  cursor,
90
+ };
91
+ Object.keys(params).map(key => {
92
+ if (params[key] === null || params[key] === undefined) {
93
+ delete params[key];
94
+ }
43
95
  });
96
+ return this.httpPostJson('cgi-bin/externalcontact/get_unassigned_list', params);
44
97
  }
98
+ /**
99
+ * 离职成员的外部联系人再分配
100
+ * @see https://work.weixin.qq.com/api/doc#90000/90135/91564
101
+ * @param externalUserId
102
+ * @param handoverUserId
103
+ * @param takeoverUserId
104
+ * @param transferSuccessMessage
105
+ * @returns
106
+ */
45
107
  transfer(externalUserId, handoverUserId, takeoverUserId, transferSuccessMessage) {
46
108
  return this.httpPostJson('cgi-bin/externalcontact/transfer', {
47
109
  external_userid: externalUserId,
@@ -50,6 +112,15 @@ class ExternalContactClient extends BaseClient_1.default {
50
112
  transfer_success_msg: transferSuccessMessage,
51
113
  });
52
114
  }
115
+ /**
116
+ * 分配在职成员的客户
117
+ * @see https://work.weixin.qq.com/api/doc/90000/90135/92125
118
+ * @param externalUserId
119
+ * @param handoverUserId
120
+ * @param takeoverUserId
121
+ * @param transferSuccessMessage
122
+ * @returns
123
+ */
53
124
  transferCustomer(externalUserId, handoverUserId, takeoverUserId, transferSuccessMessage) {
54
125
  return this.httpPostJson('cgi-bin/externalcontact/transfer_customer', {
55
126
  external_userid: externalUserId,
@@ -58,6 +129,14 @@ class ExternalContactClient extends BaseClient_1.default {
58
129
  transfer_success_msg: transferSuccessMessage,
59
130
  });
60
131
  }
132
+ /**
133
+ * 分配离职成员的客户
134
+ * @see https://work.weixin.qq.com/api/doc/90000/90135/94081
135
+ * @param externalUserId
136
+ * @param handoverUserId
137
+ * @param takeoverUserId
138
+ * @returns
139
+ */
61
140
  resignedTransferCustomer(externalUserId, handoverUserId, takeoverUserId) {
62
141
  return this.httpPostJson('cgi-bin/externalcontact/resigned/transfer_customer', {
63
142
  external_userid: externalUserId,
@@ -65,12 +144,27 @@ class ExternalContactClient extends BaseClient_1.default {
65
144
  takeover_userid: takeoverUserId,
66
145
  });
67
146
  }
147
+ /**
148
+ * 离职成员的群再分配
149
+ * @see https://work.weixin.qq.com/api/doc/90000/90135/92127
150
+ * @param chatIds
151
+ * @param newOwner
152
+ * @returns
153
+ */
68
154
  transferGroupChat(chatIds, newOwner) {
69
155
  return this.httpPostJson('cgi-bin/externalcontact/groupchat/transfer', {
70
156
  chat_id_list: chatIds,
71
157
  new_owner: newOwner,
72
158
  });
73
159
  }
160
+ /**
161
+ * 查询客户接替状态
162
+ * @see https://work.weixin.qq.com/api/doc/90000/90135/94082
163
+ * @param handoverUserId
164
+ * @param takeoverUserId
165
+ * @param cursor
166
+ * @returns
167
+ */
74
168
  transferResult(handoverUserId, takeoverUserId, cursor = null) {
75
169
  return this.httpPostJson('cgi-bin/externalcontact/resigned/transfer_result', {
76
170
  handover_userid: handoverUserId,
@@ -78,6 +172,14 @@ class ExternalContactClient extends BaseClient_1.default {
78
172
  cursor,
79
173
  });
80
174
  }
175
+ /**
176
+ * 查询客户接替结果
177
+ * @see https://work.weixin.qq.com/api/doc/90001/90143/93009
178
+ * @param externalUserId
179
+ * @param handoverUserId
180
+ * @param takeoverUserId
181
+ * @returns
182
+ */
81
183
  getTransferResult(externalUserId, handoverUserId, takeoverUserId) {
82
184
  return this.httpPostJson('cgi-bin/externalcontact/get_transfer_result', {
83
185
  external_userid: externalUserId,
@@ -85,23 +187,58 @@ class ExternalContactClient extends BaseClient_1.default {
85
187
  takeover_userid: takeoverUserId,
86
188
  });
87
189
  }
190
+ /**
191
+ * 获取客户群列表
192
+ * @see https://work.weixin.qq.com/api/doc/90000/90135/92120
193
+ * @param data
194
+ * @returns
195
+ */
88
196
  getGroupChats(data) {
89
197
  return this.httpPostJson('cgi-bin/externalcontact/groupchat/list', data);
90
198
  }
91
- getGroupChat(chatId) {
199
+ /**
200
+ * 获取客户群详情
201
+ * @see https://work.weixin.qq.com/api/doc/90000/90135/92122
202
+ * @param chatId
203
+ * @param needName
204
+ * @returns
205
+ */
206
+ getGroupChat(chatId, needName = 0) {
92
207
  return this.httpPostJson('cgi-bin/externalcontact/groupchat/get', {
93
208
  chat_id: chatId,
209
+ need_name: needName,
94
210
  });
95
211
  }
212
+ /**
213
+ * 获取企业标签库
214
+ * @see https://work.weixin.qq.com/api/doc/90000/90135/92117#获取企业标签库
215
+ * @param tagIds
216
+ * @param groupIds
217
+ * @returns
218
+ */
96
219
  getCorpTags(tagIds, groupIds) {
97
220
  return this.httpPostJson('cgi-bin/externalcontact/get_corp_tag_list', {
98
221
  tag_id: tagIds,
99
222
  group_id: groupIds,
100
223
  });
101
224
  }
225
+ /**
226
+ * 添加企业客户标签
227
+ * @see https://work.weixin.qq.com/api/doc/90000/90135/92117#添加企业客户标签
228
+ * @param data
229
+ * @returns
230
+ */
102
231
  addCorpTag(data) {
103
232
  return this.httpPostJson('cgi-bin/externalcontact/add_corp_tag', data);
104
233
  }
234
+ /**
235
+ * 编辑企业客户标签
236
+ * @see https://work.weixin.qq.com/api/doc/90000/90135/92117#编辑企业客户标签
237
+ * @param id
238
+ * @param name
239
+ * @param order
240
+ * @returns
241
+ */
105
242
  updateCorpTag(id, name = null, order = null) {
106
243
  let params = {
107
244
  id,
@@ -114,12 +251,25 @@ class ExternalContactClient extends BaseClient_1.default {
114
251
  }
115
252
  return this.httpPostJson('cgi-bin/externalcontact/edit_corp_tag', params);
116
253
  }
254
+ /**
255
+ * 删除企业客户标签
256
+ * @see https://work.weixin.qq.com/api/doc/90000/90135/92117#删除企业客户标签
257
+ * @param tagId
258
+ * @param groupId
259
+ * @returns
260
+ */
117
261
  deleteCorpTag(tagId, groupId) {
118
262
  return this.httpPostJson('cgi-bin/externalcontact/del_corp_tag', {
119
263
  tag_id: tagId,
120
264
  group_id: groupId,
121
265
  });
122
266
  }
267
+ /**
268
+ * 编辑客户企业标签
269
+ * @see https://work.weixin.qq.com/api/doc/90000/90135/92118
270
+ * @param data
271
+ * @returns
272
+ */
123
273
  markTags(data) {
124
274
  return this.httpPostJson('cgi-bin/externalcontact/mark_tag', data);
125
275
  }
@@ -5,8 +5,53 @@ export default class MessageClient extends BaseClient {
5
5
  protected imageMessage: object;
6
6
  protected linkMessage: object;
7
7
  protected miniprogramMessage: object;
8
+ /**
9
+ * 添加企业群发消息模板
10
+ * @param msg
11
+ * @returns
12
+ */
8
13
  submit(msg: object): Promise<any>;
14
+ /**
15
+ * 获取企业群发消息发送结果
16
+ * @param msgId
17
+ * @returns
18
+ */
9
19
  get(msgId: string): Promise<any>;
20
+ /**
21
+ * 获取群发记录列表
22
+ * @param chatType 群发任务的类型,默认为single,表示发送给客户,group表示发送给客户群
23
+ * @param startTime 群发任务记录开始时间
24
+ * @param endTime 群发任务记录结束时间
25
+ * @param creator 群发任务创建人企业账号id
26
+ * @param filterType 创建人类型。0:企业发表 1:个人发表 2:所有,包括个人创建以及企业创建,默认情况下为所有类型
27
+ * @param limit 返回的最大记录数,整型,最大值100,默认值50,超过最大值时取默认值
28
+ * @param cursor 用于分页查询的游标,字符串类型,由上一次调用返回,首次调用可不填
29
+ * @returns
30
+ */
31
+ getGroupmsgListV2(chatType: string, startTime: number, endTime: number, creator?: string, filterType?: number, limit?: number, cursor?: string): Promise<any>;
32
+ /**
33
+ * 获取群发成员发送任务列表
34
+ * @param msgId 群发消息的id,通过获取群发记录列表接口返回
35
+ * @param limit 返回的最大记录数,整型,最大值1000,默认值500,超过最大值时取默认值
36
+ * @param cursor 用于分页查询的游标,字符串类型,由上一次调用返回,首次调用可不填
37
+ * @returns
38
+ */
39
+ getGroupmsgTask(msgId: string, limit?: number, cursor?: string): Promise<any>;
40
+ /**
41
+ * 获取企业群发成员执行结果
42
+ * @param msgId 群发消息的id,通过获取群发记录列表接口返回
43
+ * @param userId 发送成员userid,通过获取群发成员发送任务列表接口返回
44
+ * @param limit 返回的最大记录数,整型,最大值1000,默认值500,超过最大值时取默认值
45
+ * @param cursor 用于分页查询的游标,字符串类型,由上一次调用返回,首次调用可不填
46
+ * @returns
47
+ */
48
+ getGroupmsgSendResult(msgId: string, userId: string, limit?: number, cursor?: string): Promise<any>;
49
+ /**
50
+ * 发送新客户欢迎语
51
+ * @param welcomeCode
52
+ * @param msg
53
+ * @returns
54
+ */
10
55
  sendWelcome(welcomeCode: string, msg: object): Promise<any>;
11
56
  protected formatMessage(data: object): object;
12
57
  protected formatFields(data: object, defaults: object): object;
@@ -26,15 +26,101 @@ class MessageClient extends BaseClient_1.default {
26
26
  page: '',
27
27
  };
28
28
  }
29
+ /**
30
+ * 添加企业群发消息模板
31
+ * @param msg
32
+ * @returns
33
+ */
29
34
  submit(msg) {
30
35
  let params = this.formatMessage(msg);
31
36
  return this.httpPostJson('cgi-bin/externalcontact/add_msg_template', params);
32
37
  }
38
+ /**
39
+ * 获取企业群发消息发送结果
40
+ * @param msgId
41
+ * @returns
42
+ */
33
43
  get(msgId) {
34
44
  return this.httpPostJson('cgi-bin/externalcontact/get_group_msg_result', {
35
45
  msgid: msgId,
36
46
  });
37
47
  }
48
+ /**
49
+ * 获取群发记录列表
50
+ * @param chatType 群发任务的类型,默认为single,表示发送给客户,group表示发送给客户群
51
+ * @param startTime 群发任务记录开始时间
52
+ * @param endTime 群发任务记录结束时间
53
+ * @param creator 群发任务创建人企业账号id
54
+ * @param filterType 创建人类型。0:企业发表 1:个人发表 2:所有,包括个人创建以及企业创建,默认情况下为所有类型
55
+ * @param limit 返回的最大记录数,整型,最大值100,默认值50,超过最大值时取默认值
56
+ * @param cursor 用于分页查询的游标,字符串类型,由上一次调用返回,首次调用可不填
57
+ * @returns
58
+ */
59
+ getGroupmsgListV2(chatType, startTime, endTime, creator = null, filterType = null, limit = null, cursor = null) {
60
+ let params = {
61
+ chat_type: chatType,
62
+ start_time: startTime,
63
+ end_time: endTime,
64
+ creator: creator,
65
+ filter_type: filterType,
66
+ limit: limit,
67
+ cursor: cursor,
68
+ };
69
+ Object.keys(params).map(key => {
70
+ if (params[key] === null || params[key] === undefined) {
71
+ delete params[key];
72
+ }
73
+ });
74
+ return this.httpPostJson('cgi-bin/externalcontact/get_groupmsg_list_v2', params);
75
+ }
76
+ /**
77
+ * 获取群发成员发送任务列表
78
+ * @param msgId 群发消息的id,通过获取群发记录列表接口返回
79
+ * @param limit 返回的最大记录数,整型,最大值1000,默认值500,超过最大值时取默认值
80
+ * @param cursor 用于分页查询的游标,字符串类型,由上一次调用返回,首次调用可不填
81
+ * @returns
82
+ */
83
+ getGroupmsgTask(msgId, limit = null, cursor = null) {
84
+ let params = {
85
+ msgid: msgId,
86
+ limit: limit,
87
+ cursor: cursor,
88
+ };
89
+ Object.keys(params).map(key => {
90
+ if (params[key] === null || params[key] === undefined) {
91
+ delete params[key];
92
+ }
93
+ });
94
+ return this.httpPostJson('cgi-bin/externalcontact/get_groupmsg_task', params);
95
+ }
96
+ /**
97
+ * 获取企业群发成员执行结果
98
+ * @param msgId 群发消息的id,通过获取群发记录列表接口返回
99
+ * @param userId 发送成员userid,通过获取群发成员发送任务列表接口返回
100
+ * @param limit 返回的最大记录数,整型,最大值1000,默认值500,超过最大值时取默认值
101
+ * @param cursor 用于分页查询的游标,字符串类型,由上一次调用返回,首次调用可不填
102
+ * @returns
103
+ */
104
+ getGroupmsgSendResult(msgId, userId, limit = null, cursor = null) {
105
+ let params = {
106
+ msgid: msgId,
107
+ userid: userId,
108
+ limit: limit,
109
+ cursor: cursor,
110
+ };
111
+ Object.keys(params).map(key => {
112
+ if (params[key] === null || params[key] === undefined) {
113
+ delete params[key];
114
+ }
115
+ });
116
+ return this.httpPostJson('cgi-bin/externalcontact/get_groupmsg_send_result', params);
117
+ }
118
+ /**
119
+ * 发送新客户欢迎语
120
+ * @param welcomeCode
121
+ * @param msg
122
+ * @returns
123
+ */
38
124
  sendWelcome(welcomeCode, msg) {
39
125
  let formattedMsg = this.formatMessage(msg);
40
126
  let params = Utils_1.merge(Utils_1.merge({}, formattedMsg), {
@@ -1 +1 @@
1
- {"data":{"errcode":0,"errmsg":"ok","access_token":"moke-token","expires_in":7200},"lifeTime":1633062831}
1
+ {"data":{"errcode":0,"errmsg":"ok","access_token":"moke-token","expires_in":7200},"lifeTime":1641409629}
@@ -1 +1 @@
1
- {"data":{"errcode":0,"errmsg":"ok"},"lifeTime":1633062831}
1
+ {"data":{"errcode":0,"errmsg":"ok"},"lifeTime":1641409628}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-easywechat",
3
- "version": "2.7.2",
3
+ "version": "2.8.0",
4
4
  "description": "EasyWechat SDK for Node.js (NOT OFFICIAL)",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {