node-easywechat 2.7.2 → 2.8.3

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 (123) 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 -7
  14. package/dist/Core/Mixins/HttpMixin.js +4 -4
  15. package/dist/Core/ServerGuard.js +5 -5
  16. package/dist/Core/Utils.js +18 -18
  17. package/dist/MicroMerchant/Application.js +1 -1
  18. package/dist/MicroMerchant/Base/MicroMerchantBase.js +6 -6
  19. package/dist/MicroMerchant/Certficates/CertficatesClient.js +1 -1
  20. package/dist/MicroMerchant/Core/BaseClient.js +8 -8
  21. package/dist/MicroMerchant/Media/MediaClient.js +1 -1
  22. package/dist/MicroMerchant/MerchantConfig/MerchantConfigClient.js +1 -1
  23. package/dist/MicroMerchant/Meterial/MeterialClient.js +4 -4
  24. package/dist/MicroMerchant/Withdraw/WithdrawClient.js +2 -2
  25. package/dist/MiniProgram/ActivityMessage/ActivityMessageClient.js +3 -3
  26. package/dist/MiniProgram/AppCode/AppCodeClient.js +2 -2
  27. package/dist/MiniProgram/Application.d.ts +20 -0
  28. package/dist/MiniProgram/Application.js +50 -0
  29. package/dist/MiniProgram/Base/MiniProgramBase.js +1 -1
  30. package/dist/MiniProgram/NearbyPoi/NearbyPoiClient.js +3 -3
  31. package/dist/MiniProgram/OpenData/OpenDataClient.js +2 -2
  32. package/dist/MiniProgram/PhoneNumber/PhoneNumberClient.d.ts +10 -0
  33. package/dist/MiniProgram/PhoneNumber/PhoneNumberClient.js +20 -0
  34. package/dist/MiniProgram/RealtimeLog/RealtimeLogClient.js +1 -1
  35. package/dist/MiniProgram/Shop/AccoutClient.d.ts +25 -0
  36. package/dist/MiniProgram/Shop/AccoutClient.js +42 -0
  37. package/dist/MiniProgram/Shop/AftersaleClient.d.ts +22 -0
  38. package/dist/MiniProgram/Shop/AftersaleClient.js +35 -0
  39. package/dist/MiniProgram/Shop/BasicClient.d.ts +39 -0
  40. package/dist/MiniProgram/Shop/BasicClient.js +69 -0
  41. package/dist/MiniProgram/Shop/DeliveryClient.d.ts +20 -0
  42. package/dist/MiniProgram/Shop/DeliveryClient.js +32 -0
  43. package/dist/MiniProgram/Shop/OrderClient.d.ts +32 -0
  44. package/dist/MiniProgram/Shop/OrderClient.js +51 -0
  45. package/dist/MiniProgram/Shop/RegisterClient.d.ts +25 -0
  46. package/dist/MiniProgram/Shop/RegisterClient.js +43 -0
  47. package/dist/MiniProgram/Shop/SpuClient.d.ts +67 -0
  48. package/dist/MiniProgram/Shop/SpuClient.js +92 -0
  49. package/dist/MiniProgram/ShortLink/ShortLinkClient.d.ts +11 -0
  50. package/dist/MiniProgram/ShortLink/ShortLinkClient.js +23 -0
  51. package/dist/MiniProgram/SubscribeMessage/SubscribeMessageClient.js +5 -5
  52. package/dist/MiniProgram/UniformMessage/UniformMessageClient.js +3 -3
  53. package/dist/MiniProgram/Union/UnionClient.d.ts +3 -0
  54. package/dist/MiniProgram/Union/UnionClient.js +9 -0
  55. package/dist/MiniProgram/UrlLink/UrlLinkClient.d.ts +9 -0
  56. package/dist/MiniProgram/UrlLink/UrlLinkClient.js +17 -0
  57. package/dist/OfficialAccount/Base/OfficialAccountBase.js +2 -2
  58. package/dist/OfficialAccount/Broadcasting/BroadcastingClient.js +2 -2
  59. package/dist/OfficialAccount/Broadcasting/MessageBuilder.js +1 -1
  60. package/dist/OfficialAccount/Card/Client.js +1 -1
  61. package/dist/OfficialAccount/Card/JssdkClient.js +2 -2
  62. package/dist/OfficialAccount/Card/MemberCardClient.js +1 -1
  63. package/dist/OfficialAccount/CustomerService/CustomerServiceClient.js +2 -2
  64. package/dist/OfficialAccount/CustomerService/Messenger.js +1 -1
  65. package/dist/OfficialAccount/DataCube/DataCubeClient.js +1 -1
  66. package/dist/OfficialAccount/Material/MaterialClient.js +2 -2
  67. package/dist/OfficialAccount/OCR/OCRClient.js +1 -1
  68. package/dist/OfficialAccount/Semantic/SemanticClient.js +1 -1
  69. package/dist/OfficialAccount/SubscribeMessage/SubscribeMessageClient.js +4 -4
  70. package/dist/OfficialAccount/TemplateMessage/TemplateMessageClient.js +4 -4
  71. package/dist/OpenPlatform/Application.js +7 -7
  72. package/dist/OpenPlatform/Authorizer/Auth/AccessToken.js +1 -1
  73. package/dist/OpenPlatform/Authorizer/OfficialAccount/Account/Client.js +1 -1
  74. package/dist/Payment/Application.js +4 -4
  75. package/dist/Payment/Bill/BillClient.js +2 -2
  76. package/dist/Payment/Core/BaseClient.js +8 -8
  77. package/dist/Payment/Jssdk/JssdkClient.d.ts +12 -0
  78. package/dist/Payment/Jssdk/JssdkClient.js +41 -9
  79. package/dist/Payment/Merchant/MerchantClient.js +1 -1
  80. package/dist/Payment/Notify/Handler.js +5 -5
  81. package/dist/Payment/Notify/Refunded.js +1 -1
  82. package/dist/Payment/Notify/Scanned.js +2 -2
  83. package/dist/Payment/Order/OrderClient.js +1 -1
  84. package/dist/Payment/Redpack/RedpackClient.js +5 -5
  85. package/dist/Payment/Refund/RefundClient.js +3 -3
  86. package/dist/Payment/Sandbox/SandboxClient.js +1 -1
  87. package/dist/Payment/Transfer/TransferClient.js +1 -1
  88. package/dist/Work/Agent/AgentClient.js +1 -1
  89. package/dist/Work/Agent/WorkbenchClient.d.ts +24 -0
  90. package/dist/Work/Agent/WorkbenchClient.js +39 -0
  91. package/dist/Work/Application.d.ts +8 -0
  92. package/dist/Work/Application.js +20 -0
  93. package/dist/Work/Calendar/CalendarClient.js +1 -1
  94. package/dist/Work/Chat/ChatClient.js +1 -1
  95. package/dist/Work/CorpGroup/CorpGroupClient.d.ts +34 -0
  96. package/dist/Work/CorpGroup/CorpGroupClient.js +42 -0
  97. package/dist/Work/Department/DepartmentClient.js +1 -1
  98. package/dist/Work/ExternalContact/Client.d.ts +202 -3
  99. package/dist/Work/ExternalContact/Client.js +244 -6
  100. package/dist/Work/ExternalContact/ContactWayClient.d.ts +37 -0
  101. package/dist/Work/ExternalContact/ContactWayClient.js +51 -2
  102. package/dist/Work/ExternalContact/MessageClient.d.ts +45 -0
  103. package/dist/Work/ExternalContact/MessageClient.js +90 -4
  104. package/dist/Work/ExternalContact/MessageTemplateClient.js +3 -3
  105. package/dist/Work/ExternalContact/MomentClient.d.ts +56 -3
  106. package/dist/Work/ExternalContact/MomentClient.js +62 -3
  107. package/dist/Work/ExternalContact/StatisticsClient.d.ts +24 -0
  108. package/dist/Work/ExternalContact/StatisticsClient.js +35 -0
  109. package/dist/Work/Jssdk/JssdkClient.js +3 -3
  110. package/dist/Work/Kf/KfAccountClient.d.ts +41 -0
  111. package/dist/Work/Kf/KfAccountClient.js +71 -0
  112. package/dist/Work/Kf/KfMessageClient.d.ts +44 -0
  113. package/dist/Work/Kf/KfMessageClient.js +73 -0
  114. package/dist/Work/Kf/KfServicerClient.d.ts +26 -0
  115. package/dist/Work/Kf/KfServicerClient.js +47 -0
  116. package/dist/Work/Media/MediaClient.js +1 -1
  117. package/dist/Work/Message/Messenger.js +2 -2
  118. package/dist/Work/Schedule/ScheduleClient.js +1 -1
  119. package/dist/Work/User/UserClient.js +3 -3
  120. package/dist/index.js +1 -1
  121. package/node-easywechat.file_cache.easywechat.kernel.access_token.8a9684b45da7de42a06a70ba01a7005a.cache +1 -1
  122. package/node-easywechat.file_cache.easywechat.kernel.access_token.c3d06edaf326aad75d32f31348df787a.cache +1 -1
  123. package/package.json +11 -11
