@webex/plugin-people 3.0.0-beta.13 → 3.0.0-beta.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -29,15 +29,12 @@ npm install --save @webex/plugin-people
29
29
  ## Usage
30
30
 
31
31
  ```js
32
-
33
32
  const Webex = require('webex');
34
33
 
35
34
  const webex = Webex.init();
36
- webex.people.get(id)
37
- .then((people) => {
38
- console.log(people);
39
- })
40
-
35
+ webex.people.get(id).then((people) => {
36
+ console.log(people);
37
+ });
41
38
  ```
42
39
 
43
40
  ## Maintainers
@@ -1 +1 @@
1
- {"version":3,"names":["people","batcherWait","batcherMaxCalls","batcherMaxWait","showAllTypes"],"sources":["config.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nexport default {\n people: {\n batcherWait: 100,\n batcherMaxCalls: 10,\n batcherMaxWait: 1500,\n /**\n * optional flag that requires Hydra to send every type field,\n * even if the type is not \"person\" (e.g.: SX10, webhook_integration, etc.)\n * @private\n */\n showAllTypes: false\n }\n};\n"],"mappings":";;;;;;;;;;AAAA;AACA;AACA;eAEe;EACbA,MAAM,EAAE;IACNC,WAAW,EAAE,GADP;IAENC,eAAe,EAAE,EAFX;IAGNC,cAAc,EAAE,IAHV;;IAIN;AACJ;AACA;AACA;AACA;IACIC,YAAY,EAAE;EATR;AADK,C"}
1
+ {"version":3,"names":["people","batcherWait","batcherMaxCalls","batcherMaxWait","showAllTypes"],"sources":["config.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nexport default {\n people: {\n batcherWait: 100,\n batcherMaxCalls: 10,\n batcherMaxWait: 1500,\n /**\n * optional flag that requires Hydra to send every type field,\n * even if the type is not \"person\" (e.g.: SX10, webhook_integration, etc.)\n * @private\n */\n showAllTypes: false,\n },\n};\n"],"mappings":";;;;;;;;;;AAAA;AACA;AACA;eAEe;EACbA,MAAM,EAAE;IACNC,WAAW,EAAE,GADP;IAENC,eAAe,EAAE,EAFX;IAGNC,cAAc,EAAE,IAHV;;IAIN;AACJ;AACA;AACA;AACA;IACIC,YAAY,EAAE;EATR;AADK,C"}
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["registerPlugin","People","config"],"sources":["index.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport {registerPlugin} from '@webex/webex-core';\n\nimport People from './people';\nimport config from './config';\n\nregisterPlugin('people', People, {\n config\n});\n\nexport {default} from './people';\n"],"mappings":";;;;;;;;;;;;;;;;;AAIA;;AAEA;;AACA;;AAPA;AACA;AACA;AAOA,IAAAA,yBAAA,EAAe,QAAf,EAAyBC,eAAzB,EAAiC;EAC/BC,MAAM,EAANA;AAD+B,CAAjC"}
1
+ {"version":3,"names":["registerPlugin","People","config"],"sources":["index.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport {registerPlugin} from '@webex/webex-core';\n\nimport People from './people';\nimport config from './config';\n\nregisterPlugin('people', People, {\n config,\n});\n\nexport {default} from './people';\n"],"mappings":";;;;;;;;;;;;;;;;;AAIA;;AAEA;;AACA;;AAPA;AACA;AACA;AAOA,IAAAA,yBAAA,EAAe,QAAf,EAAyBC,eAAzB,EAAiC;EAC/BC,MAAM,EAANA;AAD+B,CAAjC"}
@@ -1 +1 @@
1
- {"version":3,"names":["PersonUUIDRequestBatcher","Batcher","extend","namespace","handleHttpSuccess","res","promises","body","items","map","personResponse","handleItemSuccess","id","notFoundIds","concat","handleItemFailure","all","getDeferredForResponse","then","defer","reject","email","response","resolve","fingerprintRequest","uuidOrHydraId","hydraId","webex","people","inferPersonIdFromUuid","fingerprintResponse","prepareRequest","ids","join","submitHttpRequest","request","service","resource","config","showAllTypes"],"sources":["people-batcher.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport {Batcher} from '@webex/webex-core';\n\n/**\n * @class\n * @ignore\n */\nconst PersonUUIDRequestBatcher = Batcher.extend({\n namespace: 'People',\n\n /**\n * @instance\n * @memberof PersonUUIDRequestBatcher\n * @param {HttpResponseObject} res\n * @returns {Promise}\n */\n handleHttpSuccess(res) {\n const promises = res.body.items.map((personResponse) =>\n this.handleItemSuccess(personResponse.id, personResponse));\n\n if (res.body.notFoundIds) {\n promises.concat(res.body.notFoundIds.map((id) =>\n this.handleItemFailure(id)));\n }\n\n return Promise.all(promises);\n },\n\n handleItemFailure(id) {\n return this.getDeferredForResponse(id)\n .then((defer) => {\n defer.reject(id);\n });\n },\n\n /**\n * @instance\n * @memberof PersonUUIDRequestBatcher\n * @param {string} email\n * @param {Object} response\n * @returns {Promise}\n */\n handleItemSuccess(email, response) {\n return this.getDeferredForResponse(email)\n .then((defer) => {\n defer.resolve(response);\n });\n },\n\n /**\n * @instance\n * @memberof PersonUUIDRequestBatcher\n * @param {string} uuidOrHydraId\n * @returns {Promise<string>}\n */\n fingerprintRequest(uuidOrHydraId) {\n const hydraId = this.webex.people.inferPersonIdFromUuid(uuidOrHydraId);\n\n return Promise.resolve(hydraId);\n },\n\n /**\n * @instance\n * @memberof PersonUUIDRequestBatcher\n * @param {string} hydraId\n * @returns {Promise<string>}\n */\n fingerprintResponse(hydraId) {\n return Promise.resolve(hydraId);\n },\n\n prepareRequest(ids) {\n return Promise.resolve(ids.join());\n },\n\n /**\n * @instance\n * @memberof PersonUUIDRequestBatcher\n * @param {Object} ids\n * @returns {Promise<HttpResponseObject>}\n */\n submitHttpRequest(ids) {\n return this.webex.request({\n service: 'hydra',\n resource: `people/?id=${ids}&showAllTypes=${this.config.showAllTypes}`\n });\n }\n});\n\nexport default PersonUUIDRequestBatcher;\n"],"mappings":";;;;;;;;;;;;;;AAIA;;AAJA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA,IAAMA,wBAAwB,GAAG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AQF,OAAR,CAAgBG,OAAhB,CAAP;EACD,CApD6C;;EAsD9C;AACF;AACA;AACA;AACA;AACA;EACEI,mBA5D8C,+BA4D1BJ,OA5D0B,EA4DjB;IAC3B,OAAO,iBAAQH,OAAR,CAAgBG,OAAhB,CAAP;EACD,CA9D6C;EAgE9CK,cAhE8C,0BAgE/BC,GAhE+B,EAgE1B;IAClB,OAAO,iBAAQT,OAAR,CAAgBS,GAAG,CAACC,IAAJ,EAAhB,CAAP;EACD,CAlE6C;;EAoE9C;AACF;AACA;AACA;AACA;AACA;EACEC,iBA1E8C,6BA0E5BF,GA1E4B,EA0EvB;IACrB,OAAO,KAAKL,KAAL,CAAWQ,OAAX,CAAmB;MACxBC,OAAO,EAAE,OADe;MAExBC,QAAQ,uBAAgBL,GAAhB,2BAAoC,KAAKM,MAAL,CAAYC,YAAhD;IAFgB,CAAnB,CAAP;EAID;AA/E6C,CAAf,CAAjC;;eAkFevC,wB"}
1
+ {"version":3,"names":["PersonUUIDRequestBatcher","Batcher","extend","namespace","handleHttpSuccess","res","promises","body","items","map","personResponse","handleItemSuccess","id","notFoundIds","concat","handleItemFailure","all","getDeferredForResponse","then","defer","reject","email","response","resolve","fingerprintRequest","uuidOrHydraId","hydraId","webex","people","inferPersonIdFromUuid","fingerprintResponse","prepareRequest","ids","join","submitHttpRequest","request","service","resource","config","showAllTypes"],"sources":["people-batcher.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport {Batcher} from '@webex/webex-core';\n\n/**\n * @class\n * @ignore\n */\nconst PersonUUIDRequestBatcher = Batcher.extend({\n namespace: 'People',\n\n /**\n * @instance\n * @memberof PersonUUIDRequestBatcher\n * @param {HttpResponseObject} res\n * @returns {Promise}\n */\n handleHttpSuccess(res) {\n const promises = res.body.items.map((personResponse) =>\n this.handleItemSuccess(personResponse.id, personResponse)\n );\n\n if (res.body.notFoundIds) {\n promises.concat(res.body.notFoundIds.map((id) => this.handleItemFailure(id)));\n }\n\n return Promise.all(promises);\n },\n\n handleItemFailure(id) {\n return this.getDeferredForResponse(id).then((defer) => {\n defer.reject(id);\n });\n },\n\n /**\n * @instance\n * @memberof PersonUUIDRequestBatcher\n * @param {string} email\n * @param {Object} response\n * @returns {Promise}\n */\n handleItemSuccess(email, response) {\n return this.getDeferredForResponse(email).then((defer) => {\n defer.resolve(response);\n });\n },\n\n /**\n * @instance\n * @memberof PersonUUIDRequestBatcher\n * @param {string} uuidOrHydraId\n * @returns {Promise<string>}\n */\n fingerprintRequest(uuidOrHydraId) {\n const hydraId = this.webex.people.inferPersonIdFromUuid(uuidOrHydraId);\n\n return Promise.resolve(hydraId);\n },\n\n /**\n * @instance\n * @memberof PersonUUIDRequestBatcher\n * @param {string} hydraId\n * @returns {Promise<string>}\n */\n fingerprintResponse(hydraId) {\n return Promise.resolve(hydraId);\n },\n\n prepareRequest(ids) {\n return Promise.resolve(ids.join());\n },\n\n /**\n * @instance\n * @memberof PersonUUIDRequestBatcher\n * @param {Object} ids\n * @returns {Promise<HttpResponseObject>}\n */\n submitHttpRequest(ids) {\n return this.webex.request({\n service: 'hydra',\n resource: `people/?id=${ids}&showAllTypes=${this.config.showAllTypes}`,\n });\n },\n});\n\nexport default PersonUUIDRequestBatcher;\n"],"mappings":";;;;;;;;;;;;;;AAIA;;AAJA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA,IAAMA,wBAAwB,GAAGC,kBAAA,CAAQC,MAAR,CAAe;EAC9CC,SAAS,EAAE,QADmC;;EAG9C;AACF;AACA;AACA;AACA;AACA;EACEC,iBAT8C,6BAS5BC,GAT4B,EASvB;IAAA;;IACrB,IAAMC,QAAQ,GAAGD,GAAG,CAACE,IAAJ,CAASC,KAAT,CAAeC,GAAf,CAAmB,UAACC,cAAD;MAAA,OAClC,KAAI,CAACC,iBAAL,CAAuBD,cAAc,CAACE,EAAtC,EAA0CF,cAA1C,CADkC;IAAA,CAAnB,CAAjB;;IAIA,IAAIL,GAAG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ACF;AACA;AACA;AACA;AACA;EACEC,iBAxE8C,6BAwE5BF,GAxE4B,EAwEvB;IACrB,OAAO,KAAKL,KAAL,CAAWQ,OAAX,CAAmB;MACxBC,OAAO,EAAE,OADe;MAExBC,QAAQ,uBAAgBL,GAAhB,2BAAoC,KAAKM,MAAL,CAAYC,YAAhD;IAFgB,CAAnB,CAAP;EAID;AA7E6C,CAAf,CAAjC;;eAgFevC,wB"}
package/dist/people.js CHANGED
@@ -210,7 +210,7 @@ var People = _webexCore.WebexPlugin.extend((_obj = {
210
210
  return res.body;
211
211
  });
212
212
  },
