node-easywechat 2.7.1 → 2.8.2

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.
Files changed (110) hide show
  1. package/dist/BaseService/Jssdk/JssdkClient.js +5 -5
  2. package/dist/BaseService/Media/MediaClient.js +1 -1
  3. package/dist/Core/AES.d.ts +1 -1
  4. package/dist/Core/AES.js +4 -4
  5. package/dist/Core/BaseAccessToken.js +2 -2
  6. package/dist/Core/BaseApplication.js +4 -4
  7. package/dist/Core/BaseClient.js +2 -2
  8. package/dist/Core/Cache/FileCache.js +3 -3
  9. package/dist/Core/Encryptor.js +3 -3
  10. package/dist/Core/Http/Request.js +11 -11
  11. package/dist/Core/Http/StreamResponse.js +1 -1
  12. package/dist/Core/Messages/Media.js +2 -2
  13. package/dist/Core/Messages/Message.js +7 -9
  14. package/dist/Core/Mixins/HttpMixin.js +4 -4
  15. package/dist/Core/ServerGuard.d.ts +1 -0
  16. package/dist/Core/ServerGuard.js +8 -5
  17. package/dist/Core/Utils.js +18 -18
  18. package/dist/MicroMerchant/Application.js +1 -1
  19. package/dist/MicroMerchant/Base/MicroMerchantBase.js +6 -6
  20. package/dist/MicroMerchant/Certficates/CertficatesClient.js +1 -1
  21. package/dist/MicroMerchant/Core/BaseClient.js +8 -8
  22. package/dist/MicroMerchant/Media/MediaClient.js +1 -1
  23. package/dist/MicroMerchant/MerchantConfig/MerchantConfigClient.js +1 -1
  24. package/dist/MicroMerchant/Meterial/MeterialClient.js +4 -4
  25. package/dist/MicroMerchant/Withdraw/WithdrawClient.js +2 -2
  26. package/dist/MiniProgram/ActivityMessage/ActivityMessageClient.js +3 -3
  27. package/dist/MiniProgram/AppCode/AppCodeClient.js +2 -2
  28. package/dist/MiniProgram/Application.d.ts +6 -0
  29. package/dist/MiniProgram/Application.js +15 -0
  30. package/dist/MiniProgram/Base/MiniProgramBase.js +1 -1
  31. package/dist/MiniProgram/NearbyPoi/NearbyPoiClient.js +3 -3
  32. package/dist/MiniProgram/OpenData/OpenDataClient.js +2 -2
  33. package/dist/MiniProgram/PhoneNumber/PhoneNumberClient.d.ts +10 -0
  34. package/dist/MiniProgram/PhoneNumber/PhoneNumberClient.js +20 -0
  35. package/dist/MiniProgram/RealtimeLog/RealtimeLogClient.js +1 -1
  36. package/dist/MiniProgram/ShortLink/ShortLinkClient.d.ts +11 -0
  37. package/dist/MiniProgram/ShortLink/ShortLinkClient.js +23 -0
  38. package/dist/MiniProgram/SubscribeMessage/SubscribeMessageClient.js +5 -5
  39. package/dist/MiniProgram/UniformMessage/UniformMessageClient.js +3 -3
  40. package/dist/MiniProgram/Union/UnionClient.d.ts +3 -0
  41. package/dist/MiniProgram/Union/UnionClient.js +9 -0
  42. package/dist/MiniProgram/UrlLink/UrlLinkClient.d.ts +9 -0
  43. package/dist/MiniProgram/UrlLink/UrlLinkClient.js +17 -0
  44. package/dist/OfficialAccount/Base/OfficialAccountBase.js +2 -2
  45. package/dist/OfficialAccount/Broadcasting/BroadcastingClient.js +2 -2
  46. package/dist/OfficialAccount/Broadcasting/MessageBuilder.js +1 -1
  47. package/dist/OfficialAccount/Card/Client.js +1 -1
  48. package/dist/OfficialAccount/Card/JssdkClient.js +2 -2
  49. package/dist/OfficialAccount/Card/MemberCardClient.js +1 -1
  50. package/dist/OfficialAccount/CustomerService/CustomerServiceClient.js +2 -2
  51. package/dist/OfficialAccount/CustomerService/Messenger.js +1 -1
  52. package/dist/OfficialAccount/DataCube/DataCubeClient.js +1 -1
  53. package/dist/OfficialAccount/Material/MaterialClient.js +2 -2
  54. package/dist/OfficialAccount/OCR/OCRClient.js +1 -1
  55. package/dist/OfficialAccount/Semantic/SemanticClient.js +1 -1
  56. package/dist/OfficialAccount/SubscribeMessage/SubscribeMessageClient.js +4 -4
  57. package/dist/OfficialAccount/TemplateMessage/TemplateMessageClient.js +4 -4
  58. package/dist/OpenPlatform/Application.js +7 -7
  59. package/dist/OpenPlatform/Authorizer/Auth/AccessToken.js +1 -1
  60. package/dist/OpenPlatform/Authorizer/OfficialAccount/Account/Client.js +1 -1
  61. package/dist/Payment/Application.js +4 -4
  62. package/dist/Payment/Bill/BillClient.js +2 -2
  63. package/dist/Payment/Core/BaseClient.js +8 -8
  64. package/dist/Payment/Jssdk/JssdkClient.d.ts +12 -0
  65. package/dist/Payment/Jssdk/JssdkClient.js +41 -9
  66. package/dist/Payment/Merchant/MerchantClient.js +1 -1
  67. package/dist/Payment/Notify/Handler.js +5 -5
  68. package/dist/Payment/Notify/Refunded.js +1 -1
  69. package/dist/Payment/Notify/Scanned.js +2 -2
  70. package/dist/Payment/Order/OrderClient.js +1 -1
  71. package/dist/Payment/Redpack/RedpackClient.js +5 -5
  72. package/dist/Payment/Refund/RefundClient.js +3 -3
  73. package/dist/Payment/Sandbox/SandboxClient.js +1 -1
  74. package/dist/Payment/Transfer/TransferClient.js +1 -1
  75. package/dist/Work/Agent/AgentClient.js +1 -1
  76. package/dist/Work/Agent/WorkbenchClient.d.ts +24 -0
  77. package/dist/Work/Agent/WorkbenchClient.js +39 -0
  78. package/dist/Work/Application.d.ts +8 -0
  79. package/dist/Work/Application.js +20 -0
  80. package/dist/Work/Calendar/CalendarClient.js +1 -1
  81. package/dist/Work/Chat/ChatClient.js +1 -1
  82. package/dist/Work/CorpGroup/CorpGroupClient.d.ts +34 -0
  83. package/dist/Work/CorpGroup/CorpGroupClient.js +42 -0
  84. package/dist/Work/Department/DepartmentClient.js +1 -1
  85. package/dist/Work/ExternalContact/Client.d.ts +202 -3
  86. package/dist/Work/ExternalContact/Client.js +244 -6
  87. package/dist/Work/ExternalContact/ContactWayClient.d.ts +37 -0
  88. package/dist/Work/ExternalContact/ContactWayClient.js +51 -2
  89. package/dist/Work/ExternalContact/MessageClient.d.ts +45 -0
  90. package/dist/Work/ExternalContact/MessageClient.js +90 -4
  91. package/dist/Work/ExternalContact/MessageTemplateClient.js +3 -3
  92. package/dist/Work/ExternalContact/MomentClient.d.ts +56 -3
  93. package/dist/Work/ExternalContact/MomentClient.js +62 -3
  94. package/dist/Work/ExternalContact/StatisticsClient.d.ts +24 -0
  95. package/dist/Work/ExternalContact/StatisticsClient.js +35 -0
  96. package/dist/Work/Jssdk/JssdkClient.js +3 -3
  97. package/dist/Work/Kf/KfAccountClient.d.ts +41 -0
  98. package/dist/Work/Kf/KfAccountClient.js +71 -0
  99. package/dist/Work/Kf/KfMessageClient.d.ts +44 -0
  100. package/dist/Work/Kf/KfMessageClient.js +73 -0
  101. package/dist/Work/Kf/KfServicerClient.d.ts +26 -0
  102. package/dist/Work/Kf/KfServicerClient.js +47 -0
  103. package/dist/Work/Media/MediaClient.js +1 -1
  104. package/dist/Work/Message/Messenger.js +2 -2
  105. package/dist/Work/Schedule/ScheduleClient.js +1 -1
  106. package/dist/Work/User/UserClient.js +3 -3
  107. package/dist/index.js +1 -1
  108. package/node-easywechat.file_cache.easywechat.kernel.access_token.8a9684b45da7de42a06a70ba01a7005a.cache +1 -1
  109. package/node-easywechat.file_cache.easywechat.kernel.access_token.c3d06edaf326aad75d32f31348df787a.cache +1 -1
  110. package/package.json +11 -11
