UNPKG

node-flipr

Version:

Unofficial module for Flipr devices

63 lines (62 loc) 2.21 kB
"use strict"; /** * Main file of NodeFlipr project * @module Flipr * @author Nicolas Nunge <me@nikkow.eu> * @version 1.0.0 */ var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; function __export(m) { for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; } Object.defineProperty(exports, "__esModule", { value: true }); var network_1 = require("./classes/network"); var measure_1 = require("./classes/measure"); __export(require("./enums/deviation.enum")); __export(require("./enums/disinfectanttype.enum")); __export(require("./enums/temperature-unit.enum")); /** Class representing the main instance of Flipr */ var Flipr = /** @class */ (function () { /** * Creates a new instance of Flipr class. * @param {FliprConfigInterface} config User specific configuration. This will overwrite the default parameters. */ function Flipr(config) { this.defaultConfig = { username: null, password: null, deviceSerial: null }; if (!config.username) { throw new Error("You must set the username property."); } if (!config.password) { throw new Error("You must set the password property."); } this.config = __assign({}, this.defaultConfig, config); this.network = new network_1.Network(this.config); this.network.auth(); } /** * methodTwo description * @return {Promise<FliprMeasure>} Promise that will return a new instance of FliprMeasure, filled with the latest measure captured by Flipr. */ Flipr.prototype.getLastMeasure = function () { return this.network.get('/modules/' + this.config.deviceSerial + '/survey/last') .then(function (e) { return new measure_1.FliprMeasure(e); }); }; return Flipr; }()); exports.Flipr = Flipr;