213
- version: "3.0.0-beta.13"
213
+ version: "3.0.0-beta.15"
214
214
  }, ((0, _applyDecoratedDescriptor2.default)(_obj, "_getMe", [_common.oneFlight], (0, _getOwnPropertyDescriptor.default)(_obj, "_getMe"), _obj)), _obj));
215
215
 
216
216
  var _default = People;
@@ -1 +1 @@
1
- {"version":3,"names":["People","WebexPlugin","extend","namespace","children","batcher","PeopleBatcher","get","person","reject","Error","_getMe","id","personId","request","list","options","peopleIds","all","map","service","resource","qs","then","res","Page","webex","inferPersonIdFromUuid","base64","decode","includes","err","encode","body","oneFlight"],"sources":["people.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport {WebexPlugin, Page} from '@webex/webex-core';\nimport {base64, oneFlight} from '@webex/common';\n\nimport PeopleBatcher from './people-batcher';\n\n/**\n * @typedef {Object} PersonObject\n * @property {string} id - (server generated) Unique identifier for the person\n * @property {Array<email>} emails - Email addresses of the person\n * @property {string} displayName - Display name of the person\n * @property {isoDate} created - (server generated) The date and time that the person was created\n */\n\n/**\n * @class\n */\nconst People = WebexPlugin.extend({\n namespace: 'People',\n\n children: {\n batcher: PeopleBatcher\n },\n /**\n * Returns a single person by ID\n * @instance\n * @memberof People\n * @param {PersonObject|uuid|string} person\n * @returns {Promise<PersonObject>}\n * @example\n * webex.rooms.create({title: 'Get Person Example'})\n * .then(function(room) {\n * return webex.memberships.create({\n * personEmail: 'alice@example.com',\n * roomId: room.id\n * });\n * })\n * .then(function(membership) {\n * return webex.people.get(membership.personId);\n * })\n * .then(function(alice) {\n * var assert = require('assert');\n * assert(alice.id);\n * assert(Array.isArray(alice.emails));\n * assert.equal(alice.emails.filter(function(email) {\n * return email === 'alice@example.com';\n * }).length, 1);\n * assert(alice.displayName);\n * assert(alice.created);\n * return 'success';\n * });\n * // => success\n */\n get(person) {\n if (!person) {\n return Promise.reject(new Error('A person with an id is required'));\n }\n if (person === 'me') {\n return this._getMe();\n }\n const id = person.personId || person.id || person;\n\n return this.batcher.request(id);\n },\n\n /**\n * Returns a list of people\n * @instance\n * @memberof People\n * @param {Object | uuid[]} options or array of uuids\n * @param {email} options.email - Returns people with an email that contains this string\n * @param {string} options.displayName - Returns people with a name that contains this string\n * @param {bool} showAllTypes optional flag that requires Hydra to send every type field,\n * even if the type is not \"person\" (e.g.: SX10, webhook_integration, etc.)\n * @returns {Promise<Page<PersonObject>>}\n * @example\n * var room;\n * webex.rooms.create({title: 'List People Example'})\n * .then(function(r) {\n * room = r;\n * return webex.memberships.create({\n * personEmail: 'alice@example.com',\n * roomId: room.id\n * });\n * })\n * .then(function() {\n * return webex.memberships.create({\n * personEmail: 'bob@example.com',\n * roomId: room.id\n * });\n * })\n * .then(function() {\n * return webex.people.list({email: 'alice@example.com'});\n * })\n * .then(function(people) {\n * var assert = require('assert');\n * assert.equal(people.length, 1);\n * var person = people.items[0];\n * assert(person.id);\n * assert(Array.isArray(person.emails));\n * assert(person.displayName);\n * assert(person.created);\n * return 'success';\n * });\n * // => success\n * @example <caption>Example usage of array method</caption>\n * var room;\n * var aliceId;\n * var bobId;\n * webex.rooms.create({title: 'List People Array Example'})\n * .then(function(r) {\n * room = r;\n * return webex.memberships.create({\n * personEmail: 'alice@example.com',\n * roomId: room.id\n * });\n * })\n * .then(function(membership) {\n * aliceId = membership.personId;\n * })\n * .then(function() {\n * return webex.memberships.create({\n * personEmail: 'bob@example.com',\n * roomId: room.id\n * });\n * })\n * .then(function(membership) {\n * bobId = membership.personId;\n * })\n * .then(function() {\n * return webex.people.list([aliceId, bobId]);\n * })\n * .then(function(people) {\n * var assert = require('assert');\n * assert.equal(people.length, 2);\n * var person = people.items[0];\n * assert(person.id);\n * assert(Array.isArray(person.emails));\n * assert(person.displayName);\n * assert(person.created);\n * return 'success';\n * });\n * // => success\n */\n list(options) {\n if (Array.isArray(options)) {\n const peopleIds = options;\n\n return Promise.all(peopleIds.map((personId) => this.batcher.request(personId)));\n }\n\n return this.request({\n service: 'hydra',\n resource: 'people',\n qs: options\n })\n .then((res) => new Page(res, this.webex));\n },\n\n /**\n * Converts a uuid to a hydra id without a network dip.\n * @param {string} id\n * @private\n * @returns {string}\n */\n inferPersonIdFromUuid(id) {\n // base64.validate seems to return true for uuids, so we need a different\n // check\n try {\n if (base64.decode(id).includes('ciscospark://')) {\n return id;\n }\n }\n catch (err) {\n // ignore\n }\n\n return base64.encode(`ciscospark://us/PEOPLE/${id}`);\n },\n\n /**\n * Fetches the current user from the /people/me endpoint\n * @instance\n * @memberof People\n * @private\n * @returns {Promise<PersonObject>}\n */\n @oneFlight\n _getMe() {\n return this.webex.request({\n service: 'hydra',\n resource: 'people/me'\n })\n .then((res) => res.body);\n }\n});\n\nexport default People;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAIA;;AACA;;AAEA;;;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,IAAMA,MAAM,GAAGC,sBAAA,CAAYC,MAAZ,SAAmB;EAChCC,SAAS,EAAE,QADqB;EAGhCC,QAAQ,EAAE;IACRC,OAAO,EAAEC;EADD,CAHsB;;EAMhC;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACEC,GApCgC,eAoC5BC,MApC4B,EAoCpB;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IAAA,CALD,CAAP;EAMD,CA5I+B;;EA8IhC;AACF;AACA;AACA;AACA;AACA;EACEC,qBApJgC,iCAoJVf,EApJU,EAoJN;IACxB;IACA;IACA,IAAI;MACF,IAAIgB,cAAA,CAAOC,MAAP,CAAcjB,EAAd,EAAkBkB,QAAlB,CAA2B,eAA3B,CAAJ,EAAiD;QAC/C,OAAOlB,EAAP;MACD;IACF,CAJD,CAKA,OAAOmB,GAAP,EAAY,CACV;IACD;;IAED,OAAOH,cAAA,CAAOI,MAAP,kCAAwCpB,EAAxC,EAAP;EACD,CAjK+B;EA2KhCD,MA3KgC,oBA2KvB;IACP,OAAO,KAAKe,KAAL,CAAWZ,OAAX,CAAmB;MACxBM,OAAO,EAAE,OADe;MAExBC,QAAQ,EAAE;IAFc,CAAnB,EAIJE,IAJI,CAIC,UAACC,GAAD;MAAA,OAASA,GAAG,CAACS,IAAb;IAAA,CAJD,CAAP;EAKD,CAjL+B;EAAA;AAAA,CAAnB,4DA0KZC,iBA1KY,yEAAf;;eAoLelC,M"}
1
+ {"version":3,"names":["People","WebexPlugin","extend","namespace","children","batcher","PeopleBatcher","get","person","reject","Error","_getMe","id","personId","request","list","options","peopleIds","all","map","service","resource","qs","then","res","Page","webex","inferPersonIdFromUuid","base64","decode","includes","err","encode","body","oneFlight"],"sources":["people.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport {WebexPlugin, Page} from '@webex/webex-core';\nimport {base64, oneFlight} from '@webex/common';\n\nimport PeopleBatcher from './people-batcher';\n\n/**\n * @typedef {Object} PersonObject\n * @property {string} id - (server generated) Unique identifier for the person\n * @property {Array<email>} emails - Email addresses of the person\n * @property {string} displayName - Display name of the person\n * @property {isoDate} created - (server generated) The date and time that the person was created\n */\n\n/**\n * @class\n */\nconst People = WebexPlugin.extend({\n namespace: 'People',\n\n children: {\n batcher: PeopleBatcher,\n },\n /**\n * Returns a single person by ID\n * @instance\n * @memberof People\n * @param {PersonObject|uuid|string} person\n * @returns {Promise<PersonObject>}\n * @example\n * webex.rooms.create({title: 'Get Person Example'})\n * .then(function(room) {\n * return webex.memberships.create({\n * personEmail: 'alice@example.com',\n * roomId: room.id\n * });\n * })\n * .then(function(membership) {\n * return webex.people.get(membership.personId);\n * })\n * .then(function(alice) {\n * var assert = require('assert');\n * assert(alice.id);\n * assert(Array.isArray(alice.emails));\n * assert.equal(alice.emails.filter(function(email) {\n * return email === 'alice@example.com';\n * }).length, 1);\n * assert(alice.displayName);\n * assert(alice.created);\n * return 'success';\n * });\n * // => success\n */\n get(person) {\n if (!person) {\n return Promise.reject(new Error('A person with an id is required'));\n }\n if (person === 'me') {\n return this._getMe();\n }\n const id = person.personId || person.id || person;\n\n return this.batcher.request(id);\n },\n\n /**\n * Returns a list of people\n * @instance\n * @memberof People\n * @param {Object | uuid[]} options or array of uuids\n * @param {email} options.email - Returns people with an email that contains this string\n * @param {string} options.displayName - Returns people with a name that contains this string\n * @param {bool} showAllTypes optional flag that requires Hydra to send every type field,\n * even if the type is not \"person\" (e.g.: SX10, webhook_integration, etc.)\n * @returns {Promise<Page<PersonObject>>}\n * @example\n * var room;\n * webex.rooms.create({title: 'List People Example'})\n * .then(function(r) {\n * room = r;\n * return webex.memberships.create({\n * personEmail: 'alice@example.com',\n * roomId: room.id\n * });\n * })\n * .then(function() {\n * return webex.memberships.create({\n * personEmail: 'bob@example.com',\n * roomId: room.id\n * });\n * })\n * .then(function() {\n * return webex.people.list({email: 'alice@example.com'});\n * })\n * .then(function(people) {\n * var assert = require('assert');\n * assert.equal(people.length, 1);\n * var person = people.items[0];\n * assert(person.id);\n * assert(Array.isArray(person.emails));\n * assert(person.displayName);\n * assert(person.created);\n * return 'success';\n * });\n * // => success\n * @example <caption>Example usage of array method</caption>\n * var room;\n * var aliceId;\n * var bobId;\n * webex.rooms.create({title: 'List People Array Example'})\n * .then(function(r) {\n * room = r;\n * return webex.memberships.create({\n * personEmail: 'alice@example.com',\n * roomId: room.id\n * });\n * })\n * .then(function(membership) {\n * aliceId = membership.personId;\n * })\n * .then(function() {\n * return webex.memberships.create({\n * personEmail: 'bob@example.com',\n * roomId: room.id\n * });\n * })\n * .then(function(membership) {\n * bobId = membership.personId;\n * })\n * .then(function() {\n * return webex.people.list([aliceId, bobId]);\n * })\n * .then(function(people) {\n * var assert = require('assert');\n * assert.equal(people.length, 2);\n * var person = people.items[0];\n * assert(person.id);\n * assert(Array.isArray(person.emails));\n * assert(person.displayName);\n * assert(person.created);\n * return 'success';\n * });\n * // => success\n */\n list(options) {\n if (Array.isArray(options)) {\n const peopleIds = options;\n\n return Promise.all(peopleIds.map((personId) => this.batcher.request(personId)));\n }\n\n return this.request({\n service: 'hydra',\n resource: 'people',\n qs: options,\n }).then((res) => new Page(res, this.webex));\n },\n\n /**\n * Converts a uuid to a hydra id without a network dip.\n * @param {string} id\n * @private\n * @returns {string}\n */\n inferPersonIdFromUuid(id) {\n // base64.validate seems to return true for uuids, so we need a different\n // check\n try {\n if (base64.decode(id).includes('ciscospark://')) {\n return id;\n }\n } catch (err) {\n // ignore\n }\n\n return base64.encode(`ciscospark://us/PEOPLE/${id}`);\n },\n\n /**\n * Fetches the current user from the /people/me endpoint\n * @instance\n * @memberof People\n * @private\n * @returns {Promise<PersonObject>}\n */\n @oneFlight\n _getMe() {\n return this.webex\n .request({\n service: 'hydra',\n resource: 'people/me',\n })\n .then((res) => res.body);\n },\n});\n\nexport default People;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAIA;;AACA;;AAEA;;;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,IAAMA,MAAM,GAAGC,sBAAA,CAAYC,MAAZ,SAAmB;EAChCC,SAAS,EAAE,QADqB;EAGhCC,QAAQ,EAAE;IACRC,OAAO,EAAEC;EADD,CAHsB;;EAMhC;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACEC,GApCgC,eAoC5BC,MApC4B,EAoCpB;IACV,IAAI,CAACA,MAAL,EAAa;MACX,OAAO,iBAAQC,MAAR,CAAe,IAAIC,KAAJ,CAAU,iCAAV,CAAf,CAAP;IACD;;IACD,IAAIF,MAAM,KAAK,IAAf,EAAqB;MACnB,OAAO,KAAKG,MAAL,EAAP;IACD;;IACD,IAAMC,EAAE,GAAGJ,MAAM,CAACK,QAAP,IAAmBL,MAAM,CAACI,EAA1B,IAAgCJ,MAA3C;IAEA,OAAO,KAAKH,OAAL,CAAaS,OAAb,CAAqBF,EAArB,CAAP;EACD,CA9C+B;;EAgDhC;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACEG,IA/HgC,gBA+H3BC,OA/H2B,EA+HlB;IAAA;;IACZ,IAAI,sBAAcA,OAAd,CAAJ,EAA4B;MAC1B,IAAMC,SAAS,GAAGD,OAAlB;MAEA,OAAO,iBAAQE,GAAR,CAAYD,SAAS,CAACE,GAAV,CAAc,UAACN,QAAD;QAAA,OAAc,KAAI,CAACR,OAAL,CAAaS,OAAb,CAAqBD,QAArB,CAAd;MAAA,CAAd,CAAZ,CAAP;IACD;;IAED,OAAO,KAAKC,OAAL,CAAa;MAClBM,OAAO,EAAE,OADS;MAElBC,QAAQ,EAAE,QAFQ;MAGlBC,EAAE,EAAEN;IAHc,CAAb,EAIJO,IAJI,CAIC,UAACC,GAAD;MAAA,OAAS,IAAIC,eAAJ,CAASD,GAAT,EAAc,KAAI,CAACE,KAAnB,CAAT;IAAA,CAJD,CAAP;EAKD,CA3I+B;;EA6IhC;AACF;AACA;AACA;AACA;AACA;EACEC,qBAnJgC,iCAmJVf,EAnJU,EAmJN;IACxB;IACA;IACA,IAAI;MACF,IAAIgB,cAAA,CAAOC,MAAP,CAAcjB,EAAd,EAAkBkB,QAAlB,CAA2B,eAA3B,CAAJ,EAAiD;QAC/C,OAAOlB,EAAP;MACD;IACF,CAJD,CAIE,OAAOmB,GAAP,EAAY,CACZ;IACD;;IAED,OAAOH,cAAA,CAAOI,MAAP,kCAAwCpB,EAAxC,EAAP;EACD,CA/J+B;EAyKhCD,MAzKgC,oBAyKvB;IACP,OAAO,KAAKe,KAAL,CACJZ,OADI,CACI;MACPM,OAAO,EAAE,OADF;MAEPC,QAAQ,EAAE;IAFH,CADJ,EAKJE,IALI,CAKC,UAACC,GAAD;MAAA,OAASA,GAAG,CAACS,IAAb;IAAA,CALD,CAAP;EAMD,CAhL+B;EAAA;AAAA,CAAnB,4DAwKZC,iBAxKY,yEAAf;;eAmLelC,M"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webex/plugin-people",
3
- "version": "3.0.0-beta.13",
3
+ "version": "3.0.0-beta.15",
4
4
  "description": "",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -20,15 +20,15 @@
20
20
  ]
21
21
  },
22
22
  "devDependencies": {
23
- "@webex/test-helper-chai": "3.0.0-beta.13",
24
- "@webex/test-helper-mock-webex": "3.0.0-beta.13",
25
- "@webex/test-helper-test-users": "3.0.0-beta.13",
23
+ "@webex/test-helper-chai": "3.0.0-beta.15",
24
+ "@webex/test-helper-mock-webex": "3.0.0-beta.15",
25
+ "@webex/test-helper-test-users": "3.0.0-beta.15",
26
26
  "sinon": "^9.2.4"
27
27
  },
28
28
  "dependencies": {
29
- "@webex/common": "3.0.0-beta.13",
30
- "@webex/internal-plugin-mercury": "3.0.0-beta.13",
31
- "@webex/plugin-people": "3.0.0-beta.13",
32
- "@webex/webex-core": "3.0.0-beta.13"
29
+ "@webex/common": "3.0.0-beta.15",
30
+ "@webex/internal-plugin-mercury": "3.0.0-beta.15",
31
+ "@webex/plugin-people": "3.0.0-beta.15",
32
+ "@webex/webex-core": "3.0.0-beta.15"
33
33
  }
34
34
  }
