holly-sdk
Version:
More details coming soon.
55 lines (42 loc) • 1.93 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.Device = undefined;
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _got = require("got");
var _got2 = _interopRequireDefault(_got);
var _event = require("./event");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var Device = exports.Device = function () {
function Device(app, device) {
_classCallCheck(this, Device);
this.app = app;
this.id = device.id;
this.name = device.name;
this.type = device.type;
this.capabilities = device.capabilities;
this.platformInformation = device.platform_information;
if (device.latest_event) {
this.latestEvent = new _event.Event(app, device.latest_event);
} else {
this.latestEvent = null;
}
}
// Send an instruction to a device
_createClass(Device, [{
key: "sendInstruction",
value: function sendInstruction(instruction) {
return this.app.api.devices.instruct(this.id, instruction);
}
}, {
key: "hasCapability",
value: function hasCapability(capability) {
return this.capabilities.some(function (c) {
return c === capability;
});
}
}]);
return Device;
}();