OpenerIntercomModel.js

  1. 'use strict';
  2. /**
  3. * This function returns the intercom models of all openers.
  4. *
  5. * @memberof Nuki
  6. * @description Get a list of intercom models for all of your openers
  7. * @param {Integer} [intercomId] The intercom id
  8. * @returns {Promise}
  9. * @see https://api.nuki.io/#!/OpenerIntercomModel
  10. */
  11. module.exports.getModel = function(intercomId)
  12. {
  13. let self = this;
  14. return this
  15. ._req('opener/intercom' + (intercomId ? '/' + intercomId : ''))
  16. .then(function(models)
  17. {
  18. if ((!intercomId && !Array.isArray(models)) || (intercomId && typeof models != 'object'))
  19. throw new Error('Did not receive models!');
  20. return models;
  21. });
  22. };