node-easywechat 2.8.0 → 2.9.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.
Files changed (142) hide show
  1. package/README.md +51 -4
  2. package/dist/BaseService/Jssdk/JssdkClient.js +5 -5
  3. package/dist/BaseService/Media/MediaClient.js +1 -1
  4. package/dist/Core/AES.d.ts +1 -1
  5. package/dist/Core/AES.js +4 -4
  6. package/dist/Core/BaseAccessToken.js +2 -2
  7. package/dist/Core/BaseApplication.js +4 -4
  8. package/dist/Core/BaseClient.js +2 -2
  9. package/dist/Core/Cache/FileCache.js +3 -3
  10. package/dist/Core/Encryptor.js +3 -3
  11. package/dist/Core/Http/Request.js +13 -13
  12. package/dist/Core/Http/StreamResponse.js +1 -1
  13. package/dist/Core/Messages/Media.js +2 -2
  14. package/dist/Core/Messages/Message.js +7 -7
  15. package/dist/Core/Mixins/HttpMixin.js +4 -4
  16. package/dist/Core/ServerGuard.d.ts +2 -2
  17. package/dist/Core/ServerGuard.js +5 -5
  18. package/dist/Core/Types.d.ts +34 -4
  19. package/dist/Core/Utils.js +18 -18
  20. package/dist/MicroMerchant/Application.js +1 -1
  21. package/dist/MicroMerchant/Base/MicroMerchantBase.js +6 -6
  22. package/dist/MicroMerchant/Certficates/CertficatesClient.js +1 -1
  23. package/dist/MicroMerchant/Core/BaseClient.js +8 -8
  24. package/dist/MicroMerchant/Media/MediaClient.js +1 -1
  25. package/dist/MicroMerchant/MerchantConfig/MerchantConfigClient.js +1 -1
  26. package/dist/MicroMerchant/Meterial/MeterialClient.js +4 -4
  27. package/dist/MicroMerchant/Withdraw/WithdrawClient.js +2 -2
  28. package/dist/MiniProgram/ActivityMessage/ActivityMessageClient.js +3 -3
  29. package/dist/MiniProgram/AppCode/AppCodeClient.js +2 -2
  30. package/dist/MiniProgram/Application.d.ts +16 -0
  31. package/dist/MiniProgram/Application.js +40 -0
  32. package/dist/MiniProgram/Base/MiniProgramBase.js +1 -1
  33. package/dist/MiniProgram/NearbyPoi/NearbyPoiClient.js +3 -3
  34. package/dist/MiniProgram/OpenData/OpenDataClient.js +2 -2
  35. package/dist/MiniProgram/RealtimeLog/RealtimeLogClient.js +1 -1
  36. package/dist/MiniProgram/Shop/AccoutClient.d.ts +25 -0
  37. package/dist/MiniProgram/Shop/AccoutClient.js +42 -0
  38. package/dist/MiniProgram/Shop/AftersaleClient.d.ts +22 -0
  39. package/dist/MiniProgram/Shop/AftersaleClient.js +35 -0
  40. package/dist/MiniProgram/Shop/BasicClient.d.ts +39 -0
  41. package/dist/MiniProgram/Shop/BasicClient.js +69 -0
  42. package/dist/MiniProgram/Shop/DeliveryClient.d.ts +20 -0
  43. package/dist/MiniProgram/Shop/DeliveryClient.js +32 -0
  44. package/dist/MiniProgram/Shop/OrderClient.d.ts +32 -0
  45. package/dist/MiniProgram/Shop/OrderClient.js +51 -0
  46. package/dist/MiniProgram/Shop/RegisterClient.d.ts +25 -0
  47. package/dist/MiniProgram/Shop/RegisterClient.js +43 -0
  48. package/dist/MiniProgram/Shop/SpuClient.d.ts +67 -0
  49. package/dist/MiniProgram/Shop/SpuClient.js +92 -0
  50. package/dist/MiniProgram/ShortLink/ShortLinkClient.d.ts +11 -0
  51. package/dist/MiniProgram/ShortLink/ShortLinkClient.js +23 -0
  52. package/dist/MiniProgram/SubscribeMessage/SubscribeMessageClient.js +5 -5
  53. package/dist/MiniProgram/UniformMessage/UniformMessageClient.js +3 -3
  54. package/dist/MiniProgram/UrlLink/UrlLinkClient.d.ts +6 -1
  55. package/dist/MiniProgram/UrlLink/UrlLinkClient.js +7 -2
  56. package/dist/OfficialAccount/Base/OfficialAccountBase.js +2 -2
  57. package/dist/OfficialAccount/Broadcasting/BroadcastingClient.js +2 -2
  58. package/dist/OfficialAccount/Broadcasting/MessageBuilder.js +1 -1
  59. package/dist/OfficialAccount/Card/Client.js +1 -1
  60. package/dist/OfficialAccount/Card/JssdkClient.js +2 -2
  61. package/dist/OfficialAccount/Card/MemberCardClient.js +1 -1
  62. package/dist/OfficialAccount/CustomerService/CustomerServiceClient.js +2 -2
  63. package/dist/OfficialAccount/CustomerService/Messenger.js +1 -1
  64. package/dist/OfficialAccount/DataCube/DataCubeClient.js +1 -1
  65. package/dist/OfficialAccount/Material/MaterialClient.js +2 -2
  66. package/dist/OfficialAccount/OCR/OCRClient.js +1 -1
  67. package/dist/OfficialAccount/Semantic/SemanticClient.js +1 -1
  68. package/dist/OfficialAccount/SubscribeMessage/SubscribeMessageClient.js +4 -4
  69. package/dist/OfficialAccount/TemplateMessage/TemplateMessageClient.js +4 -4
  70. package/dist/OpenPlatform/Application.js +8 -8
  71. package/dist/OpenPlatform/Authorizer/Auth/AccessToken.js +1 -1
  72. package/dist/OpenPlatform/Authorizer/OfficialAccount/Account/Client.js +1 -1
  73. package/dist/OpenWork/Application.d.ts +37 -0
  74. package/dist/OpenWork/Application.js +128 -0
  75. package/dist/OpenWork/Auth/ProviderAccessToken.d.ts +8 -0
  76. package/dist/OpenWork/Auth/ProviderAccessToken.js +33 -0
  77. package/dist/OpenWork/Auth/SuiteAccessToken.d.ts +8 -0
  78. package/dist/OpenWork/Auth/SuiteAccessToken.js +34 -0
  79. package/dist/OpenWork/Auth/SuiteTicket.d.ts +8 -0
  80. package/dist/OpenWork/Auth/SuiteTicket.js +40 -0
  81. package/dist/OpenWork/Corp/CorpClient.d.ts +72 -0
  82. package/dist/OpenWork/Corp/CorpClient.js +150 -0
  83. package/dist/OpenWork/MiniProgram/MiniProgramClient.d.ts +5 -0
  84. package/dist/OpenWork/MiniProgram/MiniProgramClient.js +18 -0
  85. package/dist/OpenWork/Provider/ProviderClient.d.ts +81 -0
  86. package/dist/OpenWork/Provider/ProviderClient.js +172 -0
  87. package/dist/OpenWork/Server/OpenWorkGuard.d.ts +13 -0
  88. package/dist/OpenWork/Server/OpenWorkGuard.js +51 -0
  89. package/dist/OpenWork/Work/Application.d.ts +5 -0
  90. package/dist/OpenWork/Work/Application.js +22 -0
  91. package/dist/OpenWork/Work/Auth/AccessToken.d.ts +12 -0
  92. package/dist/OpenWork/Work/Auth/AccessToken.js +44 -0
  93. package/dist/Payment/Application.js +4 -4
  94. package/dist/Payment/Bill/BillClient.js +2 -2
  95. package/dist/Payment/Core/BaseClient.js +8 -8
  96. package/dist/Payment/Jssdk/JssdkClient.js +14 -14
  97. package/dist/Payment/Merchant/MerchantClient.js +1 -1
  98. package/dist/Payment/Notify/Handler.js +5 -5
  99. package/dist/Payment/Notify/Refunded.js +1 -1
  100. package/dist/Payment/Notify/Scanned.js +2 -2
  101. package/dist/Payment/Order/OrderClient.js +1 -1
  102. package/dist/Payment/Redpack/RedpackClient.js +5 -5
  103. package/dist/Payment/Refund/RefundClient.js +3 -3
  104. package/dist/Payment/Sandbox/SandboxClient.js +1 -1
  105. package/dist/Payment/Transfer/TransferClient.js +1 -1
  106. package/dist/Work/Agent/AgentClient.js +1 -1
  107. package/dist/Work/Agent/WorkbenchClient.d.ts +24 -0
  108. package/dist/Work/Agent/WorkbenchClient.js +39 -0
  109. package/dist/Work/Application.d.ts +8 -0
  110. package/dist/Work/Application.js +20 -0
  111. package/dist/Work/Calendar/CalendarClient.js +1 -1
  112. package/dist/Work/Chat/ChatClient.js +1 -1
  113. package/dist/Work/CorpGroup/CorpGroupClient.d.ts +34 -0
  114. package/dist/Work/CorpGroup/CorpGroupClient.js +42 -0
  115. package/dist/Work/Department/DepartmentClient.js +1 -1
  116. package/dist/Work/ExternalContact/Client.d.ts +56 -0
  117. package/dist/Work/ExternalContact/Client.js +88 -0
  118. package/dist/Work/ExternalContact/ContactWayClient.d.ts +37 -0
  119. package/dist/Work/ExternalContact/ContactWayClient.js +51 -2
  120. package/dist/Work/ExternalContact/MessageClient.js +4 -4
  121. package/dist/Work/ExternalContact/MessageTemplateClient.js +3 -3
  122. package/dist/Work/ExternalContact/MomentClient.d.ts +56 -3
  123. package/dist/Work/ExternalContact/MomentClient.js +62 -3
  124. package/dist/Work/ExternalContact/StatisticsClient.d.ts +24 -0
  125. package/dist/Work/ExternalContact/StatisticsClient.js +35 -0
  126. package/dist/Work/Jssdk/JssdkClient.js +3 -3
  127. package/dist/Work/Kf/KfAccountClient.d.ts +41 -0
  128. package/dist/Work/Kf/KfAccountClient.js +71 -0
  129. package/dist/Work/Kf/KfMessageClient.d.ts +44 -0
  130. package/dist/Work/Kf/KfMessageClient.js +73 -0
  131. package/dist/Work/Kf/KfServicerClient.d.ts +26 -0
  132. package/dist/Work/Kf/KfServicerClient.js +47 -0
  133. package/dist/Work/Media/MediaClient.js +1 -1
  134. package/dist/Work/Message/Messenger.js +2 -2
  135. package/dist/Work/Schedule/ScheduleClient.js +1 -1
  136. package/dist/Work/Server/Guard.d.ts +1 -1
  137. package/dist/Work/User/UserClient.js +3 -3
  138. package/dist/index.d.ts +8 -2
  139. package/dist/index.js +9 -7
  140. package/node-easywechat.file_cache.easywechat.kernel.access_token.8a9684b45da7de42a06a70ba01a7005a.cache +1 -1
  141. package/node-easywechat.file_cache.easywechat.kernel.access_token.c3d06edaf326aad75d32f31348df787a.cache +1 -1
  142. package/package.json +11 -11
