datahub-nodejs-sdk
Advanced tools
Comparing version 1.1.0 to 2.0.0
@@ -100,92 +100,4 @@ 'use strict'; | ||
} | ||
/** | ||
* update scene by projectId and dataId. | ||
* @async | ||
* @param {string} projectId | ||
* @param {string} dataId | ||
* @returns {Promise} | ||
*/ | ||
async updateSceneByProjectIdAndDataId (projectId, dataId, { | ||
currentScene, | ||
delay, | ||
statusCode, | ||
responseHeaders, | ||
}) { | ||
assertArgument(projectId, 'projectId is required'); | ||
assertArgument(dataId, 'dataId is required'); | ||
const res = await this.getDataByProjectIdAndDataId(projectId, dataId); | ||
if (!res.success) { | ||
return this.EXCEPTION_RESPONSE; | ||
} | ||
let proxyContent = {}; | ||
try { | ||
proxyContent = JSON.parse(res.data.proxyContent); | ||
} catch (_) { /* ignore invalid proxyContent */ } | ||
proxyContent.statusCode = statusCode; | ||
proxyContent.responseHeaders = responseHeaders; | ||
return this.post(`data/${projectId}/${dataId}`, { | ||
currentScene, | ||
delay, | ||
proxyContent: JSON.stringify(proxyContent), | ||
}); | ||
} | ||
/** | ||
* update multiple data | ||
* @async | ||
* @param {object} data list | ||
* @returns {Promise} | ||
*/ | ||
async updateMultiData (data) { | ||
assertArgument(data, 'data is required'); | ||
return this.post('multi/data', data); | ||
} | ||
/** | ||
* get data list by projectId and dataId. | ||
* @async | ||
* @param {string} projectId | ||
* @param {string} dataId | ||
* @returns {Promise} | ||
*/ | ||
async getDataByProjectIdAndDataId (projectId, dataId) { | ||
assertArgument(projectId, 'projectId is required'); | ||
assertArgument(dataId, 'dataId is required'); | ||
return this.get(`data/${projectId}/${dataId}`); | ||
} | ||
/** | ||
* get data list by projectId. | ||
* @async | ||
* @param {string} projectId | ||
* @returns {Promise} | ||
*/ | ||
async getDataListByProjectId (projectId) { | ||
assertArgument(projectId, 'projectId is required'); | ||
return this.get(`data/${projectId}`); | ||
} | ||
/** | ||
* get scene data | ||
* @async | ||
* @param {string} projectId | ||
* @param {string} dataId | ||
* @param {string} sceneId | ||
* @returns {Object} scene data | ||
*/ | ||
async getSceneDataByProjectIdAndDataId (projectId, dataId, sceneId) { | ||
assertArgument(projectId, 'projectId is required'); | ||
assertArgument(dataId, 'dataId is required'); | ||
assertArgument(sceneId, 'sceneId is required'); | ||
const res = await this.getDataByProjectIdAndDataId(projectId, dataId); | ||
try { | ||
const jsonData = JSON.parse(res.data.scenes); | ||
return jsonData.find(i => i.name === sceneId).data; | ||
} catch (_) { | ||
return {}; | ||
} | ||
} | ||
} | ||
module.exports = DataHubSDK; |
{ | ||
"name": "datahub-nodejs-sdk", | ||
"version": "1.1.0", | ||
"version": "2.0.0", | ||
"description": "DataHub Node.js SDK", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1472056
1346