@jiexiaoyin/wecom-api 0.0.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 (58) hide show
  1. package/README.md +228 -0
  2. package/config.example.json +7 -0
  3. package/config.js +76 -0
  4. package/docs/approval-templates.example.json +11 -0
  5. package/docs/nginx-mirror.md +193 -0
  6. package/openclaw.plugin.json +15 -0
  7. package/package.json +34 -0
  8. package/plugin.cjs +172 -0
  9. package/plugin.ts +136 -0
  10. package/skills/wecom-api/SKILL.md +40 -0
  11. package/skills/wecom-api/index.js +288 -0
  12. package/skills/wecom-api/openclaw.plugin.json +10 -0
  13. package/src/callback-helper.js +198 -0
  14. package/src/config.cjs +286 -0
  15. package/src/core/permission.js +479 -0
  16. package/src/crypto.js +130 -0
  17. package/src/index.js +199 -0
  18. package/src/modules/addressbook/index.js +413 -0
  19. package/src/modules/addressbook_cache/index.js +365 -0
  20. package/src/modules/advanced/index.js +159 -0
  21. package/src/modules/app/index.js +102 -0
  22. package/src/modules/approval/index.js +146 -0
  23. package/src/modules/auth/index.js +103 -0
  24. package/src/modules/callback/index.js +1180 -0
  25. package/src/modules/chain/index.js +193 -0
  26. package/src/modules/checkin/index.js +142 -0
  27. package/src/modules/checkin_rules/index.js +251 -0
  28. package/src/modules/contact/index.js +481 -0
  29. package/src/modules/contact_stats/index.js +349 -0
  30. package/src/modules/custom/index.js +140 -0
  31. package/src/modules/customer/index.js +51 -0
  32. package/src/modules/disk/index.js +245 -0
  33. package/src/modules/document/index.js +282 -0
  34. package/src/modules/hr/index.js +93 -0
  35. package/src/modules/intelligence/index.js +346 -0
  36. package/src/modules/kf/index.js +74 -0
  37. package/src/modules/live/index.js +122 -0
  38. package/src/modules/media/index.js +183 -0
  39. package/src/modules/meeting/index.js +665 -0
  40. package/src/modules/message/index.js +402 -0
  41. package/src/modules/messenger/index.js +208 -0
  42. package/src/modules/moments/index.js +161 -0
  43. package/src/modules/msgaudit/index.js +24 -0
  44. package/src/modules/notify/index.js +81 -0
  45. package/src/modules/oceanengine/index.js +199 -0
  46. package/src/modules/openchat/index.js +197 -0
  47. package/src/modules/phone/index.js +45 -0
  48. package/src/modules/room/index.js +178 -0
  49. package/src/modules/schedule/index.js +246 -0
  50. package/src/modules/school/index.js +199 -0
  51. package/src/modules/security/index.js +223 -0
  52. package/src/modules/sensitive/index.js +170 -0
  53. package/src/modules/thirdparty/index.js +145 -0
  54. package/src/sdk/index.js +269 -0
  55. package/src/utils/callback-helper.js +198 -0
  56. package/test/callback-crypto.test.js +55 -0
  57. package/test/crypto.test.js +85 -0
  58. package/test/permission.test.js +115 -0