package/src/config.js CHANGED
@@ -12,6 +12,6 @@ export default {
12
12
  * even if the type is not "person" (e.g.: SX10, webhook_integration, etc.)
13
13
  * @private
14
14
  */
15
- showAllTypes: false
16
- }
15
+ showAllTypes: false,
16
+ },
17
17
  };
package/src/index.js CHANGED
@@ -8,7 +8,7 @@ import People from './people';
8
8
  import config from './config';
9
9
 
10
10
  registerPlugin('people', People, {
11
- config
11
+ config,
12
12
  });
13
13
 
14
14
  export {default} from './people';
@@ -19,21 +19,20 @@ const PersonUUIDRequestBatcher = Batcher.extend({
19
19
  */
20
20
  handleHttpSuccess(res) {
21
21
  const promises = res.body.items.map((personResponse) =>
22
- this.handleItemSuccess(personResponse.id, personResponse));
22
+ this.handleItemSuccess(personResponse.id, personResponse)
23
+ );
23
24
 
24
25
  if (res.body.notFoundIds) {
25
- promises.concat(res.body.notFoundIds.map((id) =>
26
- this.handleItemFailure(id)));
26
+ promises.concat(res.body.notFoundIds.map((id) => this.handleItemFailure(id)));
27
27
  }
28
28
 
29
29
  return Promise.all(promises);
30
30
  },
31
31
 
32
32
  handleItemFailure(id) {
33
- return this.getDeferredForResponse(id)
34
- .then((defer) => {
35
- defer.reject(id);
36
- });
33
+ return this.getDeferredForResponse(id).then((defer) => {
34
+ defer.reject(id);
35
+ });
37
36
  },
38
37
 
39
38
  /**
@@ -44,10 +43,9 @@ const PersonUUIDRequestBatcher = Batcher.extend({
44
43
  * @returns {Promise}
45
44
  */
46
45
  handleItemSuccess(email, response) {
47
- return this.getDeferredForResponse(email)
48
- .then((defer) => {
49
- defer.resolve(response);
50
- });
46
+ return this.getDeferredForResponse(email).then((defer) => {
47
+ defer.resolve(response);
48
+ });
51
49
  },
52
50
 
53
51
  /**
@@ -85,9 +83,9 @@ const PersonUUIDRequestBatcher = Batcher.extend({
85
83
  submitHttpRequest(ids) {
86
84
  return this.webex.request({
87
85
  service: 'hydra',
88
- resource: `people/?id=${ids}&showAllTypes=${this.config.showAllTypes}`
86
+ resource: `people/?id=${ids}&showAllTypes=${this.config.showAllTypes}`,
89
87
  });
90
- }
88
+ },
91
89
  });
92
90
 
93
91
  export default PersonUUIDRequestBatcher;
package/src/people.js CHANGED
@@ -22,7 +22,7 @@ const People = WebexPlugin.extend({
22
22
  namespace: 'People',
23
23
 
24
24
  children: {
25
- batcher: PeopleBatcher
25
+ batcher: PeopleBatcher,
26
26
  },
27
27
  /**
28
28
  * Returns a single person by ID
@@ -155,9 +155,8 @@ const People = WebexPlugin.extend({
155
155
  return this.request({
156
156
  service: 'hydra',
157
157
  resource: 'people',
158
- qs: options
159
- })
160
- .then((res) => new Page(res, this.webex));
158
+ qs: options,
159
+ }).then((res) => new Page(res, this.webex));
161
160
  },
162
161
 
163
162
  /**
@@ -173,8 +172,7 @@ const People = WebexPlugin.extend({
173
172
  if (base64.decode(id).includes('ciscospark://')) {
174
173
  return id;
175
174
  }
176
- }
177
- catch (err) {
175
+ } catch (err) {
178
176
  // ignore
179
177
  }
180
178
 
@@ -190,12 +188,13 @@ const People = WebexPlugin.extend({
190
188
  */
191
189
  @oneFlight
192
190
  _getMe() {
193
- return this.webex.request({
194
- service: 'hydra',
195
- resource: 'people/me'
196
- })
191
+ return this.webex
192
+ .request({
193
+ service: 'hydra',
194
+ resource: 'people/me',
195
+ })
197
196
  .then((res) => res.body);
198
- }
197
+ },
199
198
  });