@@ -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,14 +251,115 @@ 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
  }
276
+ /**
277
+ * 外部联系人unionid转换
278
+ * @see https://work.weixin.qq.com/api/doc/90001/90143/93274
279
+ * @param unionid 微信客户的unionid
280
+ * @param openid 微信客户的openid
281
+ * @returns
282
+ */
283
+ unionidToExternalUserid(unionid = null, openid = null) {
284
+ return this.httpPostJson('cgi-bin/externalcontact/unionid_to_external_userid', {
285
+ unionid,
286
+ openid,
287
+ });
288
+ }
289
+ /**
290
+ * 代开发应用external_userid转换
291
+ * @see https://work.weixin.qq.com/api/doc/90001/90143/95195
292
+ * @param unionid 微信客户的unionid
293
+ * @returns
294
+ */
295
+ toServiceExternalUserid(externalUserid) {
296
+ return this.httpPostJson('cgi-bin/externalcontact/to_service_external_userid', {
297
+ external_userid: externalUserid,
298
+ });
299
+ }
300
+ /**
301
+ * 转换external_userid
302
+ * @see https://open.work.weixin.qq.com/api/doc/90001/90143/95327#%E8%BD%AC%E6%8D%A2external_userid
303
+ * @param externalUserIds
304
+ * @returns
305
+ */
306
+ getNewExternalUserid(externalUserIds) {
307
+ return this.httpPostJson('cgi-bin/externalcontact/get_new_external_userid', {
308
+ external_userid_list: externalUserIds,
309
+ });
310
+ }
311
+ /**
312
+ * 设置迁移完成
313
+ * @see https://open.work.weixin.qq.com/api/doc/90001/90143/95327#%E8%AE%BE%E7%BD%AE%E8%BF%81%E7%A7%BB%E5%AE%8C%E6%88%90
314
+ * @param corpid
315
+ * @returns
316
+ */
317
+ finishExternalUseridMigration(corpid) {
318
+ return this.httpPostJson('cgi-bin/externalcontact/finish_external_userid_migration', {
319
+ corpid,
320
+ });
321
+ }
322
+ /**
323
+ * unionid查询external_userid
324
+ * @see https://open.work.weixin.qq.com/api/doc/90001/90143/95327#4.2%20unionid%E6%9F%A5%E8%AF%A2external_userid
325
+ * @param unionid
326
+ * @param openid
327
+ * @param corpid
328
+ * @returns
329
+ */
330
+ unionidToexternalUserid3rd(unionid, openid, corpid = '') {
331
+ return this.httpPostJson('cgi-bin/externalcontact/unionid_to_external_userid_3rd', {
332
+ unionid,
333
+ openid,
334
+ corpid,
335
+ });
336
+ }
337
+ /**
338
+ * 客户群opengid转换
339
+ * @see https://work.weixin.qq.com/api/doc/90000/90135/94822
340
+ * @param opengid
341
+ * @returns
342
+ */
343
+ opengidToChatid(opengid) {
344
+ return this.httpPostJson('cgi-bin/externalcontact/opengid_to_chatid', {
345
+ opengid,
346
+ });
347
+ }
348
+ /**
349
+ * 上传附件资源
350
+ * @see https://work.weixin.qq.com/api/doc/90000/90135/95098
351
+ * @param path
352
+ * @param mediaType
353
+ * @param attachmentType
354
+ * @returns
355
+ */
356
+ uploadAttachment(path, mediaType, attachmentType) {
357
+ return this.httpUpload('cgi-bin/media/upload_attachment', {
358
+ media: path
359
+ }, {}, {
360
+ media_type: mediaType,
361
+ attachment_type: attachmentType,
362
+ });
363
+ }
126
364
  }