@@ -273,5 +273,93 @@ class ExternalContactClient extends BaseClient_1.default {
273
273
  markTags(data) {
274
274
  return this.httpPostJson('cgi-bin/externalcontact/mark_tag', data);
275
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
+ }
276
364
  }
277
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;
@@ -123,13 +123,13 @@ class MessageClient extends BaseClient_1.default {
123
123
  */
124
124
  sendWelcome(welcomeCode, msg) {
125
125
  let formattedMsg = this.formatMessage(msg);
126
- let params = Utils_1.merge(Utils_1.merge({}, formattedMsg), {
126
+ let params = (0, Utils_1.merge)((0, Utils_1.merge)({}, formattedMsg), {
127
127
  welcome_code: welcomeCode,
128
128
  });
129
129
  return this.httpPostJson('cgi-bin/externalcontact/send_welcome_msg', params);
130
130
  }
131
131
  formatMessage(data) {
132
- let params = Utils_1.merge({}, data);
132
+ let params = (0, Utils_1.merge)({}, data);
133
133
  if (params['text']) {
134
134
  params['text'] = this.formatFields(params['text'], this.textMessage);
135
135
  }
@@ -145,9 +145,9 @@ class MessageClient extends BaseClient_1.default {
145
145
  return params;
146
146
  }
147
147
  formatFields(data, defaults) {
148
- let params = Utils_1.merge(Utils_1.merge({}, defaults), data);
148
+ let params = (0, Utils_1.merge)((0, Utils_1.merge)({}, defaults), data);
149
149
  for (let key in params) {
150
- 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) {
151
151
  throw new Error(`Attribute "${key}" can not be empty!`);
152
152
  }
153
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];
@@ -1,8 +1,61 @@
1
1
  import BaseClient from '../../Core/BaseClient';
2
2
  export default class MomentClient extends BaseClient {
3
+ /**
4
+ * 创建发表任务
5
+ * @see https://work.weixin.qq.com/api/doc/90000/90135/95094#%E5%88%9B%E5%BB%BA%E5%8F%91%E8%A1%A8%E4%BB%BB%E5%8A%A1
6
+ * @param params
7
+ * @returns
8
+ */
9
+ createTask(params: object): Promise<any>;
10
+ /**
11
+ * 获取任务创建结果
12
+ * @see https://work.weixin.qq.com/api/doc/90000/90135/95094#%E8%8E%B7%E5%8F%96%E4%BB%BB%E5%8A%A1%E5%88%9B%E5%BB%BA%E7%BB%93%E6%9E%9C
13
+ * @param jobId
14
+ * @returns
15
+ */
16
+ getTask(jobId: string): Promise<any>;
17
+ /**
18
+ * 获取企业全部的发表列表
19
+ * @see https://open.work.weixin.qq.com/api/doc/90000/90135/93333#获取企业全部的发表列表
20
+ * @param params
21
+ * @returns
22
+ */
3
23
  list(params: object): Promise<any>;
4
- getTasks(momentId: string, cursor: string, limit: number): Promise<any>;
5
- getCustomers(momentId: string, userId: string, cursor: string, limit: number): Promise<any>;
6
- getSendResult(momentId: string, userId: string, cursor: string, limit: number): Promise<any>;
24
+ /**
25
+ * 获取客户朋友圈企业发表的列表
26
+ * @see https://open.work.weixin.qq.com/api/doc/90000/90135/93333#获取客户朋友圈企业发表的列表
27
+ * @param momentId
28
+ * @param cursor
29
+ * @param limit
30
+ * @returns
31
+ */
32
+ getTasks(momentId: string, cursor?: string, limit?: number): Promise<any>;
33
+ /**
34
+ * 获取客户朋友圈发表时选择的可见范围
35
+ * @see https://open.work.weixin.qq.com/api/doc/90000/90135/93333#获取客户朋友圈发表时选择的可见范围
36
+ * @param momentId
37
+ * @param userId
38
+ * @param cursor
39
+ * @param limit
40
+ * @returns
41
+ */
42
+ getCustomers(momentId: string, userId: string, cursor?: string, limit?: number): Promise<any>;
43
+ /**
44
+ * 获取客户朋友圈发表后的可见客户列表
45
+ * @see https://open.work.weixin.qq.com/api/doc/90000/90135/93333#获取客户朋友圈发表后的可见客户列表
46
+ * @param momentId
47
+ * @param userId
48
+ * @param cursor
49
+ * @param limit
50
+ * @returns
51
+ */
52
+ getSendResult(momentId: string, userId: string, cursor?: string, limit?: number): Promise<any>;
53
+ /**
54
+ * 获取客户朋友圈的互动数据
55
+ * @see https://open.work.weixin.qq.com/api/doc/90000/90135/93333#获取客户朋友圈的互动数据
56
+ * @param momentId
57
+ * @param userId
58
+ * @returns
59
+ */
7
60
  getComments(momentId: string, userId: string): Promise<any>;
8
61
  }
@@ -5,10 +5,44 @@ 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 MomentClient extends BaseClient_1.default {
8
+ /**
9
+ * 创建发表任务
10
+ * @see https://work.weixin.qq.com/api/doc/90000/90135/95094#%E5%88%9B%E5%BB%BA%E5%8F%91%E8%A1%A8%E4%BB%BB%E5%8A%A1
11
+ * @param params
12
+ * @returns
13
+ */
14
+ createTask(params) {
15
+ return this.httpPostJson('cgi-bin/externalcontact/add_moment_task', params);
16
+ }
17
+ /**
18
+ * 获取任务创建结果
19
+ * @see https://work.weixin.qq.com/api/doc/90000/90135/95094#%E8%8E%B7%E5%8F%96%E4%BB%BB%E5%8A%A1%E5%88%9B%E5%BB%BA%E7%BB%93%E6%9E%9C
20
+ * @param jobId
21
+ * @returns
22
+ */
23
+ getTask(jobId) {
24
+ return this.httpGet('cgi-bin/externalcontact/get_moment_task_result', {
25
+ jobid: jobId,
26
+ });
27
+ }
28
+ /**
29
+ * 获取企业全部的发表列表
30
+ * @see https://open.work.weixin.qq.com/api/doc/90000/90135/93333#获取企业全部的发表列表
31
+ * @param params
32
+ * @returns
33
+ */
8
34
  list(params) {
9
35
  return this.httpPostJson('cgi-bin/externalcontact/get_moment_list', params);
10
36
  }
11
- getTasks(momentId, cursor, limit) {
37
+ /**
38
+ * 获取客户朋友圈企业发表的列表
39
+ * @see https://open.work.weixin.qq.com/api/doc/90000/90135/93333#获取客户朋友圈企业发表的列表
40
+ * @param momentId
41
+ * @param cursor
42
+ * @param limit
43
+ * @returns
44
+ */
45
+ getTasks(momentId, cursor = '', limit = 500) {
12
46
  let params = {
13
47
  moment_id: momentId,
14
48
  cursor,
@@ -16,7 +50,16 @@ class MomentClient extends BaseClient_1.default {
16
50
  };
17
51
  return this.httpPostJson('cgi-bin/externalcontact/get_moment_task', params);
18
52
  }
19
- getCustomers(momentId, userId, cursor, limit) {
53
+ /**
54
+ * 获取客户朋友圈发表时选择的可见范围
55
+ * @see https://open.work.weixin.qq.com/api/doc/90000/90135/93333#获取客户朋友圈发表时选择的可见范围
56
+ * @param momentId
57
+ * @param userId
58
+ * @param cursor
59
+ * @param limit
60
+ * @returns
61
+ */
62
+ getCustomers(momentId, userId, cursor = '', limit = 500) {
20
63
  let params = {
21
64
  moment_id: momentId,
22
65
  userid: userId,
@@ -25,7 +68,16 @@ class MomentClient extends BaseClient_1.default {
25
68
  };
26
69
  return this.httpPostJson('cgi-bin/externalcontact/get_moment_customer_list', params);
27
70
  }
28
- getSendResult(momentId, userId, cursor, limit) {
71
+ /**
72
+ * 获取客户朋友圈发表后的可见客户列表
73
+ * @see https://open.work.weixin.qq.com/api/doc/90000/90135/93333#获取客户朋友圈发表后的可见客户列表
74
+ * @param momentId
75
+ * @param userId
76
+ * @param cursor
77
+ * @param limit
78
+ * @returns
79
+ */
80
+ getSendResult(momentId, userId, cursor = '', limit = 3000) {
29
81
  let params = {
30
82
  moment_id: momentId,
31
83
  userid: userId,
@@ -34,6 +86,13 @@ class MomentClient extends BaseClient_1.default {
34
86
  };
35
87
  return this.httpPostJson('cgi-bin/externalcontact/get_moment_send_result', params);
36
88
  }
89
+ /**
90
+ * 获取客户朋友圈的互动数据
91
+ * @see https://open.work.weixin.qq.com/api/doc/90000/90135/93333#获取客户朋友圈的互动数据
92
+ * @param momentId
93
+ * @param userId
94
+ * @returns
95
+ */
37
96
  getComments(momentId, userId) {
38
97
  let params = {
39
98
  moment_id: momentId,
@@ -1,4 +1,28 @@
1
1
  import BaseClient from '../../Core/BaseClient';
2
2
  export default class StatisticsClient extends BaseClient {
3
+ /**
4
+ * 获取「联系客户统计」数据
5
+ * @see https://work.weixin.qq.com/api/doc/90000/90135/92132
6
+ * @param userIds
7
+ * @param from
8
+ * @param to
9
+ * @returns
10
+ */
3
11
  userBehavior(userIds: string[], from: string, to: string): Promise<any>;
12
+ /**
13
+ * 获取「群聊数据统计」数据(按群主聚合的方式)
14
+ * @see https://developer.work.weixin.qq.com/document/path/92133#%E6%8C%89%E7%BE%A4%E4%B8%BB%E8%81%9A%E5%90%88%E7%9A%84%E6%96%B9%E5%BC%8F
15
+ * @param params
16
+ * @returns
17
+ */
18
+ groupChatStatistic(params: object): Promise<any>;
19
+ /**
20
+ * 获取「群聊数据统计」数据(按自然日聚合的方式)
21
+ * @see https://developer.work.weixin.qq.com/document/path/92133#%E6%8C%89%E8%87%AA%E7%84%B6%E6%97%A5%E8%81%9A%E5%90%88%E7%9A%84%E6%96%B9%E5%BC%8F
22
+ * @param dayBeginTime
23
+ * @param dayEndTime
24
+ * @param userIds
25
+ * @returns
26
+ */
27
+ groupChatStatisticGroupByDay(dayBeginTime: number, dayEndTime: number, userIds: string[]): Promise<any>;
4
28
  }
@@ -5,6 +5,14 @@ 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 StatisticsClient extends BaseClient_1.default {
8
+ /**
9
+ * 获取「联系客户统计」数据
10
+ * @see https://work.weixin.qq.com/api/doc/90000/90135/92132
11
+ * @param userIds
12
+ * @param from
13
+ * @param to
14
+ * @returns
15
+ */
8
16
  userBehavior(userIds, from, to) {
9
17
  let params = {
10
18
  userid: userIds,
@@ -13,5 +21,32 @@ class StatisticsClient extends BaseClient_1.default {
13
21
  };
14
22
  return this.httpPostJson('cgi-bin/externalcontact/get_user_behavior_data', params);
15
23
  }
24
+ /**
25
+ * 获取「群聊数据统计」数据(按群主聚合的方式)
26
+ * @see https://developer.work.weixin.qq.com/document/path/92133#%E6%8C%89%E7%BE%A4%E4%B8%BB%E8%81%9A%E5%90%88%E7%9A%84%E6%96%B9%E5%BC%8F
27
+ * @param params
28
+ * @returns
29
+ */
30
+ groupChatStatistic(params) {
31
+ return this.httpPostJson('cgi-bin/externalcontact/groupchat/statistic', params);
32
+ }
33
+ /**
34
+ * 获取「群聊数据统计」数据(按自然日聚合的方式)
35
+ * @see https://developer.work.weixin.qq.com/document/path/92133#%E6%8C%89%E8%87%AA%E7%84%B6%E6%97%A5%E8%81%9A%E5%90%88%E7%9A%84%E6%96%B9%E5%BC%8F
36
+ * @param dayBeginTime
37
+ * @param dayEndTime
38
+ * @param userIds
39
+ * @returns
40
+ */
41
+ groupChatStatisticGroupByDay(dayBeginTime, dayEndTime, userIds) {
42
+ let params = {
43
+ day_begin_time: dayBeginTime,
44
+ day_end_time: dayEndTime,
45
+ owner_filter: {
46
+ userid_list: userIds,
47
+ },
48
+ };
49
+ return this.httpPostJson('cgi-bin/externalcontact/groupchat/statistic_group_by_day', params);
50
+ }
16
51
  }
17
52
  exports.default = StatisticsClient;
@@ -29,7 +29,7 @@ class JssdkClient extends JssdkClient_1.default {
29
29
  }
30
30
  buildAgentConfig(jsApiList, agentId, debug = false, beta = false, json, openTagList = [], url = '') {
31
31
  return __awaiter(this, void 0, void 0, function* () {
32
- let config = Utils_1.merge({
32
+ let config = (0, Utils_1.merge)({
33
33
  debug,
34
34
  beta,
35
35
  jsApiList,
@@ -41,8 +41,8 @@ class JssdkClient extends JssdkClient_1.default {
41
41
  agentConfigSignature(agentId, url = '', nonce = '', timestamp = '') {
42
42
  return __awaiter(this, void 0, void 0, function* () {
43
43
  url = url || this.getUrl();
44
- nonce = nonce || Utils_1.randomString(10);
45
- timestamp = timestamp || Utils_1.getTimestamp() + '';
44
+ nonce = nonce || (0, Utils_1.randomString)(10);
45
+ timestamp = timestamp || (0, Utils_1.getTimestamp)() + '';
46
46
  let ticket = yield this.getAgentTicket(agentId);
47
47
  return {
48
48
  corpid: this.getAppId(),
@@ -0,0 +1,41 @@
1
+ import BaseClient from '../../Core/BaseClient';
2
+ export default class KfAccountClient extends BaseClient {
3
+ /**
4
+ * 添加客服帐号
5
+ * @see https://open.work.weixin.qq.com/api/doc/90000/90135/94662
6
+ * @param name
7
+ * @param mediaId
8
+ * @returns
9
+ */
10
+ add(name: string, mediaId: string): Promise<any>;
11
+ /**
12
+ * 修改客服帐号
13
+ * @see https://open.work.weixin.qq.com/api/doc/90000/90135/94664
14
+ * @param openKfId
15
+ * @param name
16
+ * @param mediaId
17
+ * @returns
18
+ */
19
+ update(openKfId: string, name: string, mediaId: string): Promise<any>;
20
+ /**
21
+ * 删除客服帐号
22
+ * @see https://open.work.weixin.qq.com/api/doc/90000/90135/94663
23
+ * @param openKfId
24
+ * @returns
25
+ */
26
+ del(openKfId: string): Promise<any>;
27
+ /**
28
+ * 获取客服帐号列表
29
+ * @see https://open.work.weixin.qq.com/api/doc/90000/90135/94661
30
+ * @returns
31
+ */
32
+ list(): Promise<any>;
33
+ /**
34
+ * 获取客服帐号链接
35
+ * @see https://open.work.weixin.qq.com/api/doc/90000/90135/94665
36
+ * @param openKfId
37
+ * @param scene
38
+ * @returns
39
+ */
40
+ getAccountLink(openKfId: string, scene: string): Promise<any>;
41
+ }
@@ -0,0 +1,71 @@
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 KfAccountClient extends BaseClient_1.default {
8
+ /**
9
+ * 添加客服帐号
10
+ * @see https://open.work.weixin.qq.com/api/doc/90000/90135/94662
11
+ * @param name
12
+ * @param mediaId
13
+ * @returns
14
+ */
15
+ add(name, mediaId) {
16
+ let params = {
17
+ name,
18
+ media_id: mediaId,
19
+ };
20
+ return this.httpPostJson('cgi-bin/kf/account/add', params);
21
+ }
22
+ /**
23
+ * 修改客服帐号
24
+ * @see https://open.work.weixin.qq.com/api/doc/90000/90135/94664
25
+ * @param openKfId
26
+ * @param name
27
+ * @param mediaId
28
+ * @returns
29
+ */
30
+ update(openKfId, name, mediaId) {
31
+ let params = {
32
+ open_kfid: openKfId,
33
+ name,
34
+ media_id: mediaId,
35
+ };
36
+ return this.httpPostJson('cgi-bin/kf/account/update', params);
37
+ }
38
+ /**
39
+ * 删除客服帐号
40
+ * @see https://open.work.weixin.qq.com/api/doc/90000/90135/94663
41
+ * @param openKfId
42
+ * @returns
43
+ */
44
+ del(openKfId) {
45
+ return this.httpPostJson('cgi-bin/kf/account/del', {
46
+ open_kfid: openKfId,
47
+ });
48
+ }
49
+ /**
50
+ * 获取客服帐号列表
51
+ * @see https://open.work.weixin.qq.com/api/doc/90000/90135/94661
52
+ * @returns
53
+ */
54
+ list() {
55
+ return this.httpGet('cgi-bin/kf/account/list');
56
+ }
57
+ /**
58
+ * 获取客服帐号链接
59
+ * @see https://open.work.weixin.qq.com/api/doc/90000/90135/94665
60
+ * @param openKfId
61
+ * @param scene
62
+ * @returns
63
+ */
64
+ getAccountLink(openKfId, scene) {
65
+ return this.httpPostJson('cgi-bin/kf/add_contact_way', {
66
+ open_kfid: openKfId,
67
+ scene,
68
+ });
69
+ }
70
+ }
71
+ exports.default = KfAccountClient;