node-ciscospark
Version:
Super-Simple Lightweight Javascript wrapper for Cisco Spark API
77 lines (58 loc) • 3.77 kB
JavaScript
;
/** @ignore */
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 _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var CiscoSpark = require('./CiscoSpark');
/**
* Spark People
* @see https://developer.ciscospark.com/resource-people.html
*/
var People = function (_CiscoSpark) {
_inherits(People, _CiscoSpark);
/**
* @constructor
* @param {string} [accessToken] - Your Cisco Spark accesstoken
* @param {string} [userAgent] - User Agent request header
*/
function People(accessToken, userAgent) {
_classCallCheck(this, People);
/** @private */
var _this = _possibleConstructorReturn(this, (People.__proto__ || Object.getPrototypeOf(People)).call(this, accessToken, userAgent, 'https://api.ciscospark.com/v1/people'));
_this.idName = 'personId';
return _this;
}
/**
* List People
* List people in your organization. For most users, either the email or a Display Name parameters are required.
* Admin users can omit these fields and list all users in their organization.
*
* @override
* @param {Object} params - see https://developer.ciscospark.com/endpoint-people-get.html
* @param {requestCallback} callback
*/
_createClass(People, [{
key: 'list',
value: function list(params, callback) {
if (typeof params === 'string') {
params = { email: params };
} else if (!params || !params.email || !params.displayName) {
return callback(new Error('Invalid Params. Require email or displayName'));
}
return _get(People.prototype.__proto__ || Object.getPrototypeOf(People.prototype), 'list', this).call(this, params, callback);
}
/**
* Get my own details
* @param {requestCallback} callback
*/
}, {
key: 'me',
value: function me(callback) {
return this.get('me', callback);
}
}]);
return People;
}(CiscoSpark);
module.exports = People;