@@ -0,0 +1,481 @@
1
+ /**
2
+ * 客户联系模块
3
+ * API 章节:十三 - 客户联系
4
+ * 包含:客户管理、客户标签、离职/在职继承、客户群、规则组、联系我等
5
+ */
6
+
7
+ const WeComSDK = require('../../sdk');
8
+
9
+ class Contact extends WeComSDK {
10
+ constructor(config) {
11
+ super(config);
12
+ }
13
+
14
+ // ========== 成员对外信息 ==========
15
+
16
+ /**
17
+ * 获取成员对外信息
18
+ * @param {string} userId 成员 userid
19
+ */
20
+ async getExternalUserInfo(userId) {
21
+ return this.post('/externalcontact/get_external_user_info', { userid: userId });
22
+ }
23
+
24
+ /**
25
+ * 设置成员对外信息
26
+ * @param {string} userId 成员 userid
27
+ * @param {object} externalCorpInfo 企业信息
28
+ * @param {object} externalName 对外名称
29
+ */
30
+ async setExternalUserInfo(userId, externalCorpInfo, externalName) {
31
+ return this.post('/externalcontact/set_external_user_info', {
32
+ userid: userId,
33
+ external_corp_info: externalCorpInfo,
34
+ external_name: externalName
35
+ });
36
+ }
37
+
38
+ // ========== 企业服务人员管理 ==========
39
+
40
+ /**
41
+ * 获取配置了客户联系功能的成员列表
42
+ */
43
+ async getCustomerContactUsers() {
44
+ return this.post('/externalcontact/get_customer_contact_list', {});
45
+ }
46
+
47
+ // ========== 客户管理 ==========
48
+
49
+ /**
50
+ * 获取客户列表
51
+ * @param {string} userId 成员 userid
52
+ * @param {string} cursor 分页游标
53
+ */
54
+ async getCustomerList(userId, cursor = '') {
55
+ return this.get('/externalcontact/list', { userid: userId, cursor });
56
+ }
57
+
58
+ /**
59
+ * 获取客户详情
60
+ * @param {string} userId 成员 userid
61
+ * @param {string} externalUserId 外部联系人 userid
62
+ */
63
+ async getCustomerDetail(userId, externalUserId) {
64
+ return this.get('/externalcontact/get', { userid: userId, external_userid: externalUserId });
65
+ }
66
+
67
+ /**
68
+ * 批量获取客户详情
69
+ * @param {string} userId 成员 userid
70
+ * @param {string[]} externalUserIds 外部联系人 userid 列表
71
+ */
72
+ async batchGetCustomers(userId, externalUserIds) {
73
+ return this.post('/externalcontact/batch_get_by_user', {
74
+ userid: userId,
75
+ external_userid: externalUserIds
76
+ });
77
+ }
78
+
79
+ /**
80
+ * 修改客户备注信息
81
+ * @param {string} userId 成员 userid
82
+ * @param {string} externalUserId 外部联系人 userid
83
+ * @param {object} params 备注参数
84
+ */
85
+ async updateCustomerRemark(userId, externalUserId, params = {}) {
86
+ const { remark, description, addRemark, mobile, corporateName, position } = params;
87
+ return this.post('/externalcontact/update_remark', {
88
+ userid: userId,
89
+ external_userid: externalUserId,
90
+ remark,
91
+ description,
92
+ add_remark: addRemark,
93
+ mobile,
94
+ corporate_name: corporateName,
95
+ position
96
+ });
97
+ }
98
+
99
+ // ========== 客户标签管理 ==========
100
+
101
+ /**
102
+ * 获取企业标签列表
103
+ */
104
+ async getCorpTags() {
105
+ return this.post('/externalcontact/get_corp_tag_list', {});
106
+ }
107
+
108
+ /**
109
+ * 添加企业标签
110
+ * @param {string} groupId 标签组id
111
+ * @param {string} tagName 标签名
112
+ * @param {string} groupName 标签组名称(新建组时使用)
113
+ */
114
+ async addCorpTag(groupId, tagName, groupName = '') {
115
+ return this.post('/externalcontact/add_corp_tag', {
116
+ group_id: groupId,
117
+ tag_name: tagName,
118
+ group_name: groupName
119
+ });
120
+ }
121
+
122
+ /**
123
+ * 编辑企业标签
124
+ * @param {string} tagId 标签id
125
+ * @param {string} tagName 新标签名
126
+ */
127
+ async updateCorpTag(tagId, tagName) {
128
+ return this.post('/externalcontact/edit_corp_tag', { id: tagId, name: tagName });
129
+ }
130
+
131
+ /**
132
+ * 删除企业标签
133
+ * @param {string} tagId 标签id
134
+ */
135
+ async deleteCorpTag(tagId) {
136
+ return this.post('/externalcontact/del_corp_tag', { tag_id: tagId });
137
+ }
138
+
139
+ /**
140
+ * 编辑客户企业标签
141
+ * @param {string} userId 成员 userid
142
+ * @param {string} externalUserId 外部联系人 userid
143
+ * @param {string[]} addTag 添加的标签
144
+ * @param {string[]} removeTag 删除的标签
145
+ */
146
+ async updateCustomerTags(userId, externalUserId, { addTag = [], removeTag = [] } = {}) {
147
+ return this.post('/externalcontact/mark_tag', {
148
+ userid: userId,
149
+ external_userid: externalUserId,
150
+ add_tag: addTag,
151
+ remove_tag: removeTag
152
+ });
153
+ }
154
+
155
+ // ========== 客户联系规则组管理 ==========
156
+
157
+ /**
158
+ * 获取客户联系规则组列表
159
+ */
160
+ async getContactRuleGroups() {
161
+ return this.post('/externalcontact/get_contact_rule_groups', {});
162
+ }
163
+
164
+ /**
165
+ * 获取客户联系规则组详情
166
+ * @param {string} ruleGroupId 规则组 ID
167
+ */
168
+ async getContactRuleGroupDetail(ruleGroupId) {
169
+ return this.post('/externalcontact/get_contact_rule_group_detail', { rule_group_id: ruleGroupId });
170
+ }
171
+
172
+ /**
173
+ * 创建客户联系规则组
174
+ * @param {object} ruleGroup 规则组配置
175
+ */
176
+ async createContactRuleGroup(ruleGroup) {
177
+ return this.post('/externalcontact/add_contact_rule_group', ruleGroup);
178
+ }
179
+
180
+ /**
181
+ * 更新客户联系规则组
182
+ * @param {string} ruleGroupId 规则组 ID
183
+ * @param {object} ruleGroup 规则组配置
184
+ */
185
+ async updateContactRuleGroup(ruleGroupId, ruleGroup) {
186
+ return this.post('/externalcontact/update_contact_rule_group', {
187
+ rule_group_id: ruleGroupId,
188
+ ...ruleGroup
189
+ });
190
+ }
191
+
192
+ /**
193
+ * 删除客户联系规则组
194
+ * @param {string} ruleGroupId 规则组 ID
195
+ */
196
+ async deleteContactRuleGroup(ruleGroupId) {
197
+ return this.post('/externalcontact/del_contact_rule_group', { rule_group_id: ruleGroupId });
198
+ }
199
+
200
+ // ========== 离职继承 ==========
201
+
202
+ /**
203
+ * 获取待分配的离职成员列表
204
+ * @param {number} cursor 分页游标
205
+ * @param {number} size 每页数量
206
+ */
207
+ async getDimissionList(cursor = 0, size = 100) {
208
+ return this.post('/externalcontact/get_unassigned_list', { cursor, limit: size });
209
+ }
210
+
211
+ /**
212
+ * 分配离职成员的客户
213
+ * @param {string} externalUserId 外部联系人 userid
214
+ * @param {string} handoverUserId 交接人 userid
215
+ * @param {string} takeOverUserId 接替人 userid
216
+ */
217
+ async transferCustomer(externalUserId, handoverUserId, takeOverUserId) {
218
+ return this.post('/externalcontact/transfer_customer', {
219
+ external_userid: externalUserId,
220
+ handover_userid: handoverUserId,
221
+ takeover_userid: takeOverUserId
222
+ });
223
+ }
224
+
225
+ /**
226
+ * 批量分配离职成员的客户
227
+ * @param {string} handoverUserId 交接人 userid
228
+ * @param {string} takeOverUserId 接替人 userid
229
+ * @param {string[]} externalUserIds 外部联系人 userid 列表
230
+ */
231
+ async batchTransferCustomers(handoverUserId, takeOverUserId, externalUserIds) {
232
+ return this.post('/externalcontact/transfer_customer', {
233
+ handover_userid: handoverUserId,
234
+ takeover_userid: takeOverUserId,
235
+ external_userid: externalUserIds
236
+ });
237
+ }
238
+
239
+ /**
240
+ * 查询客户接替状态
241
+ * @param {string} externalUserId 外部联系人 userid
242
+ * @param {string} takeOverUserId 接替人 userid
243
+ */
244
+ async getTransferResult(externalUserId, takeOverUserId) {
245
+ return this.post('/externalcontact/get_transfer_result', {
246
+ external_userid: externalUserId,
247
+ takeover_userid: takeOverUserId
248
+ });
249
+ }
250
+
251
+ // ========== 在职继承 ==========
252
+
253
+ /**
254
+ * 分配在职成员的客户
255
+ * @param {string} externalUserId 外部联系人 userid
256
+ * @param {string} userId 原跟进人 userid
257
+ * @param {string} newUserId 新跟进人 userid
258
+ */
259
+ async transferOnJobCustomer(externalUserId, userId, newUserId) {
260
+ return this.post('/externalcontact/resigned/transfer_customer', {
261
+ external_userid: externalUserId,
262
+ handed_userid: userId,
263
+ new_handover_userid: newUserId
264
+ });
265
+ }
266
+
267
+ /**
268
+ * 分配在职成员的客户群
269
+ * @param {string} chatId 群聊 id
270
+ * @param {string} newOwner 新群主 userid
271
+ */
272
+ async transferOnJobGroupChat(chatId, newOwner) {
273
+ return this.post('/externalcontact/groupchat/transfer_customer', {
274
+ chat_id: chatId,
275
+ new_owner: newOwner
276
+ });
277
+ }
278
+
279
+ // ========== 客户群管理 ==========
280
+
281
+ /**
282
+ * 获取客户群列表
283
+ * @param {string} cursor 分页游标
284
+ * @param {number} size 每页数量
285
+ * @param {number} statusFilter 群状态过滤: 0-正常 1-跟进人离职 2-离职继承中 3-离职继承完成
286
+ */
287
+ async getGroupChatList(cursor = '', size = 100, statusFilter = 0) {
288
+ return this.post('/externalcontact/groupchat/list', {
289
+ cursor,
290
+ limit: size,
291
+ status_filter: statusFilter
292
+ });
293
+ }
294
+
295
+ /**
296
+ * 获取客户群详情
297
+ * @param {string} chatId 群聊 id
298
+ */
299
+ async getGroupChatDetail(chatId) {
300
+ return this.post('/externalcontact/groupchat/get', { chat_id: chatId });
301
+ }
302
+
303
+ /**
304
+ * 客户群 opengid 转换
305
+ * @param {string} opengid 开放群 ID
306
+ */
307
+ async convertOpenChatId(opengid) {
308
+ return this.post('/externalcontact/groupchat/opentochat', { opengid });
309
+ }
310
+
311
+ // ========== 联系我与客户入群方式 ==========
312
+
313
+ /**
314
+ * 获取联系我列表
315
+ */
316
+ async getContactWayList() {
317
+ return this.post('/externalcontact/get_contact_way_list', {});
318
+ }
319
+
320
+ /**
321
+ * 获取联系我详情
322
+ * @param {string} configId 联系方式配置 ID
323
+ */
324
+ async getContactWayDetail(configId) {
325
+ return this.post('/externalcontact/get_contact_way', { config_id: configId });
326
+ }
327
+
328
+ /**
329
+ * 添加联系我方式
330
+ * @param {object} params 联系方式参数
331
+ */
332
+ async addContactWay(params) {
333
+ const { type, scene, style, remark, skipVerify, state, userIds, departmentIds } = params;
334
+ return this.post('/externalcontact/add_contact_way', {
335
+ type,
336
+ scene,
337
+ style,
338
+ remark,
339
+ skip_verify: skipVerify,
340
+ state,
341
+ user: userIds,
342
+ party: departmentIds
343
+ });
344
+ }
345
+
346
+ /**
347
+ * 更新联系我方式
348
+ * @param {string} configId 联系方式配置 ID
349
+ * @param {object} params 更新参数
350
+ */
351
+ async updateContactWay(configId, params) {
352
+ const { style, remark, skipVerify, state, userIds, departmentIds } = params;
353
+ return this.post('/externalcontact/update_contact_way', {
354
+ config_id: configId,
355
+ style,
356
+ remark,
357
+ skip_verify: skipVerify,
358
+ state,
359
+ user: userIds,
360
+ party: departmentIds
361
+ });
362
+ }
363
+
364
+ /**
365
+ * 删除联系我方式
366
+ * @param {string} configId 联系方式配置 ID
367
+ */
368
+ async deleteContactWay(configId) {
369
+ return this.post('/externalcontact/del_contact_way', { config_id: configId });
370
+ }
371
+
372
+ // ========== 客户群「加入群聊」管理 ==========
373
+
374
+ /**
375
+ * 获取群聊邀请方式列表
376
+ */
377
+ async getJoinWayList() {
378
+ return this.post('/externalcontact/get_join_way_list', {});
379
+ }
380
+
381
+ /**
382
+ * 获取群聊邀请方式详情
383
+ * @param {string} configId 群聊邀请方式 ID
384
+ */
385
+ async getJoinWayDetail(configId) {
386
+ return this.post('/externalcontact/get_join_way', { config_id: configId });
387
+ }
388
+
389
+ /**
390
+ * 添加群聊邀请方式
391
+ * @param {object} params 邀请方式参数
392
+ */
393
+ async addJoinWay(params) {
394
+ const { chatId, scene, style, remark, skipVerify, state } = params;
395
+ return this.post('/externalcontact/add_join_way', {
396
+ chat_id: chatId,
397
+ scene,
398
+ style,
399
+ remark,
400
+ skip_verify: skipVerify,
401
+ state
402
+ });
403
+ }
404
+
405
+ /**
406
+ * 更新群聊邀请方式
407
+ * @param {string} configId 群聊邀请方式 ID
408
+ * @param {object} params 更新参数
409
+ */
410
+ async updateJoinWay(configId, params) {
411
+ const { style, remark, skipVerify, state } = params;
412
+ return this.post('/externalcontact/update_join_way', {
413
+ config_id: configId,
414
+ style,
415
+ remark,
416
+ skip_verify: skipVerify,
417
+ state
418
+ });
419
+ }
420
+
421
+ /**
422
+ * 删除群聊邀请方式
423
+ * @param {string} configId 群聊邀请方式 ID
424
+ */
425
+ async deleteJoinWay(configId) {
426
+ return this.post('/externalcontact/del_join_way', { config_id: configId });
427
+ }
428
+
429
+ // ========== 商品图册 ==========
430
+
431
+ /**
432
+ * 获取商品图册列表
433
+ */
434
+ async getProductAlbumList() {
435
+ return this.post('/externalcontact/get_product_album_list', {});
436
+ }
437
+
438
+ /**
439
+ * 添加商品图册
440
+ * @param {object} product 商品信息
441
+ */
442
+ async addProductAlbum(product) {
443
+ return this.post('/externalcontact/add_product_album', product);
444
+ }
445
+
446
+ /**
447
+ * 编辑商品图册
448
+ * @param {string} productId 商品 ID
449
+ * @param {object} product 商品信息
450
+ */
451
+ async updateProductAlbum(productId, product) {
452
+ return this.post('/externalcontact/update_product_album', {
453
+ product_id: productId,
454
+ ...product
455
+ });
456
+ }
457
+
458
+ /**
459
+ * 删除商品图册
460
+ * @param {string} productId 商品 ID
461
+ */
462
+ async deleteProductAlbum(productId) {
463
+ return this.post('/externalcontact/del_product_album', { product_id: productId });
464
+ }
465
+
466
+ // ========== 已服务客户 ==========
467
+
468
+ /**
469
+ * 获取已服务的外部联系人
470
+ * @param {string} userId 成员 userid
471
+ * @param {string} cursor 分页游标
472
+ */
473
+ async getServedCustomers(userId, cursor = '') {
474
+ return this.post('/externalcontact/get_served_list', {
475
+ userid: userId,
476
+ cursor
477
+ });
478
+ }
479
+ }
480
+
481
+ module.exports = Contact;