UNPKG

nubli

Version:
43 lines (42 loc) 1.17 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const smartLockResponse_1 = require("../smartLockResponse"); class SmartLockCommand { constructor() { this._challenge = null; this._complete = false; this._response = new smartLockResponse_1.SmartLockResponse(); } set challenge(challenge) { this._challenge = challenge; } get challenge() { if (!this._challenge) { throw new Error("Challenge is null."); } return this._challenge; } get complete() { return this._complete; } get response() { return this._response; } set callback(callback) { this._callback = callback; } sendResponse() { if (this._callback) { this._callback(this._response); this._callback = undefined; } } sendFailure(errorMessage) { this._response.success = false; if (errorMessage !== undefined && errorMessage !== null) { this._response.message = errorMessage; } this.sendResponse(); } } exports.SmartLockCommand = SmartLockCommand;