127
365
  exports.default = ExternalContactClient;
@@ -1,7 +1,44 @@
1
1
  import BaseClient from '../../Core/BaseClient';
2
2
  export default class ContactWayClient extends BaseClient {
3
+ /**
4
+ * 配置客户联系「联系我」方式
5
+ * @see https://developer.work.weixin.qq.com/document/path/92572#%E9%85%8D%E7%BD%AE%E5%AE%A2%E6%88%B7%E8%81%94%E7%B3%BB%E3%80%8C%E8%81%94%E7%B3%BB%E6%88%91%E3%80%8D%E6%96%B9%E5%BC%8F
6
+ * @param type
7
+ * @param scene
8
+ * @param config
9
+ * @returns
10
+ */
3
11
  create(type: number, scene: number, config: object): Promise<any>;
12
+ /**
13
+ * 获取企业已配置的「联系我」方式
14
+ * @see https://developer.work.weixin.qq.com/document/path/92572#%E8%8E%B7%E5%8F%96%E4%BC%81%E4%B8%9A%E5%B7%B2%E9%85%8D%E7%BD%AE%E7%9A%84%E3%80%8C%E8%81%94%E7%B3%BB%E6%88%91%E3%80%8D%E6%96%B9%E5%BC%8F
15
+ * @param configId
16
+ * @returns
17
+ */
4
18
  get(configId: string): Promise<any>;
19
+ /**
20
+ * 更新企业已配置的「联系我」方式
21
+ * @see https://developer.work.weixin.qq.com/document/path/92572#%E6%9B%B4%E6%96%B0%E4%BC%81%E4%B8%9A%E5%B7%B2%E9%85%8D%E7%BD%AE%E7%9A%84%E3%80%8C%E8%81%94%E7%B3%BB%E6%88%91%E3%80%8D%E6%96%B9%E5%BC%8F
22
+ * @param configId
23
+ * @param config
24
+ * @returns
25
+ */
5
26
  update(configId: string, config: object): Promise<any>;
27
+ /**
28
+ * 删除企业已配置的「联系我」方式
29
+ * @see https://developer.work.weixin.qq.com/document/path/92572#%E5%88%A0%E9%99%A4%E4%BC%81%E4%B8%9A%E5%B7%B2%E9%85%8D%E7%BD%AE%E7%9A%84%E3%80%8C%E8%81%94%E7%B3%BB%E6%88%91%E3%80%8D%E6%96%B9%E5%BC%8F
30
+ * @param configId
31
+ * @returns
32
+ */
6
33
  delete(configId: string): Promise<any>;
34
+ /**
35
+ * 获取企业已配置的「联系我」列表
36
+ * @see https://developer.work.weixin.qq.com/document/path/92572#%E8%8E%B7%E5%8F%96%E4%BC%81%E4%B8%9A%E5%B7%B2%E9%85%8D%E7%BD%AE%E7%9A%84%E3%80%8C%E8%81%94%E7%B3%BB%E6%88%91%E3%80%8D%E5%88%97%E8%A1%A8
37
+ * @param cursor
38
+ * @param limit
39
+ * @param startTime
40
+ * @param endTime
41
+ * @returns
42
+ */
43
+ list(cursor?: string, limit?: number, startTime?: number, endTime?: number): Promise<any>;
7
44
  }