@@ -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;
@@ -0,0 +1,44 @@
1
+ import BaseClient from '../../Core/BaseClient';
2
+ export default class KfMessageClient extends BaseClient {
3
+ /**
4
+ * 获取会话状态
5
+ * @see https://open.work.weixin.qq.com/api/doc/90000/90135/94669
6
+ * @param openKfId
7
+ * @param externalUserId
8
+ * @returns
9
+ */
10
+ state(openKfId: string, externalUserId: string): Promise<any>;
11
+ /**
12
+ * 变更会话状态
13
+ * @see https://open.work.weixin.qq.com/api/doc/90000/90135/94669
14
+ * @param openKfId
15
+ * @param externalUserId
16
+ * @param serviceState
17
+ * @param serviceUserId
18
+ * @returns
19
+ */
20
+ del(openKfId: string, externalUserId: string, serviceState: number, serviceUserId: string): Promise<any>;
21
+ /**
22
+ * 读取消息
23
+ * @see https://open.work.weixin.qq.com/api/doc/90000/90135/94670
24
+ * @param cursor
25
+ * @param token
26
+ * @param limit
27
+ * @returns
28
+ */
29
+ sync(cursor: string, token: string, limit: number): Promise<any>;
30
+ /**
31
+ * 发送消息
32
+ * @see https://open.work.weixin.qq.com/api/doc/90000/90135/94677
33
+ * @param params
34
+ * @returns
35
+ */
36
+ send(params: object): Promise<any>;
37
+ /**
38
+ * 发送事件响应消息
39
+ * @see https://open.work.weixin.qq.com/api/doc/90000/90135/94677
40
+ * @param params
41
+ * @returns
42
+ */
43
+ event(params: object): Promise<any>;
44
+ }
@@ -0,0 +1,73 @@
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 KfMessageClient extends BaseClient_1.default {
8
+ /**
9
+ * 获取会话状态
10
+ * @see https://open.work.weixin.qq.com/api/doc/90000/90135/94669
11
+ * @param openKfId
12
+ * @param externalUserId
13
+ * @returns
14
+ */
15
+ state(openKfId, externalUserId) {
16
+ let params = {
17
+ open_kfid: openKfId,
18
+ external_userid: externalUserId,
19
+ };
20
+ return this.httpPostJson('cgi-bin/kf/service_state/get', params);
21
+ }
22
+ /**
23
+ * 变更会话状态
24
+ * @see https://open.work.weixin.qq.com/api/doc/90000/90135/94669
25
+ * @param openKfId
26
+ * @param externalUserId
27
+ * @param serviceState
28
+ * @param serviceUserId
29
+ * @returns
30
+ */
31
+ del(openKfId, externalUserId, serviceState, serviceUserId) {
32
+ return this.httpPostJson('cgi-bin/kf/service_state/trans', {
33
+ open_kfid: openKfId,
34
+ external_userid: externalUserId,
35
+ service_state: serviceState,
36
+ servicer_userid: serviceUserId,
37
+ });
38
+ }
39
+ /**
40
+ * 读取消息
41
+ * @see https://open.work.weixin.qq.com/api/doc/90000/90135/94670
42
+ * @param cursor
43
+ * @param token
44
+ * @param limit
45
+ * @returns
46
+ */
47
+ sync(cursor, token, limit) {
48
+ return this.httpPostJson('cgi-bin/kf/sync_msg', {
49
+ cursor,
50
+ token,
51
+ limit,
52
+ });
53
+ }
54
+ /**
55
+ * 发送消息
56
+ * @see https://open.work.weixin.qq.com/api/doc/90000/90135/94677
57
+ * @param params
58
+ * @returns
59
+ */
60
+ send(params) {
61
+ return this.httpPostJson('cgi-bin/kf/send_msg', params);
62
+ }
63
+ /**
64
+ * 发送事件响应消息
65
+ * @see https://open.work.weixin.qq.com/api/doc/90000/90135/94677
66
+ * @param params
67
+ * @returns
68
+ */
69
+ event(params) {
70
+ return this.httpPostJson('cgi-bin/kf/send_msg_on_event', params);
71
+ }
72
+ }
73
+ exports.default = KfMessageClient;
@@ -0,0 +1,26 @@
1
+ import BaseClient from '../../Core/BaseClient';
2
+ export default class KfServicerClient extends BaseClient {
3
+ /**
4
+ * 添加接待人员
5
+ * @see https://open.work.weixin.qq.com/api/doc/90000/90135/94646
6
+ * @param openKfId
7
+ * @param userIds
8
+ * @returns
9
+ */
10
+ add(openKfId: string, userIds: string[]): Promise<any>;
11
+ /**
12
+ * 删除接待人员
13
+ * @see https://open.work.weixin.qq.com/api/doc/90000/90135/94647
14
+ * @param openKfId
15
+ * @param userIds
16
+ * @returns
17
+ */
18
+ del(openKfId: string, userIds: string[]): Promise<any>;
19
+ /**
20
+ * 获取接待人员列表
21
+ * @see https://open.work.weixin.qq.com/api/doc/90000/90135/94645
22
+ * @param openKfId
23
+ * @returns
24
+ */
25
+ list(openKfId: string): Promise<any>;
26
+ }
@@ -0,0 +1,47 @@
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 KfServicerClient extends BaseClient_1.default {
8
+ /**
9
+ * 添加接待人员
10
+ * @see https://open.work.weixin.qq.com/api/doc/90000/90135/94646
11
+ * @param openKfId
12
+ * @param userIds
13
+ * @returns
14
+ */
15
+ add(openKfId, userIds) {
16
+ let params = {
17
+ open_kfid: openKfId,
18
+ media_id: userIds,
19
+ };
20
+ return this.httpPostJson('cgi-bin/kf/servicer/add', params);
21
+ }
22
+ /**
23
+ * 删除接待人员
24
+ * @see https://open.work.weixin.qq.com/api/doc/90000/90135/94647
25
+ * @param openKfId
26
+ * @param userIds
27
+ * @returns
28
+ */
29
+ del(openKfId, userIds) {
30
+ return this.httpPostJson('cgi-bin/kf/servicer/del', {
31
+ open_kfid: openKfId,
32
+ userid_list: userIds,
33
+ });
34
+ }
35
+ /**
36
+ * 获取接待人员列表
37
+ * @see https://open.work.weixin.qq.com/api/doc/90000/90135/94645
38
+ * @param openKfId
39
+ * @returns
40
+ */
41
+ list(openKfId) {
42
+ return this.httpGet('cgi-bin/kf/servicer/list', {
43
+ open_kfid: openKfId,
44
+ });
45
+ }
46
+ }
47
+ exports.default = KfServicerClient;
@@ -69,7 +69,7 @@ class MediaClient extends BaseClient_1.default {
69
69
  if (!file) {
70
70
  throw new Error(`File does not exist, or the file is unreadable: '${file}'`);
71
71
  }
72
- if (!Utils_1.inArray(type, this.allowTypes)) {
72
+ if (!(0, Utils_1.inArray)(type, this.allowTypes)) {
73
73
  throw new Error(`Unsupported media type: '${type}'`);
74
74
  }
75
75
  let files = {
@@ -32,7 +32,7 @@ class Messenger {
32
32
  return this;
33
33
  }
34
34
  setRecipients(ids, key) {
35
- if (Utils_1.isArray(ids)) {
35
+ if ((0, Utils_1.isArray)(ids)) {
36
36
  ids = ids.join('|');
37
37
  }
38
38
  this.to = {};
@@ -58,7 +58,7 @@ class Messenger {
58
58
  if (!this.agentId) {
59
59
  throw new Error('No agentid specified.');
60
60
  }
61
- let data = this.message.transformForJsonRequest(Utils_1.merge({
61
+ let data = this.message.transformForJsonRequest((0, Utils_1.merge)({
62
62
  agentid: this.agentId,
63
63
  safe: this.secretive ? 1 : 0,
64
64
  }, this.to));
@@ -13,7 +13,7 @@ class ScheduleClient extends BaseClient_1.default {
13
13
  }
14
14
  update(id, schedule) {
15
15
  return this.httpPostJson('cgi-bin/oa/schedule/update', {
16
- schedule: Utils_1.merge({
16
+ schedule: (0, Utils_1.merge)({
17
17
  schedule_id: id,
18
18
  }, schedule)
19
19
  });
@@ -10,12 +10,12 @@ class UserClient extends BaseClient_1.default {
10
10
  return this.httpPostJson('cgi-bin/user/create', data);
11
11
  }
12
12
  update(id, data) {
13
- return this.httpPostJson('cgi-bin/user/update', Utils_1.merge({
13
+ return this.httpPostJson('cgi-bin/user/update', (0, Utils_1.merge)({
14
14
  userid: id,
15
15
  }, data));
16
16
  }
17
17
  delete(userId) {
18
- if (Utils_1.isArray(userId)) {
18
+ if ((0, Utils_1.isArray)(userId)) {
19
19
  return this.batchDelete(userId);
20
20
  }
21
21
  return this.httpGet('cgi-bin/user/delete', {
@@ -69,7 +69,7 @@ class UserClient extends BaseClient_1.default {
69
69
  return this.httpPostJson('cgi-bin/batch/invite', params);
70
70
  }
71
71
  getInvitationQrCode(sizeType = 1) {
72
- if (Utils_1.inArray(sizeType, [1, 2, 3, 4])) {
72
+ if ((0, Utils_1.inArray)(sizeType, [1, 2, 3, 4])) {
73
73
  throw new Error('The sizeType must be 1, 2, 3, 4.');
74
74
  }
75
75
  return this.httpGet('cgi-bin/corp/get_join_qrcode', {
package/dist/index.js CHANGED
@@ -38,7 +38,7 @@ const StreamResponse_1 = __importDefault(require("./Core/Http/StreamResponse"));
38
38
  const Messages = __importStar(require("./Core/Messages"));
39
39
  function getInstance(service, config) {
40
40
  try {
41
- let s = Utils_1.strStudly(service);
41
+ let s = (0, Utils_1.strStudly)(service);
42
42
  let applicationClass = this[s];
43
43
  return new applicationClass(config);
44
44
  }
@@ -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":1642619272}
@@ -1 +1 @@
1
- {"data":{"errcode":0,"errmsg":"ok"},"lifeTime":1633062831}
1
+ {"data":{"errcode":0,"errmsg":"ok"},"lifeTime":1642619272}