UNPKG

browser-sdk

Version:

javascript SDK for the lightelligence-platform

124 lines (108 loc) 4.14 kB
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); Object.defineProperty(exports, "__esModule", { value: true }); exports["default"] = void 0; var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass")); var _apiService = _interopRequireDefault(require("../tools/apiService")); /** * Methods for device type operations */ var DeviceType = /*#__PURE__*/ function () { function DeviceType() { (0, _classCallCheck2["default"])(this, DeviceType); } (0, _createClass2["default"])(DeviceType, null, [{ key: "createDeviceType", /** * Creates a new device type * @param {object} deviceType * @returns {Promise} */ value: function createDeviceType(deviceType) { return _apiService["default"].call('/device-types', 'POST', deviceType); } /** * Get all device types * @param {object} params * @param {number} [params.page=0] The number of the result page starting with 0 * @param {number} [params.pageSize=10] The number of result per page. Default is 10 * @param {string} [params.name=undefined] Filter the results to contain only devices having the provided name. Case-insensitive. Surround with * for substring matching. Example: &subString* OR fullMatchingName * @returns {Promise} */ }, { key: "getDeviceTypes", value: function getDeviceTypes(params) { var urlParams = new URLSearchParams(params); return _apiService["default"].call("/device-types?".concat(urlParams.toString())); } /** * Returns a list of semantic categories used in your device types. * @returns {Promise} */ }, { key: "getUsedCategories", value: function getUsedCategories() { return _apiService["default"].call("/device-types/categories"); } /** * Get a specific device-type by id * @param {string} deviceTypeId * @returns {Promise} */ }, { key: "getDeviceType", value: function getDeviceType(deviceTypeId) { return _apiService["default"].call("/device-types/".concat(deviceTypeId)); } /** * Edit a specific device-type by id partially. Id is not patchable. You can also only patch a single property from your custom data. To delete submit null. * @param {string} deviceTypeId * @param {object} patch changes to device type * @returns {Promise} */ }, { key: "patchDeviceType", value: function patchDeviceType(deviceTypeId, patch) { return _apiService["default"].call("/device-types/".concat(deviceTypeId), 'PATCH', patch); } /** * Delete a specific device-type by id. Note: you can not delete device type if it's attached to at least one device * @param {string} deviceTypeId * @returns {Promise} */ }, { key: "deleteDeviceType", value: function deleteDeviceType(deviceTypeId) { return _apiService["default"].call("/device-types/".concat(deviceTypeId), 'DELETE'); } /** * Get the online monitoring configuration for a device type * @param {string} deviceTypeId * @returns {Promise} */ }, { key: "getOnlineMonitoringRules", value: function getOnlineMonitoringRules(deviceTypeId) { return _apiService["default"].call("/device-types/".concat(deviceTypeId, "/onlinemonitoring")); } /** * Edit the online monitoring configuration for a device type * @param {string} deviceTypeId * @param {object} config changes to device * @param {number|null} config.communicationInterval The expected communication interval in seconds. Special cases: **null** and **0** mean monitoring is disabled * @returns {Promise} */ }, { key: "patchOnlineMonitoringRules", value: function patchOnlineMonitoringRules(deviceTypeId, config) { return _apiService["default"].call("/device-types/".concat(deviceTypeId, "/onlinemonitoring"), 'PATCH', config); } }]); return DeviceType; }(); exports["default"] = DeviceType;