@@ -6,28 +6,77 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const BaseClient_1 = __importDefault(require("../../Core/BaseClient"));
7
7
  const Utils_1 = require("../../Core/Utils");
8
8
  class ContactWayClient extends BaseClient_1.default {
9
+ /**
10
+ * 配置客户联系「联系我」方式
11
+ * @see https://developer.work.weixin.qq.com/document/path/92572#%E9%85%8D%E7%BD%AE%E5%AE%A2%E6%88%B7%E8%81%94%E7%B3%BB%E3%80%8C%E8%81%94%E7%B3%BB%E6%88%91%E3%80%8D%E6%96%B9%E5%BC%8F
12
+ * @param type
13
+ * @param scene
14
+ * @param config
15
+ * @returns
16
+ */
9
17
  create(type, scene, config) {
10
- let params = Utils_1.merge({
18
+ let params = (0, Utils_1.merge)({
11
19
  type,
12
20
  scene,
13
21
  }, config);
14
22
  return this.httpPostJson('cgi-bin/externalcontact/add_contact_way', params);
15
23
  }
24
+ /**
25
+ * 获取企业已配置的「联系我」方式
26
+ * @see https://developer.work.weixin.qq.com/document/path/92572#%E8%8E%B7%E5%8F%96%E4%BC%81%E4%B8%9A%E5%B7%B2%E9%85%8D%E7%BD%AE%E7%9A%84%E3%80%8C%E8%81%94%E7%B3%BB%E6%88%91%E3%80%8D%E6%96%B9%E5%BC%8F
27
+ * @param configId
28
+ * @returns
29
+ */
16
30
  get(configId) {
17
31
  return this.httpGet('cgi-bin/externalcontact/get_contact_way', {
18
32
  config_id: configId,
19
33
  });
20
34
  }
35
+ /**
36
+ * 更新企业已配置的「联系我」方式
37
+ * @see https://developer.work.weixin.qq.com/document/path/92572#%E6%9B%B4%E6%96%B0%E4%BC%81%E4%B8%9A%E5%B7%B2%E9%85%8D%E7%BD%AE%E7%9A%84%E3%80%8C%E8%81%94%E7%B3%BB%E6%88%91%E3%80%8D%E6%96%B9%E5%BC%8F
38
+ * @param configId
39
+ * @param config
40
+ * @returns
41
+ */
21
42
  update(configId, config) {
22
- let params = Utils_1.merge({
43
+ let params = (0, Utils_1.merge)({
23
44
  config_id: configId,
24
45
  }, config);
25
46
  return this.httpPostJson('cgi-bin/externalcontact/update_contact_way', params);
26
47
  }
48
+ /**
49
+ * 删除企业已配置的「联系我」方式
50
+ * @see https://developer.work.weixin.qq.com/document/path/92572#%E5%88%A0%E9%99%A4%E4%BC%81%E4%B8%9A%E5%B7%B2%E9%85%8D%E7%BD%AE%E7%9A%84%E3%80%8C%E8%81%94%E7%B3%BB%E6%88%91%E3%80%8D%E6%96%B9%E5%BC%8F
51
+ * @param configId
52
+ * @returns
53
+ */
27
54
  delete(configId) {
28
55
  return this.httpGet('cgi-bin/externalcontact/del_contact_way', {
29
56
  config_id: configId,
30
57
  });
31
58
  }
59
+ /**
60
+ * 获取企业已配置的「联系我」列表
61
+ * @see https://developer.work.weixin.qq.com/document/path/92572#%E8%8E%B7%E5%8F%96%E4%BC%81%E4%B8%9A%E5%B7%B2%E9%85%8D%E7%BD%AE%E7%9A%84%E3%80%8C%E8%81%94%E7%B3%BB%E6%88%91%E3%80%8D%E5%88%97%E8%A1%A8
62
+ * @param cursor
63
+ * @param limit
64
+ * @param startTime
65
+ * @param endTime
66
+ * @returns
67
+ */
68
+ list(cursor = '', limit = 100, startTime = null, endTime = null) {
69
+ let params = {
70
+ cursor,
71
+ limit,
72
+ };
73
+ if (startTime) {
74
+ params['start_time'] = startTime;
75
+ }
76
+ if (endTime) {
77
+ params['end_time'] = endTime;
78
+ }
79
+ return this.httpPostJson('cgi-bin/externalcontact/list_contact_way', params);
80
+ }
32
81
  }
33
82
  exports.default = ContactWayClient;
@@ -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,24 +26,110 @@ 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
- let params = Utils_1.merge(Utils_1.merge({}, formattedMsg), {
126
+ let params = (0, Utils_1.merge)((0, Utils_1.merge)({}, formattedMsg), {
41
127
  welcome_code: welcomeCode,
42
128
  });
43
129
  return this.httpPostJson('cgi-bin/externalcontact/send_welcome_msg', params);
44
130
  }
45
131
  formatMessage(data) {
46
- let params = Utils_1.merge({}, data);
132
+ let params = (0, Utils_1.merge)({}, data);
47
133
  if (params['text']) {
48
134
  params['text'] = this.formatFields(params['text'], this.textMessage);
49
135
  }
@@ -59,9 +145,9 @@ class MessageClient extends BaseClient_1.default {
59
145
  return params;
60
146
  }
61
147
  formatFields(data, defaults) {
62
- let params = Utils_1.merge(Utils_1.merge({}, defaults), data);
148
+ let params = (0, Utils_1.merge)((0, Utils_1.merge)({}, defaults), data);
63
149
  for (let key in params) {
64
- if (Utils_1.inArray(key, this.required) && typeof params[key] == undefined && typeof defaults[key] == undefined) {
150
+ if ((0, Utils_1.inArray)(key, this.required) && typeof params[key] == undefined && typeof defaults[key] == undefined) {
65
151
  throw new Error(`Attribute "${key}" can not be empty!`);
66
152
  }
67
153
  params[key] = params[key] || defaults[key];
@@ -49,7 +49,7 @@ class MessageTemplateClient extends BaseClient_1.default {
49
49
  });
50
50
  }
51
51
  formatMessage(data) {
52
- let params = Utils_1.merge({}, data);
52
+ let params = (0, Utils_1.merge)({}, data);
53
53
  if (params['text']) {
54
54
  params['text'] = this.formatFields(params['text'], this.textMessage);
55
55
  }
@@ -65,9 +65,9 @@ class MessageTemplateClient extends BaseClient_1.default {
65
65
  return params;
66
66
  }
67
67
  formatFields(data, defaults) {
68
- let params = Utils_1.merge(Utils_1.merge({}, defaults), data);
68
+ let params = (0, Utils_1.merge)((0, Utils_1.merge)({}, defaults), data);
69
69
  for (let key in params) {
70
- if (Utils_1.inArray(key, this.required) && typeof params[key] == undefined && typeof defaults[key] == undefined) {
70
+ if ((0, Utils_1.inArray)(key, this.required) && typeof params[key] == undefined && typeof defaults[key] == undefined) {
71
71
  throw new Error(`Attribute "${key}" can not be empty!`);
72
72
  }
73
73
  params[key] = params[key] || defaults[key];