200
199
 
201
200
  export default People;
@@ -15,56 +15,58 @@ describe('plugin-people', function () {
15
15
  describe('People', () => {
16
16
  let bones, mccoy, spock;
17
17
 
18
- beforeEach('create users', () => testUsers.create({count: 3})
19
- .then((users) => {
18
+ beforeEach('create users', () =>
19
+ testUsers.create({count: 3}).then((users) => {
20
20
  [spock, mccoy, bones] = users;
21
21
  spock.webex = new WebexCore({
22
22
  credentials: {
23
- authorization: users[0].token
24
- }
23
+ authorization: users[0].token,
24
+ },
25
25
  });
26
26
  mccoy.webex = new WebexCore({
27
27
  credentials: {
28
- authorization: users[1].token
29
- }
28
+ authorization: users[1].token,
29
+ },
30
30
  });
31
- }));
31
+ })
32
+ );
32
33
 
33
34
  describe('#get()', () => {
34
- it('gets a person by id', () => spock.webex.people.get(mccoy.id)
35
- .then((peopleResponse) => {
35
+ it('gets a person by id', () =>
36
+ spock.webex.people.get(mccoy.id).then((peopleResponse) => {
36
37
  assert.isPerson(peopleResponse);
37
38
  assert.equal(peopleResponse.emails[0], mccoy.email);
38
39
  }));
39
40
 
40
- it('gets the current user with "get(\'me\')"', () => spock.webex.people.get('me')
41
- .then((peopleResponse) => {
41
+ it('gets the current user with "get(\'me\')"', () =>
42
+ spock.webex.people.get('me').then((peopleResponse) => {
42
43
  assert.isPerson(peopleResponse);
43
44
  assert.equal(peopleResponse.emails[0], spock.email);
44
45
  }));
45
46
 
46
- it('gets a user by hydra id', () => spock.webex.people.get('me')
47
- .then((person) => spock.webex.people.get(person.id))
48
- .then((person) => {
49
- assert.isPerson(person);
50
- assert.equal(person.emails[0], spock.email);
51
- }));
47
+ it('gets a user by hydra id', () =>
48
+ spock.webex.people
49
+ .get('me')
50
+ .then((person) => spock.webex.people.get(person.id))
51
+ .then((person) => {
52
+ assert.isPerson(person);
53
+ assert.equal(person.emails[0], spock.email);
54
+ }));
52
55
 
53
- it('gets multiple users at a time', () => Promise.all([
54
- spock.webex.people.get(mccoy.id),
55
- spock.webex.people.get('me')
56
- ])
57
- .then((peopleResponse) => {
58
- assert.isPerson(peopleResponse[0]);
59
- assert.isPerson(peopleResponse[1]);
60
- assert.equal(peopleResponse[0].emails[0], mccoy.email);
61
- assert.equal(peopleResponse[1].emails[0], spock.email);
62
- }));
56
+ it('gets multiple users at a time', () =>
57
+ Promise.all([spock.webex.people.get(mccoy.id), spock.webex.people.get('me')]).then(
58
+ (peopleResponse) => {
59
+ assert.isPerson(peopleResponse[0]);
60
+ assert.isPerson(peopleResponse[1]);
61
+ assert.equal(peopleResponse[0].emails[0], mccoy.email);
62
+ assert.equal(peopleResponse[1].emails[0], spock.email);
63
+ }
64
+ ));
63
65
  });
64
66
 
65
67
  describe('#list()', () => {
66
- it('gets a group of people by ids', () => spock.webex.people.list([mccoy.id, spock.id, bones.id])
67
- .then((peopleResponse) => {
68
+ it('gets a group of people by ids', () =>
69
+ spock.webex.people.list([mccoy.id, spock.id, bones.id]).then((peopleResponse) => {
68
70
  assert.equal(peopleResponse.length, 3);
69
71
  assert.isPerson(peopleResponse[0]);
70
72
  assert.isPerson(peopleResponse[1]);
@@ -73,18 +75,21 @@ describe('plugin-people', function () {
73
75
  assert.equal(peopleResponse[1].emails[0], spock.email);
74
76
  }));
75
77
 
76
- it('defaults to false showAllTypes', () => spock.webex.people.list([mccoy.id, spock.id, bones.id])
77
- .then(assert.isFalse(spock.webex.people.batcher.config.showAllTypes)));
78
+ it('defaults to false showAllTypes', () =>
79
+ spock.webex.people
80
+ .list([mccoy.id, spock.id, bones.id])
81
+ .then(assert.isFalse(spock.webex.people.batcher.config.showAllTypes)));
78
82
 
79
83
  it('sets showAllTypes to true', () => {
80
84
  spock.webex.people.batcher.config.showAllTypes = true;
81
85
 
82
- return spock.webex.people.list([mccoy.id, spock.id, bones.id])
86
+ return spock.webex.people
87
+ .list([mccoy.id, spock.id, bones.id])
83
88
  .then(assert.isTrue(spock.webex.people.batcher.config.showAllTypes));
84
89
  });
85
90
 
86
- it('returns a list of people matching email address', () => spock.webex.people.list({email: mccoy.email})
87
- .then((peopleResponse) => {
91
+ it('returns a list of people matching email address', () =>
92
+ spock.webex.people.list({email: mccoy.email}).then((peopleResponse) => {
88
93
  assert.isAbove(peopleResponse.items.length, 0);
89
94
  const person = peopleResponse.items[0];
90
95
 
@@ -92,8 +97,8 @@ describe('plugin-people', function () {
92
97
  assert.equal(person.emails[0], mccoy.email);
93
98
  }));
94
99
 
95
- it('returns a list of people matching name', () => spock.webex.people.list({displayName: mccoy.name})
96
- .then((peopleResponse) => {
100
+ it('returns a list of people matching name', () =>
101
+ spock.webex.people.list({displayName: mccoy.name}).then((peopleResponse) => {
97
102
  assert.isAbove(peopleResponse.items.length, 0);
98
103
  let isMccoyFound = false;
99
104
 
@@ -109,40 +114,43 @@ describe('plugin-people', function () {
109
114
  describe('batching of people requests', () => {
110
115
  let batchTestUsers;
111
116
 
112
- beforeEach('create more users', () => testUsers.create({count: 6})
113
- .then((users) => {
117
+ beforeEach('create more users', () =>
118
+ testUsers.create({count: 6}).then((users) => {
114
119
  batchTestUsers = users;
115
- }));
120
+ })
121
+ );
116
122
 
117
123
  it('batches uuid get requests into one', () => {
118
124
  sinon.spy(spock.webex.people.batcher, 'submitHttpRequest');
119
125
 
120
- return Promise.all(batchTestUsers.map((user) => spock.webex.people.get(user.id)))
121
- .then((peopleResponse) => {
126
+ return Promise.all(batchTestUsers.map((user) => spock.webex.people.get(user.id))).then(
127
+ (peopleResponse) => {
122
128
  assert.equal(peopleResponse.length, 6);
123
129
  assert.calledOnce(spock.webex.people.batcher.submitHttpRequest);
124
130
  spock.webex.people.batcher.submitHttpRequest.restore();
125
- });
131
+ }
132
+ );
126
133
  });
127
134
 
128
135
  it('batches people get requests into one', () => {
129
136
  sinon.spy(spock.webex.people.batcher, 'submitHttpRequest');
130
137
 
131
- return Promise.all(batchTestUsers.map((user) => spock.webex.people.get(user)))
132
- .then((peopleResponse) => {
138
+ return Promise.all(batchTestUsers.map((user) => spock.webex.people.get(user))).then(
139
+ (peopleResponse) => {
133
140
  assert.equal(peopleResponse.length, 6);
134
141
  peopleResponse.map((personResponse) => assert.isPerson(personResponse));
135
142
  assert.calledOnce(spock.webex.people.batcher.submitHttpRequest);
136
143
  spock.webex.people.batcher.submitHttpRequest.restore();
137
- });
144
+ }
145
+ );
138
146
  });
139
147
 
140
-
141
148
  it('executes network requests for max limit', () => {
142
149
  spock.webex.people.config.batcherMaxCalls = 2;
143
150
  sinon.spy(spock.webex.people.batcher, 'submitHttpRequest');
144
151
 
145
- return spock.webex.people.list(batchTestUsers.map((user) => user.id))
152
+ return spock.webex.people
153
+ .list(batchTestUsers.map((user) => user.id))
146
154
  .then((peopleResponse) => {
147
155
  assert.equal(peopleResponse.length, 6);
148
156
  assert.calledThrice(spock.webex.people.batcher.submitHttpRequest);
@@ -153,8 +161,10 @@ describe('plugin-people', function () {
153
161
  });
154
162
 
155
163
  describe('#inferPersonId', () => {
156
- it('infers a person id without a network dip', () => spock.webex.people.get(spock.id)
157
- .then((me) => assert.equal(spock.webex.people.inferPersonIdFromUuid(spock.id), me.id)));
164
+ it('infers a person id without a network dip', () =>
165
+ spock.webex.people
166
+ .get(spock.id)
167
+ .then((me) => assert.equal(spock.webex.people.inferPersonIdFromUuid(spock.id), me.id)));
158
168
  });
159
169
  });
160
170
  });
@@ -15,25 +15,29 @@ describe('people-batcher', () => {
15
15
  beforeEach(() => {
16
16
  webex = new MockWebex({
17
17
  children: {
18
- people: People
18
+ people: People,
19
19
  },
20
20
  config: {
21
- people: {showAllTypes: false}
22
- }
21
+ people: {showAllTypes: false},
22
+ },
23
23
  });
24
24
  batcher = webex.people.batcher;
25
25
  });
26
26
 
27
27
  describe('#fingerprints', () => {
28
- it('fingerprintRequest returns encrypted \'hydraId\'', () => batcher.fingerprintRequest('hydraId')
29
- .then((result) => assert.deepEqual(result, webex.people.inferPersonIdFromUuid('hydraId'))));
28
+ it("fingerprintRequest returns encrypted 'hydraId'", () =>
29
+ batcher
30
+ .fingerprintRequest('hydraId')
31
+ .then((result) =>
32
+ assert.deepEqual(result, webex.people.inferPersonIdFromUuid('hydraId'))
33
+ ));
30
34
  });
31
35
 
32
36
  describe('#submitHttpRequest()', () => {
33
37
  const ids = ['id1'];
34
38
  const mockRequest = {
35
39
  service: 'hydra',
36
- resource: `people/?id=${ids}&showAllTypes=false`
40
+ resource: `people/?id=${ids}&showAllTypes=false`,
37
41
  };
38
42
 
39
43
  it('calls webex.request with expected params', () => {
@@ -41,8 +45,7 @@ describe('people-batcher', () => {
41
45
  return Promise.resolve(options);
42
46
  };
43
47
 
44
- return batcher.submitHttpRequest(ids)
45
- .then((req) => assert.deepEqual(req, mockRequest));
48
+ return batcher.submitHttpRequest(ids).then((req) => assert.deepEqual(req, mockRequest));
46
49
  });
47
50
  });
48
51
 
@@ -56,15 +59,18 @@ describe('people-batcher', () => {
56
59
 
57
60
  it('handles item success', () => {
58
61
  const mockResponse = {
59
- items: [{
60
- id: 'hydra1',
61
- displayName: 'name1'
62
- }]
62
+ items: [
63
+ {
64
+ id: 'hydra1',
65
+ displayName: 'name1',
66
+ },
67
+ ],
63
68
  };
64
69
 
65
- return batcher.handleHttpSuccess({
66
- body: mockResponse
67
- })
70
+ return batcher
71
+ .handleHttpSuccess({
72
+ body: mockResponse,
73
+ })
68
74
  .then(() => {
69
75
  assert.calledWith(successSpy, 'hydra1', mockResponse.items[0]);
70
76
  assert.notCalled(failureSpy);
@@ -73,19 +79,23 @@ describe('people-batcher', () => {
73
79
 
74
80
  it('handles item failure', () => {
75
81
  const mockResponse = {
76
- items: [{
77
- id: 'hydra1',
78
- displayName: 'name1'
79
- }, {
80
- id: 'hydra2',
81
- displayName: 'name2'
82
- }],
83
- notFoundIds: ['hydra3']
82
+ items: [
83
+ {
84
+ id: 'hydra1',
85
+ displayName: 'name1',
86
+ },
87
+ {
88
+ id: 'hydra2',
89
+ displayName: 'name2',
90
+ },
91
+ ],
92
+ notFoundIds: ['hydra3'],
84
93
  };
85
94
 
86
- return batcher.handleHttpSuccess({
87
- body: mockResponse
88
- })
95
+ return batcher
96
+ .handleHttpSuccess({
97
+ body: mockResponse,
98
+ })
89
99
  .then(() => {
90
100
  assert.calledTwice(successSpy);
91
101
  assert.calledWith(failureSpy, 'hydra3');
@@ -13,13 +13,14 @@ describe('plugin-people', () => {
13
13
  beforeEach(() => {
14
14
  webex = new MockWebex({
15
15
  children: {
16
- people: People
17
- }
16
+ people: People,
17
+ },
18
18
  });
19
19
  });
20
20
 
21
21
  describe('#get()', () => {
22
- it('requires a person parameter', () => assert.isRejected(webex.people.get(), /A person with an id is required/));
22
+ it('requires a person parameter', () =>
23
+ assert.isRejected(webex.people.get(), /A person with an id is required/));
23
24
  });
24
25
  });
25
26
  });