-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
90 lines (79 loc) · 3.25 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
const os = require("os");
const hikopenapi = require(`${genPath()}`);
function genPath() {
const platform = os.platform();
const arch = process.arch;
let scriptBasePath = ``;
if (platform === 'win32') {
scriptBasePath = "./lib/windows/hikopenapi.node";
} else if (platform === 'linux') {
scriptBasePath = `./lib/linux/${arch}/hikopenapi.node`;
}
return scriptBasePath;
}
/**
* say hello,没有参数
*/
const sayHello= ()=>{
return hikopenapi.sayHello();
}
/**
* say something
*/
const saySomething= ()=>{
return hikopenapi.saySomething(__dirname);
}
/** artemis封装post接口
*
* @param {*} url 完整请求url,如https://123.123.123.123:443/artemis/api/video/v1/cameras/previewURLs
* @param {*} headers 请求头,json格式,如{"content-type":"application/json;charset=UTF-8","accept":"application/json"}
* @param {*} body 请求消息体,请自行使用JSON.stringify处理json
* @param {*} appKey 认证参数,请联系海康工作人员获取
* @param {*} appSecret 认证参数,请联系海康工作人员获取
* @param {*} timeout 超时时长,推荐配置15
*/
const httpPost=(url,headers,body,appKey,appSecret,timeout)=>{
return hikopenapi.artemisHttpPost(__dirname,url,headers,body,appKey,appSecret,timeout);
}
/** artemis封装put接口
*
* @param {*} url 完整请求url,如https://123.123.123.123:443/artemis/api/video/v1/cameras/previewURLs
* @param {*} headers 请求头,json格式,如{"content-type":"application/json;charset=UTF-8","accept":"application/json"}
* @param {*} body 请求消息体,请自行使用JSON.stringify处理json
* @param {*} appKey 认证参数,请联系海康工作人员获取
* @param {*} appSecret 认证参数,请联系海康工作人员获取
* @param {*} timeout 超时时长,推荐配置15
*/
const httpPut=(url,headers,body,appKey,appSecret,timeout)=>{
return hikopenapi.artemisHttpPut(__dirname,url,headers,body,appKey,appSecret,timeout);
}
/** artemis封装get接口
*
* @param {*} url 完整请求url,如https://123.123.123.123:443/artemis/api/video/v1/cameras/previewURLs
* @param {*} headers 请求头,json格式,如{"content-type":"application/json;charset=UTF-8","accept":"application/json"}
* @param {*} appKey 认证参数,请联系海康工作人员获取
* @param {*} appSecret 认证参数,请联系海康工作人员获取
* @param {*} timeout 超时时长,推荐配置15
*/
const httpGet=(url,headers,appKey,appSecret,timeout)=>{
return hikopenapi.artemisHttpGet(__dirname,url,headers,appKey,appSecret,timeout);
}
/** artemis封装delete接口
*
* @param {*} url 完整请求url,如https://123.123.123.123:443/artemis/api/video/v1/cameras/previewURLs
* @param {*} headers 请求头,json格式,如{"content-type":"application/json;charset=UTF-8","accept":"application/json"}
* @param {*} appKey 认证参数,请联系海康工作人员获取
* @param {*} appSecret 认证参数,请联系海康工作人员获取
* @param {*} timeout 超时时长,推荐配置15
*/
const httpDelete=(url,headers,appKey,appSecret,timeout)=>{
return hikopenapi.artemisHttpDelete(__dirname,url,headers,appKey,appSecret,timeout);
}
module.exports = {
httpPost,
httpGet,
httpPut,
httpDelete,
sayHello,
saySomething,
};