node-easywechat 2.10.2 → 2.11.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.
- package/CHANGELOG.md +7 -1
- package/dist/OpenWork/Application.d.ts +12 -0
- package/dist/OpenWork/Application.js +36 -0
- package/dist/OpenWork/Device/DeviceClient.d.ts +64 -0
- package/dist/OpenWork/Device/DeviceClient.js +119 -0
- package/dist/OpenWork/License/LicenseAccountClient.d.ts +71 -0
- package/dist/OpenWork/License/LicenseAccountClient.js +139 -0
- package/dist/OpenWork/License/LicenseAppClient.d.ts +13 -0
- package/dist/OpenWork/License/LicenseAppClient.js +27 -0
- package/dist/OpenWork/License/LicenseAutoActiveClient.d.ts +19 -0
- package/dist/OpenWork/License/LicenseAutoActiveClient.js +36 -0
- package/dist/OpenWork/License/LicenseOrderClient.d.ts +64 -0
- package/dist/OpenWork/License/LicenseOrderClient.js +124 -0
- package/dist/OpenWork/Media/MediaClient.d.ts +37 -0
- package/dist/OpenWork/Media/MediaClient.js +60 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
# CHANGELOG
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
## v2.
|
|
4
|
+
## v2.11.0 (2022-08-22)
|
|
5
5
|
|
|
6
|
+
- Feat: 企业微信开放平台新作接口调用许可相关接口
|
|
7
|
+
- Feat: 企业微信开放平台新作设备管理相关接口
|
|
8
|
+
|
|
9
|
+
## v2.10.2, origin/HEAD, origin/2.x (2022-05-25)
|
|
10
|
+
|
|
11
|
+
- Fix: 生成xml报文时,移除xml声明部分 (#28)
|
|
6
12
|
- Fix: 修复Http/Request对象传入xml时解析异常导致无法获取请求参数的问题(#27)
|
|
7
13
|
|
|
8
14
|
## v2.10.1 (2022-05-21)
|
|
@@ -10,6 +10,12 @@ import ProviderClient from './Provider/ProviderClient';
|
|
|
10
10
|
import Encryptor from '../Core/Encryptor';
|
|
11
11
|
import OpenWorkGuard from './Server/OpenWorkGuard';
|
|
12
12
|
import { EasyWechatConfig } from '../Core/Types';
|
|
13
|
+
import DeviceClient from './Device/DeviceClient';
|
|
14
|
+
import LicenseOrderClient from './License/LicenseOrderClient';
|
|
15
|
+
import LicenseAccountClient from './License/LicenseAccountClient';
|
|
16
|
+
import LicenseAppClient from './License/LicenseAppClient';
|
|
17
|
+
import LicenseAutoActiveClient from './License/LicenseAutoActiveClient';
|
|
18
|
+
import MediaClient from './Media/MediaClient';
|
|
13
19
|
export default class OpenWork extends BaseApplication {
|
|
14
20
|
protected defaultConfig: EasyWechatConfig;
|
|
15
21
|
provider_access_token: ProviderAccessToken;
|
|
@@ -21,6 +27,12 @@ export default class OpenWork extends BaseApplication {
|
|
|
21
27
|
encryptor_corp: Encryptor;
|
|
22
28
|
encryptor: Encryptor;
|
|
23
29
|
server: OpenWorkGuard;
|
|
30
|
+
device: DeviceClient;
|
|
31
|
+
license_order: LicenseOrderClient;
|
|
32
|
+
license_account: LicenseAccountClient;
|
|
33
|
+
license_app: LicenseAppClient;
|
|
34
|
+
license_auto_active: LicenseAutoActiveClient;
|
|
35
|
+
media: MediaClient;
|
|
24
36
|
constructor(config?: EasyWechatConfig, prepends?: Object, id?: String);
|
|
25
37
|
registerProviders(): void;
|
|
26
38
|
/**
|
|
@@ -24,6 +24,12 @@ const ProviderClient_1 = __importDefault(require("./Provider/ProviderClient"));
|
|
|
24
24
|
const Encryptor_1 = __importDefault(require("../Core/Encryptor"));
|
|
25
25
|
const OpenWorkGuard_1 = __importDefault(require("./Server/OpenWorkGuard"));
|
|
26
26
|
const FinallResult_1 = __importDefault(require("../Core/Decorators/FinallResult"));
|
|
27
|
+
const DeviceClient_1 = __importDefault(require("./Device/DeviceClient"));
|
|
28
|
+
const LicenseOrderClient_1 = __importDefault(require("./License/LicenseOrderClient"));
|
|
29
|
+
const LicenseAccountClient_1 = __importDefault(require("./License/LicenseAccountClient"));
|
|
30
|
+
const LicenseAppClient_1 = __importDefault(require("./License/LicenseAppClient"));
|
|
31
|
+
const LicenseAutoActiveClient_1 = __importDefault(require("./License/LicenseAutoActiveClient"));
|
|
32
|
+
const MediaClient_1 = __importDefault(require("./Media/MediaClient"));
|
|
27
33
|
class OpenWork extends BaseApplication_1.default {
|
|
28
34
|
constructor(config = {}, prepends = {}, id = null) {
|
|
29
35
|
super(config, prepends, id);
|
|
@@ -98,6 +104,36 @@ class OpenWork extends BaseApplication_1.default {
|
|
|
98
104
|
return guard;
|
|
99
105
|
});
|
|
100
106
|
}
|
|
107
|
+
if (!this.device) {
|
|
108
|
+
this.offsetSet('device', function (app) {
|
|
109
|
+
return new DeviceClient_1.default(app);
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
if (!this.license_order) {
|
|
113
|
+
this.offsetSet('license_order', function (app) {
|
|
114
|
+
return new LicenseOrderClient_1.default(app);
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
if (!this.license_account) {
|
|
118
|
+
this.offsetSet('license_account', function (app) {
|
|
119
|
+
return new LicenseAccountClient_1.default(app);
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
if (!this.license_app) {
|
|
123
|
+
this.offsetSet('license_app', function (app) {
|
|
124
|
+
return new LicenseAppClient_1.default(app);
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
if (!this.license_auto_active) {
|
|
128
|
+
this.offsetSet('license_auto_active', function (app) {
|
|
129
|
+
return new LicenseAutoActiveClient_1.default(app);
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
if (!this.media) {
|
|
133
|
+
this.offsetSet('media', function (app) {
|
|
134
|
+
return new MediaClient_1.default(app);
|
|
135
|
+
});
|
|
136
|
+
}
|
|
101
137
|
}
|
|
102
138
|
/**
|
|
103
139
|
* 代理小程序实现业务,返回SDK实例
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import BaseClient from '../../Core/BaseClient';
|
|
2
|
+
export default class DeviceClient extends BaseClient {
|
|
3
|
+
constructor(app: any);
|
|
4
|
+
/**
|
|
5
|
+
* 添加设备实例
|
|
6
|
+
* @see https://developer.work.weixin.qq.com/document/path/90626
|
|
7
|
+
* @param modelId 设备的型号id,在服务商管理端添加设备型号之后,可以查看型号id
|
|
8
|
+
* @param deviceSn 硬件序列号,只能包含数字和大小写字母,长度最大为128字节,不可与之前已导入的相同
|
|
9
|
+
* @returns
|
|
10
|
+
*/
|
|
11
|
+
add(modelId: string, deviceSn: string): Promise<string>;
|
|
12
|
+
/**
|
|
13
|
+
* 查询设备绑定信息
|
|
14
|
+
* @see https://developer.work.weixin.qq.com/document/path/90753
|
|
15
|
+
* @param deviceSn 硬件序列号
|
|
16
|
+
* @returns
|
|
17
|
+
*/
|
|
18
|
+
get(deviceSn: string): Promise<any>;
|
|
19
|
+
/**
|
|
20
|
+
* 重置设备SecretNo
|
|
21
|
+
* @see https://developer.work.weixin.qq.com/document/path/90631
|
|
22
|
+
* @param deviceSn 硬件序列号
|
|
23
|
+
* @returns
|
|
24
|
+
*/
|
|
25
|
+
reset(deviceSn: string): Promise<any>;
|
|
26
|
+
/**
|
|
27
|
+
* 获取设备列表
|
|
28
|
+
* @see https://developer.work.weixin.qq.com/document/path/91346
|
|
29
|
+
* @param offset 分页偏移量
|
|
30
|
+
* @param limit 分页请求的数据条数
|
|
31
|
+
* @returns
|
|
32
|
+
*/
|
|
33
|
+
list(offset: number, limit: number): Promise<any>;
|
|
34
|
+
/**
|
|
35
|
+
* 上传设备日志
|
|
36
|
+
* @see https://developer.work.weixin.qq.com/document/path/91475
|
|
37
|
+
* @param deviceSn 硬件序列号
|
|
38
|
+
* @param hint 提示参数,企业微信后台会将此参数透传给设备,设备可根据此参数来决定要上传哪部分日志,服务商可根据实际业务需求来使用此参数,最长为128字节
|
|
39
|
+
* @returns
|
|
40
|
+
*/
|
|
41
|
+
uploadLog(deviceSn: string, hint: string): Promise<any>;
|
|
42
|
+
/**
|
|
43
|
+
* 获取设备自定义参数
|
|
44
|
+
* @see https://developer.work.weixin.qq.com/document/path/92739
|
|
45
|
+
* @param deviceSn 硬件序列号
|
|
46
|
+
* @returns
|
|
47
|
+
*/
|
|
48
|
+
getFeature(deviceSn: string): Promise<any>;
|
|
49
|
+
/**
|
|
50
|
+
* 删除设备实例
|
|
51
|
+
* @see https://developer.work.weixin.qq.com/document/path/92770
|
|
52
|
+
* @param deviceSn 硬件序列号
|
|
53
|
+
* @returns
|
|
54
|
+
*/
|
|
55
|
+
getUserByTicket(deviceSn: string): Promise<any>;
|
|
56
|
+
/**
|
|
57
|
+
* 设置打印机支持状态
|
|
58
|
+
* @see https://developer.work.weixin.qq.com/document/path/95327
|
|
59
|
+
* @param deviceSn 硬件序列号
|
|
60
|
+
* @param supported 是否支持打印机,true:不支持,false:支持
|
|
61
|
+
* @returns
|
|
62
|
+
*/
|
|
63
|
+
setPrinterSupportState(deviceSn: string, supported: boolean): Promise<any>;
|
|
64
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const BaseClient_1 = __importDefault(require("../../Core/BaseClient"));
|
|
16
|
+
class DeviceClient extends BaseClient_1.default {
|
|
17
|
+
constructor(app) {
|
|
18
|
+
super(app, app['provider_access_token']);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* 添加设备实例
|
|
22
|
+
* @see https://developer.work.weixin.qq.com/document/path/90626
|
|
23
|
+
* @param modelId 设备的型号id,在服务商管理端添加设备型号之后,可以查看型号id
|
|
24
|
+
* @param deviceSn 硬件序列号,只能包含数字和大小写字母,长度最大为128字节,不可与之前已导入的相同
|
|
25
|
+
* @returns
|
|
26
|
+
*/
|
|
27
|
+
add(modelId = '', deviceSn) {
|
|
28
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
+
return this.httpPostJson('cgi-bin/service/add_device', {
|
|
30
|
+
model_id: modelId,
|
|
31
|
+
device_sn: deviceSn,
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* 查询设备绑定信息
|
|
37
|
+
* @see https://developer.work.weixin.qq.com/document/path/90753
|
|
38
|
+
* @param deviceSn 硬件序列号
|
|
39
|
+
* @returns
|
|
40
|
+
*/
|
|
41
|
+
get(deviceSn) {
|
|
42
|
+
return this.httpPostJson('cgi-bin/service/get_device_auth_info', {
|
|
43
|
+
device_sn: deviceSn,
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* 重置设备SecretNo
|
|
48
|
+
* @see https://developer.work.weixin.qq.com/document/path/90631
|
|
49
|
+
* @param deviceSn 硬件序列号
|
|
50
|
+
* @returns
|
|
51
|
+
*/
|
|
52
|
+
reset(deviceSn) {
|
|
53
|
+
return this.httpPostJson('cgi-bin/service/reset_secret_no', {
|
|
54
|
+
device_sn: deviceSn,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* 获取设备列表
|
|
59
|
+
* @see https://developer.work.weixin.qq.com/document/path/91346
|
|
60
|
+
* @param offset 分页偏移量
|
|
61
|
+
* @param limit 分页请求的数据条数
|
|
62
|
+
* @returns
|
|
63
|
+
*/
|
|
64
|
+
list(offset, limit) {
|
|
65
|
+
return this.httpPostJson('cgi-bin/service/list_device', {
|
|
66
|
+
offset,
|
|
67
|
+
limit,
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* 上传设备日志
|
|
72
|
+
* @see https://developer.work.weixin.qq.com/document/path/91475
|
|
73
|
+
* @param deviceSn 硬件序列号
|
|
74
|
+
* @param hint 提示参数,企业微信后台会将此参数透传给设备,设备可根据此参数来决定要上传哪部分日志,服务商可根据实际业务需求来使用此参数,最长为128字节
|
|
75
|
+
* @returns
|
|
76
|
+
*/
|
|
77
|
+
uploadLog(deviceSn, hint) {
|
|
78
|
+
return this.httpPostJson('cgi-bin/service/fetch_device_log', {
|
|
79
|
+
device_sn: deviceSn,
|
|
80
|
+
hint,
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* 获取设备自定义参数
|
|
85
|
+
* @see https://developer.work.weixin.qq.com/document/path/92739
|
|
86
|
+
* @param deviceSn 硬件序列号
|
|
87
|
+
* @returns
|
|
88
|
+
*/
|
|
89
|
+
getFeature(deviceSn) {
|
|
90
|
+
return this.httpGet('cgi-bin/hardware/get_device_feature', {
|
|
91
|
+
device_sn: deviceSn,
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* 删除设备实例
|
|
96
|
+
* @see https://developer.work.weixin.qq.com/document/path/92770
|
|
97
|
+
* @param deviceSn 硬件序列号
|
|
98
|
+
* @returns
|
|
99
|
+
*/
|
|
100
|
+
getUserByTicket(deviceSn) {
|
|
101
|
+
return this.httpPostJson('cgi-bin/service/del_device', {
|
|
102
|
+
device_sn: deviceSn,
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* 设置打印机支持状态
|
|
107
|
+
* @see https://developer.work.weixin.qq.com/document/path/95327
|
|
108
|
+
* @param deviceSn 硬件序列号
|
|
109
|
+
* @param supported 是否支持打印机,true:不支持,false:支持
|
|
110
|
+
* @returns
|
|
111
|
+
*/
|
|
112
|
+
setPrinterSupportState(deviceSn, supported) {
|
|
113
|
+
return this.httpPostJson('cgi-bin/service/set_printer_support_state', {
|
|
114
|
+
device_sn: deviceSn,
|
|
115
|
+
not_supported_printer: supported ? 1 : 0,
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
exports.default = DeviceClient;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import BaseClient from '../../Core/BaseClient';
|
|
2
|
+
export default class LicenseAccountClient extends BaseClient {
|
|
3
|
+
constructor(app: any);
|
|
4
|
+
/**
|
|
5
|
+
* 激活帐号
|
|
6
|
+
* @see https://developer.work.weixin.qq.com/document/path/95553
|
|
7
|
+
* @param activeCode 帐号激活码
|
|
8
|
+
* @param corpId 激活码所属企业corpid
|
|
9
|
+
* @param userId 待绑定激活的企业成员userid 。只支持加密的userid
|
|
10
|
+
* @returns
|
|
11
|
+
*/
|
|
12
|
+
active(activeCode: string, corpId: string, userId: string): Promise<string>;
|
|
13
|
+
/**
|
|
14
|
+
* 批量激活帐号
|
|
15
|
+
* @see https://developer.work.weixin.qq.com/document/path/95553#批量激活帐号
|
|
16
|
+
* @param corpId 激活码所属企业corpid
|
|
17
|
+
* @param activeList 待绑定激活的企业成员userid 。只支持加密的userid
|
|
18
|
+
* @returns
|
|
19
|
+
*/
|
|
20
|
+
batchActive(corpId: string, activeList: any[]): Promise<string>;
|
|
21
|
+
/**
|
|
22
|
+
* 获取激活码详情
|
|
23
|
+
* @see https://developer.work.weixin.qq.com/document/path/95552
|
|
24
|
+
* @param corpId 企业id,只支持加密的corpid
|
|
25
|
+
* @param activeCode 激活码
|
|
26
|
+
* @returns
|
|
27
|
+
*/
|
|
28
|
+
getActiveCodeInfo(corpId: string, activeCode: string): Promise<string>;
|
|
29
|
+
/**
|
|
30
|
+
* 批量获取激活码详情
|
|
31
|
+
* @see https://developer.work.weixin.qq.com/document/path/95552#批量获取激活码详情
|
|
32
|
+
* @param corpId 要查询的企业的corpid,只支持加密的corpid
|
|
33
|
+
* @param activeCodeList 激活码列表,最多不超过1000个
|
|
34
|
+
* @returns
|
|
35
|
+
*/
|
|
36
|
+
batchGetActiveCodeInfo(corpId: string, activeCodeList: string[]): Promise<string>;
|
|
37
|
+
/**
|
|
38
|
+
* 获取企业的帐号列表
|
|
39
|
+
* @see https://developer.work.weixin.qq.com/document/path/95544
|
|
40
|
+
* @param corpId 企业corpid ,只支持加密的corpid
|
|
41
|
+
* @param cursor 用于分页查询的游标,字符串类型,由上一次调用返回,首次调用可不填
|
|
42
|
+
* @param limit 返回的最大记录数,整型,最大值1000,默认值500
|
|
43
|
+
* @returns
|
|
44
|
+
*/
|
|
45
|
+
list(corpId: string, cursor?: string, limit?: number): Promise<any>;
|
|
46
|
+
/**
|
|
47
|
+
* 获取成员的激活详情
|
|
48
|
+
* @see https://developer.work.weixin.qq.com/document/path/95555
|
|
49
|
+
* @param corpId 企业corpid ,只支持加密的corpid
|
|
50
|
+
* @param userid 订单id
|
|
51
|
+
* @returns
|
|
52
|
+
*/
|
|
53
|
+
getActiveAccountInfo(corpId: string, userid: string): Promise<any>;
|
|
54
|
+
/**
|
|
55
|
+
* 帐号继承
|
|
56
|
+
* @see https://developer.work.weixin.qq.com/document/path/95673
|
|
57
|
+
* @param corpId 企业id,只支持加密的corpid
|
|
58
|
+
* @param transferList 转移成员列表
|
|
59
|
+
* @returns
|
|
60
|
+
*/
|
|
61
|
+
batchTransfer(corpId: string, transferList: any[]): Promise<any>;
|
|
62
|
+
/**
|
|
63
|
+
* 分配激活码给下游企业
|
|
64
|
+
* @see https://developer.work.weixin.qq.com/document/path/96059
|
|
65
|
+
* @param from 上游企业corpid。支持明文或者密文的corpid
|
|
66
|
+
* @param to 下游企业corpid。支持明文或者密文的corpid
|
|
67
|
+
* @param shareList 分享的接口许可列表。单次分享激活码不可超过1000个,累计分享给同一下游企业的激活码总数不可超过上下游通讯录中该下游企业人数的2倍
|
|
68
|
+
* @returns
|
|
69
|
+
*/
|
|
70
|
+
batchShareActiveCode(from: string, to: string, shareList: any[]): Promise<any>;
|
|
71
|
+
}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const BaseClient_1 = __importDefault(require("../../Core/BaseClient"));
|
|
16
|
+
class LicenseAccountClient extends BaseClient_1.default {
|
|
17
|
+
constructor(app) {
|
|
18
|
+
super(app, app['provider_access_token']);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* 激活帐号
|
|
22
|
+
* @see https://developer.work.weixin.qq.com/document/path/95553
|
|
23
|
+
* @param activeCode 帐号激活码
|
|
24
|
+
* @param corpId 激活码所属企业corpid
|
|
25
|
+
* @param userId 待绑定激活的企业成员userid 。只支持加密的userid
|
|
26
|
+
* @returns
|
|
27
|
+
*/
|
|
28
|
+
active(activeCode, corpId, userId) {
|
|
29
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
30
|
+
let params = {
|
|
31
|
+
active_code: activeCode,
|
|
32
|
+
corpid: corpId,
|
|
33
|
+
userid: userId,
|
|
34
|
+
};
|
|
35
|
+
return this.httpPostJson('cgi-bin/license/active_account', params);
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* 批量激活帐号
|
|
40
|
+
* @see https://developer.work.weixin.qq.com/document/path/95553#批量激活帐号
|
|
41
|
+
* @param corpId 激活码所属企业corpid
|
|
42
|
+
* @param activeList 待绑定激活的企业成员userid 。只支持加密的userid
|
|
43
|
+
* @returns
|
|
44
|
+
*/
|
|
45
|
+
batchActive(corpId, activeList) {
|
|
46
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
47
|
+
let params = {
|
|
48
|
+
corpid: corpId,
|
|
49
|
+
active_list: activeList,
|
|
50
|
+
};
|
|
51
|
+
return this.httpPostJson('cgi-bin/license/batch_active_account', params);
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* 获取激活码详情
|
|
56
|
+
* @see https://developer.work.weixin.qq.com/document/path/95552
|
|
57
|
+
* @param corpId 企业id,只支持加密的corpid
|
|
58
|
+
* @param activeCode 激活码
|
|
59
|
+
* @returns
|
|
60
|
+
*/
|
|
61
|
+
getActiveCodeInfo(corpId, activeCode) {
|
|
62
|
+
let params = {
|
|
63
|
+
corpid: corpId,
|
|
64
|
+
active_code: activeCode,
|
|
65
|
+
};
|
|
66
|
+
return this.httpPostJson('cgi-bin/license/get_active_info_by_code', params);
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* 批量获取激活码详情
|
|
70
|
+
* @see https://developer.work.weixin.qq.com/document/path/95552#批量获取激活码详情
|
|
71
|
+
* @param corpId 要查询的企业的corpid,只支持加密的corpid
|
|
72
|
+
* @param activeCodeList 激活码列表,最多不超过1000个
|
|
73
|
+
* @returns
|
|
74
|
+
*/
|
|
75
|
+
batchGetActiveCodeInfo(corpId, activeCodeList) {
|
|
76
|
+
let params = {
|
|
77
|
+
corpid: corpId,
|
|
78
|
+
active_code_list: activeCodeList,
|
|
79
|
+
};
|
|
80
|
+
return this.httpPostJson('cgi-bin/license/batch_get_active_info_by_code', params);
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* 获取企业的帐号列表
|
|
84
|
+
* @see https://developer.work.weixin.qq.com/document/path/95544
|
|
85
|
+
* @param corpId 企业corpid ,只支持加密的corpid
|
|
86
|
+
* @param cursor 用于分页查询的游标,字符串类型,由上一次调用返回,首次调用可不填
|
|
87
|
+
* @param limit 返回的最大记录数,整型,最大值1000,默认值500
|
|
88
|
+
* @returns
|
|
89
|
+
*/
|
|
90
|
+
list(corpId, cursor = null, limit = 500) {
|
|
91
|
+
return this.httpPostJson('cgi-bin/license/list_actived_account', {
|
|
92
|
+
corpid: corpId,
|
|
93
|
+
cursor,
|
|
94
|
+
limit,
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* 获取成员的激活详情
|
|
99
|
+
* @see https://developer.work.weixin.qq.com/document/path/95555
|
|
100
|
+
* @param corpId 企业corpid ,只支持加密的corpid
|
|
101
|
+
* @param userid 订单id
|
|
102
|
+
* @returns
|
|
103
|
+
*/
|
|
104
|
+
getActiveAccountInfo(corpId, userid) {
|
|
105
|
+
return this.httpPostJson('cgi-bin/license/get_active_info_by_user', {
|
|
106
|
+
cropid: corpId,
|
|
107
|
+
order_id: userid,
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* 帐号继承
|
|
112
|
+
* @see https://developer.work.weixin.qq.com/document/path/95673
|
|
113
|
+
* @param corpId 企业id,只支持加密的corpid
|
|
114
|
+
* @param transferList 转移成员列表
|
|
115
|
+
* @returns
|
|
116
|
+
*/
|
|
117
|
+
batchTransfer(corpId, transferList) {
|
|
118
|
+
return this.httpPostJson('cgi-bin/license/batch_transfer_license', {
|
|
119
|
+
corpid: corpId,
|
|
120
|
+
transfer_list: transferList,
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* 分配激活码给下游企业
|
|
125
|
+
* @see https://developer.work.weixin.qq.com/document/path/96059
|
|
126
|
+
* @param from 上游企业corpid。支持明文或者密文的corpid
|
|
127
|
+
* @param to 下游企业corpid。支持明文或者密文的corpid
|
|
128
|
+
* @param shareList 分享的接口许可列表。单次分享激活码不可超过1000个,累计分享给同一下游企业的激活码总数不可超过上下游通讯录中该下游企业人数的2倍
|
|
129
|
+
* @returns
|
|
130
|
+
*/
|
|
131
|
+
batchShareActiveCode(from, to, shareList) {
|
|
132
|
+
return this.httpPostJson('cgi-bin/license/batch_share_active_code', {
|
|
133
|
+
from_corpid: from,
|
|
134
|
+
to_corpid: to,
|
|
135
|
+
share_list: shareList,
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
exports.default = LicenseAccountClient;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import BaseClient from '../../Core/BaseClient';
|
|
2
|
+
export default class LicenseAppClient extends BaseClient {
|
|
3
|
+
constructor(app: any);
|
|
4
|
+
/**
|
|
5
|
+
* 获取应用的接口许可状态
|
|
6
|
+
* @see https://developer.work.weixin.qq.com/document/path/95844
|
|
7
|
+
* @param corpId 企业id
|
|
8
|
+
* @param suiteId 套件id
|
|
9
|
+
* @param appId 旧的多应用套件中的应用id,新开发者请忽略
|
|
10
|
+
* @returns
|
|
11
|
+
*/
|
|
12
|
+
get(corpId: string, suiteId: string, appId?: string): Promise<any>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
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 LicenseAppClient extends BaseClient_1.default {
|
|
8
|
+
constructor(app) {
|
|
9
|
+
super(app, app['provider_access_token']);
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* 获取应用的接口许可状态
|
|
13
|
+
* @see https://developer.work.weixin.qq.com/document/path/95844
|
|
14
|
+
* @param corpId 企业id
|
|
15
|
+
* @param suiteId 套件id
|
|
16
|
+
* @param appId 旧的多应用套件中的应用id,新开发者请忽略
|
|
17
|
+
* @returns
|
|
18
|
+
*/
|
|
19
|
+
get(corpId, suiteId, appId = '') {
|
|
20
|
+
return this.httpPostJson('cgi-bin/license/get_app_license_info', {
|
|
21
|
+
corpid: corpId,
|
|
22
|
+
suite_id: suiteId,
|
|
23
|
+
appid: appId,
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.default = LicenseAppClient;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import BaseClient from '../../Core/BaseClient';
|
|
2
|
+
export default class LicenseAutoActiveClient extends BaseClient {
|
|
3
|
+
constructor(app: any);
|
|
4
|
+
/**
|
|
5
|
+
* 设置企业的许可自动激活状态
|
|
6
|
+
* @see https://developer.work.weixin.qq.com/document/path/95873
|
|
7
|
+
* @param corpId 企业corpid,要求服务商为企业购买过接口许可,购买指支付完成,购买并退款成功包括在内
|
|
8
|
+
* @param status 许可自动激活状态。0:关闭,1:打开
|
|
9
|
+
* @returns
|
|
10
|
+
*/
|
|
11
|
+
setStatus(corpId: string, status: number): Promise<any>;
|
|
12
|
+
/**
|
|
13
|
+
* 查询企业的许可自动激活状态
|
|
14
|
+
* @see https://developer.work.weixin.qq.com/document/path/95874
|
|
15
|
+
* @param corpId 查询的企业corpid。要求服务商为企业购买过接口许可才有查询结果。
|
|
16
|
+
* @returns
|
|
17
|
+
*/
|
|
18
|
+
getStatus(corpId: string): Promise<any>;
|
|
19
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
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 LicenseAutoActiveClient extends BaseClient_1.default {
|
|
8
|
+
constructor(app) {
|
|
9
|
+
super(app, app['provider_access_token']);
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* 设置企业的许可自动激活状态
|
|
13
|
+
* @see https://developer.work.weixin.qq.com/document/path/95873
|
|
14
|
+
* @param corpId 企业corpid,要求服务商为企业购买过接口许可,购买指支付完成,购买并退款成功包括在内
|
|
15
|
+
* @param status 许可自动激活状态。0:关闭,1:打开
|
|
16
|
+
* @returns
|
|
17
|
+
*/
|
|
18
|
+
setStatus(corpId, status) {
|
|
19
|
+
return this.httpPostJson('cgi-bin/license/set_auto_active_status', {
|
|
20
|
+
corpid: corpId,
|
|
21
|
+
auto_active_status: status,
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* 查询企业的许可自动激活状态
|
|
26
|
+
* @see https://developer.work.weixin.qq.com/document/path/95874
|
|
27
|
+
* @param corpId 查询的企业corpid。要求服务商为企业购买过接口许可才有查询结果。
|
|
28
|
+
* @returns
|
|
29
|
+
*/
|
|
30
|
+
getStatus(corpId) {
|
|
31
|
+
return this.httpPostJson('cgi-bin/license/get_auto_active_status', {
|
|
32
|
+
corpid: corpId,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
exports.default = LicenseAutoActiveClient;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import BaseClient from '../../Core/BaseClient';
|
|
2
|
+
export default class LicenseOrderClient extends BaseClient {
|
|
3
|
+
constructor(app: any);
|
|
4
|
+
/**
|
|
5
|
+
* 下单购买帐号
|
|
6
|
+
* @see https://developer.work.weixin.qq.com/document/path/95644
|
|
7
|
+
* @param corpId 企业id,只支持加密的corpid
|
|
8
|
+
* @param data 订单信息
|
|
9
|
+
* @returns
|
|
10
|
+
*/
|
|
11
|
+
create(corpId: string, data: object): Promise<string>;
|
|
12
|
+
/**
|
|
13
|
+
* 下单续期帐号
|
|
14
|
+
* @see https://developer.work.weixin.qq.com/document/path/95646
|
|
15
|
+
* @param corpId 企业id,只支持加密的corpid
|
|
16
|
+
* @param data 订单信息
|
|
17
|
+
* @returns
|
|
18
|
+
*/
|
|
19
|
+
renew(corpId: string, data: object): Promise<string>;
|
|
20
|
+
/**
|
|
21
|
+
* 提交续期订单
|
|
22
|
+
* @see https://developer.work.weixin.qq.com/document/path/95646#提交续期订单
|
|
23
|
+
* @param jobId 任务id
|
|
24
|
+
* @param buyerUserId 下单人。服务商企业内成员userid。该userid必须登录过企业微信,并且企业微信已绑定微信
|
|
25
|
+
* @param accountDurationMonths 购买的月数,每个月按照31天计算。最多购买36个月。(若企业为服务商测试企业,每次续期只能续期1个月)
|
|
26
|
+
* @returns
|
|
27
|
+
*/
|
|
28
|
+
submitJob(jobId: string, buyerUserId: string, accountDurationMonths: number): Promise<string>;
|
|
29
|
+
/**
|
|
30
|
+
* 获取订单列表
|
|
31
|
+
* @see https://developer.work.weixin.qq.com/document/path/95647
|
|
32
|
+
* @param corpId 企业id,只支持加密的corpid。若指定corpid且corpid为服务商测试企业,则返回的订单列表为测试订单列表。否则只返回正式订单列表
|
|
33
|
+
* @param endTime 开始时间,下单时间。可不填。但是不能单独指定该字段,startTime跟endTime必须同时指定。
|
|
34
|
+
* @param endTime 结束时间,下单时间。起始时间跟结束时间不能超过31天。可不填。但是不能单独指定该字段,startTime跟endTime必须同时指定。
|
|
35
|
+
* @param cursor 用于分页查询的游标,字符串类型,由上一次调用返回,首次调用可不填
|
|
36
|
+
* @param limit 返回的最大记录数,整型,最大值1000,默认值500
|
|
37
|
+
* @returns
|
|
38
|
+
*/
|
|
39
|
+
list(corpId: string, startTime?: number, endTime?: number, cursor?: string, limit?: number): Promise<any>;
|
|
40
|
+
/**
|
|
41
|
+
* 获取订单详情
|
|
42
|
+
* @see https://developer.work.weixin.qq.com/document/path/95648
|
|
43
|
+
* @param orderId 订单id
|
|
44
|
+
* @returns
|
|
45
|
+
*/
|
|
46
|
+
get(orderId: string): Promise<any>;
|
|
47
|
+
/**
|
|
48
|
+
* 获取订单中的帐号列表
|
|
49
|
+
* @see https://developer.work.weixin.qq.com/document/path/95649
|
|
50
|
+
* @param orderId 订单号
|
|
51
|
+
* @param cursor 用于分页查询的游标,字符串类型,由上一次调用返回,首次调用可不填
|
|
52
|
+
* @param limit 返回的最大记录数,整型,最大值1000,默认值500
|
|
53
|
+
* @returns
|
|
54
|
+
*/
|
|
55
|
+
getAccountList(orderId: string, cursor?: string, limit?: number): Promise<any>;
|
|
56
|
+
/**
|
|
57
|
+
* 取消订单
|
|
58
|
+
* @see https://developer.work.weixin.qq.com/document/path/96106
|
|
59
|
+
* @param corpId 企业id,只支持加密的corpid
|
|
60
|
+
* @param orderId 订单号
|
|
61
|
+
* @returns
|
|
62
|
+
*/
|
|
63
|
+
cancel(corpId: string, orderId: string): Promise<any>;
|
|
64
|
+
}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const BaseClient_1 = __importDefault(require("../../Core/BaseClient"));
|
|
16
|
+
const Utils_1 = require("../../Core/Utils");
|
|
17
|
+
class LicenseOrderClient extends BaseClient_1.default {
|
|
18
|
+
constructor(app) {
|
|
19
|
+
super(app, app['provider_access_token']);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* 下单购买帐号
|
|
23
|
+
* @see https://developer.work.weixin.qq.com/document/path/95644
|
|
24
|
+
* @param corpId 企业id,只支持加密的corpid
|
|
25
|
+
* @param data 订单信息
|
|
26
|
+
* @returns
|
|
27
|
+
*/
|
|
28
|
+
create(corpId, data) {
|
|
29
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
30
|
+
let params = (0, Utils_1.merge)({}, data);
|
|
31
|
+
params['corpid'] = corpId;
|
|
32
|
+
return this.httpPostJson('cgi-bin/license/create_new_order', params);
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* 下单续期帐号
|
|
37
|
+
* @see https://developer.work.weixin.qq.com/document/path/95646
|
|
38
|
+
* @param corpId 企业id,只支持加密的corpid
|
|
39
|
+
* @param data 订单信息
|
|
40
|
+
* @returns
|
|
41
|
+
*/
|
|
42
|
+
renew(corpId, data) {
|
|
43
|
+
let params = (0, Utils_1.merge)({}, data);
|
|
44
|
+
params['corpid'] = corpId;
|
|
45
|
+
return this.httpPostJson('cgi-bin/license/create_renew_order_job', params);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* 提交续期订单
|
|
49
|
+
* @see https://developer.work.weixin.qq.com/document/path/95646#提交续期订单
|
|
50
|
+
* @param jobId 任务id
|
|
51
|
+
* @param buyerUserId 下单人。服务商企业内成员userid。该userid必须登录过企业微信,并且企业微信已绑定微信
|
|
52
|
+
* @param accountDurationMonths 购买的月数,每个月按照31天计算。最多购买36个月。(若企业为服务商测试企业,每次续期只能续期1个月)
|
|
53
|
+
* @returns
|
|
54
|
+
*/
|
|
55
|
+
submitJob(jobId, buyerUserId, accountDurationMonths) {
|
|
56
|
+
let params = {
|
|
57
|
+
jobid: jobId,
|
|
58
|
+
buyer_userid: buyerUserId,
|
|
59
|
+
account_duration: {
|
|
60
|
+
months: accountDurationMonths,
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
return this.httpPostJson('cgi-bin/license/submit_order_job', params);
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* 获取订单列表
|
|
67
|
+
* @see https://developer.work.weixin.qq.com/document/path/95647
|
|
68
|
+
* @param corpId 企业id,只支持加密的corpid。若指定corpid且corpid为服务商测试企业,则返回的订单列表为测试订单列表。否则只返回正式订单列表
|
|
69
|
+
* @param endTime 开始时间,下单时间。可不填。但是不能单独指定该字段,startTime跟endTime必须同时指定。
|
|
70
|
+
* @param endTime 结束时间,下单时间。起始时间跟结束时间不能超过31天。可不填。但是不能单独指定该字段,startTime跟endTime必须同时指定。
|
|
71
|
+
* @param cursor 用于分页查询的游标,字符串类型,由上一次调用返回,首次调用可不填
|
|
72
|
+
* @param limit 返回的最大记录数,整型,最大值1000,默认值500
|
|
73
|
+
* @returns
|
|
74
|
+
*/
|
|
75
|
+
list(corpId, startTime = null, endTime = null, cursor = null, limit = 500) {
|
|
76
|
+
return this.httpPostJson('cgi-bin/license/list_order', {
|
|
77
|
+
corpid: corpId,
|
|
78
|
+
start_time: startTime,
|
|
79
|
+
end_time: endTime,
|
|
80
|
+
cursor,
|
|
81
|
+
limit,
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* 获取订单详情
|
|
86
|
+
* @see https://developer.work.weixin.qq.com/document/path/95648
|
|
87
|
+
* @param orderId 订单id
|
|
88
|
+
* @returns
|
|
89
|
+
*/
|
|
90
|
+
get(orderId) {
|
|
91
|
+
return this.httpPostJson('cgi-bin/license/get_order', {
|
|
92
|
+
order_id: orderId,
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* 获取订单中的帐号列表
|
|
97
|
+
* @see https://developer.work.weixin.qq.com/document/path/95649
|
|
98
|
+
* @param orderId 订单号
|
|
99
|
+
* @param cursor 用于分页查询的游标,字符串类型,由上一次调用返回,首次调用可不填
|
|
100
|
+
* @param limit 返回的最大记录数,整型,最大值1000,默认值500
|
|
101
|
+
* @returns
|
|
102
|
+
*/
|
|
103
|
+
getAccountList(orderId, cursor = null, limit = 500) {
|
|
104
|
+
return this.httpPostJson('cgi-bin/license/list_order_account', {
|
|
105
|
+
order_id: orderId,
|
|
106
|
+
cursor,
|
|
107
|
+
limit,
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* 取消订单
|
|
112
|
+
* @see https://developer.work.weixin.qq.com/document/path/96106
|
|
113
|
+
* @param corpId 企业id,只支持加密的corpid
|
|
114
|
+
* @param orderId 订单号
|
|
115
|
+
* @returns
|
|
116
|
+
*/
|
|
117
|
+
cancel(corpId, orderId) {
|
|
118
|
+
return this.httpPostJson('cgi-bin/license/cancel_order', {
|
|
119
|
+
corpid: corpId,
|
|
120
|
+
order_id: orderId,
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
exports.default = LicenseOrderClient;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import BaseClient from '../../Core/BaseClient';
|
|
3
|
+
import Stream from 'stream';
|
|
4
|
+
export default class MediaClient extends BaseClient {
|
|
5
|
+
constructor(app: any);
|
|
6
|
+
/**
|
|
7
|
+
* 上传图片
|
|
8
|
+
* @see https://developer.work.weixin.qq.com/document/path/91883
|
|
9
|
+
* @param file 文件路径或可读stream
|
|
10
|
+
*/
|
|
11
|
+
uploadImage(file: string | Stream.Readable): Promise<any>;
|
|
12
|
+
/**
|
|
13
|
+
* 上传视频
|
|
14
|
+
* @see https://developer.work.weixin.qq.com/document/path/91883
|
|
15
|
+
* @param file 文件路径或可读stream
|
|
16
|
+
*/
|
|
17
|
+
uploadVideo(file: string | Stream.Readable): Promise<any>;
|
|
18
|
+
/**
|
|
19
|
+
* 上传语音
|
|
20
|
+
* @see https://developer.work.weixin.qq.com/document/path/91883
|
|
21
|
+
* @param file 文件路径或可读stream
|
|
22
|
+
*/
|
|
23
|
+
uploadVoice(file: string | Stream.Readable): Promise<any>;
|
|
24
|
+
/**
|
|
25
|
+
* 上传普通文件
|
|
26
|
+
* @see https://developer.work.weixin.qq.com/document/path/91883
|
|
27
|
+
* @param file 文件路径或可读stream
|
|
28
|
+
*/
|
|
29
|
+
uploadFile(file: string | Stream.Readable): Promise<any>;
|
|
30
|
+
/**
|
|
31
|
+
* 上传需要转译的文件
|
|
32
|
+
* @see https://developer.work.weixin.qq.com/document/path/91883
|
|
33
|
+
* @param type 类型,可选值:image,video,voice,file
|
|
34
|
+
* @param file 文件路径或可读stream
|
|
35
|
+
*/
|
|
36
|
+
upload(type: string, file: string | Stream.Readable): Promise<any>;
|
|
37
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
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 MediaClient extends BaseClient_1.default {
|
|
8
|
+
constructor(app) {
|
|
9
|
+
super(app, app['provider_access_token']);
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* 上传图片
|
|
13
|
+
* @see https://developer.work.weixin.qq.com/document/path/91883
|
|
14
|
+
* @param file 文件路径或可读stream
|
|
15
|
+
*/
|
|
16
|
+
uploadImage(file) {
|
|
17
|
+
return this.upload('image', file);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* 上传视频
|
|
21
|
+
* @see https://developer.work.weixin.qq.com/document/path/91883
|
|
22
|
+
* @param file 文件路径或可读stream
|
|
23
|
+
*/
|
|
24
|
+
uploadVideo(file) {
|
|
25
|
+
return this.upload('video', file);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* 上传语音
|
|
29
|
+
* @see https://developer.work.weixin.qq.com/document/path/91883
|
|
30
|
+
* @param file 文件路径或可读stream
|
|
31
|
+
*/
|
|
32
|
+
uploadVoice(file) {
|
|
33
|
+
return this.upload('voice', file);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* 上传普通文件
|
|
37
|
+
* @see https://developer.work.weixin.qq.com/document/path/91883
|
|
38
|
+
* @param file 文件路径或可读stream
|
|
39
|
+
*/
|
|
40
|
+
uploadFile(file) {
|
|
41
|
+
return this.upload('file', file);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* 上传需要转译的文件
|
|
45
|
+
* @see https://developer.work.weixin.qq.com/document/path/91883
|
|
46
|
+
* @param type 类型,可选值:image,video,voice,file
|
|
47
|
+
* @param file 文件路径或可读stream
|
|
48
|
+
*/
|
|
49
|
+
upload(type, file) {
|
|
50
|
+
if (!file) {
|
|
51
|
+
throw new Error(`File does not exist, or the file is unreadable: '${file}'`);
|
|
52
|
+
}
|
|
53
|
+
return this.httpUpload('cgi-bin/service/media/upload', {
|
|
54
|
+
media: file
|
|
55
|
+
}, {}, {
|
|
56
|
+
type
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
exports.default = MediaClient;
|