@ifings/api-client
Advanced tools
Comparing version 0.13.1 to 0.14.0
"use strict"; | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
var baseUrl = "FROST-Server/v1.0/Things"; | ||
@@ -14,4 +20,41 @@ | ||
return instance.get("".concat(baseUrl, "(").concat(id, ")")).query(query); | ||
}, | ||
aggregation: { | ||
getById: function getById(id) { | ||
return { | ||
withStatus: function withStatus() { | ||
var query = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
return instance.get("".concat(baseUrl, "(").concat(id, ")")).query(_objectSpread(_objectSpread({}, query), {}, { | ||
$expand: "Datastreams/Observations" | ||
})).then(function (res) { | ||
return _objectSpread(_objectSpread({}, res), {}, { | ||
status: res.Datastreams.reduce(function (acc, ds) { | ||
return ds.Observations.length !== 0 && acc === true; | ||
}, true) ? "online" : "offline" | ||
}); | ||
}); | ||
} | ||
}; | ||
}, | ||
getAll: function getAll() { | ||
return { | ||
withStatus: function withStatus() { | ||
var query = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
return instance.get(baseUrl).query(_objectSpread(_objectSpread({}, query), {}, { | ||
$expand: "Datastreams/Observations" | ||
})).then(function (res) { | ||
return res.map(function (thing) { | ||
var status = thing.Datastreams.reduce(function (acc, ds) { | ||
return ds.Observations.length !== 0 && acc === true; | ||
}, true); | ||
return _objectSpread(_objectSpread({}, thing), {}, { | ||
status: status ? "online" : "offline" | ||
}); | ||
}); | ||
}); | ||
} | ||
}; | ||
} | ||
} | ||
}; | ||
}; |
{ | ||
"name": "@ifings/api-client", | ||
"description": "iFings API client", | ||
"version": "0.13.1", | ||
"version": "0.14.0", | ||
"main": "dist/index.js", | ||
@@ -6,0 +6,0 @@ "scripts": { |
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
54436
515