@webex/internal-plugin-calendar 3.0.0-beta.20 → 3.0.0-beta.200

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/dist/calendar.js CHANGED
@@ -231,15 +231,25 @@ var Calendar = _webexCore.WebexPlugin.extend({
231
231
  });
232
232
  },
233
233
  /**
234
- * Retrieves an array of meeting participants for the meeting id
235
- * @param {String} id
234
+ * Retrieves an array of meeting participants for the meeting participantsUrl
235
+ * @param {String} participantsUrl
236
236
  * @returns {Promise} Resolves with an object of meeting participants
237
237
  */
238
- getParticipants: function getParticipants(id) {
238
+ getParticipants: function getParticipants(participantsUrl) {
239
239
  return this.request({
240
240
  method: 'GET',
241
- service: 'calendar',
242
- resource: "calendarEvents/".concat((0, _btoa.default)(id), "/participants")
241
+ uri: participantsUrl
242
+ });
243
+ },
244
+ /**
245
+ * get meeting notes using notesUrl from meeting object.
246
+ * @param {String} notesUrl
247
+ * @returns {Promise} Resolves with an object of meeting notes
248
+ */
249
+ getNotesByUrl: function getNotesByUrl(notesUrl) {
250
+ return this.request({
251
+ method: 'GET',
252
+ uri: notesUrl
243
253
  });
244
254
  },
245
255
  /**
@@ -273,13 +283,8 @@ var Calendar = _webexCore.WebexPlugin.extend({
273
283
  var meetingObjects = res.body.items;
274
284
  var promises = [];
275
285
  meetingObjects.forEach(function (meeting) {
276
- if (!meeting.encryptedNotes) {
277
- promises.push(_this4.getNotes(meeting.id).then(function (notesResponse) {
278
- meeting.encryptedNotes = notesResponse.body && notesResponse.body.encryptedNotes;
279
- }));
280
- }
281
286
  if (!meeting.encryptedParticipants) {
282
- promises.push(_this4.getParticipants(meeting.id).then(function (notesResponse) {
287
+ promises.push(_this4.getParticipants(meeting.participantsUrl).then(function (notesResponse) {
283
288
  meeting.encryptedParticipants = notesResponse.body.encryptedParticipants;
284
289
  }));
285
290
  }
@@ -289,7 +294,7 @@ var Calendar = _webexCore.WebexPlugin.extend({
289
294
  });
290
295
  });
291
296
  },
292
- version: "3.0.0-beta.20"
297
+ version: "3.0.0-beta.200"
293
298
  });
294
299
  var _default = Calendar;
295
300
  exports.default = _default;
@@ -1 +1 @@
1
- {"version":3,"names":["Calendar","WebexPlugin","extend","namespace","registered","register","webex","canAuthorize","logger","error","reject","Error","info","resolve","internal","device","then","mercury","connect","listenForEvents","trigger","CALENDAR_REGISTERED","catch","message","unregister","stopListeningForEvents","disconnect","CALENDAR_UNREGISTERED","on","envelope","_handleCreate","data","_handleUpdate","_handleDelete","off","id","CalendarCollection","set","calendarMeetingExternal","CALENDAR_UPDATED","get","CALENDAR_CREATE","item","remove","CALENDAR_DELETE","syncCalendar","options","fromDate","config","toDate","list","res","setAll","getAll","getByType","key","value","includes","getBy","processMeetingEvent","event","transform","getParticipants","request","method","service","resource","btoa","getNotes","qs","meetingObjects","body","items","promises","forEach","meeting","encryptedNotes","push","notesResponse","encryptedParticipants","all"],"sources":["calendar.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\n/**\n * Calendar Item Create Event\n * Emitted when a calendar item has been added\n * @event calendar:meeting:create\n * @instance\n * @memberof Calendar\n */\n\n/**\n * Calendar Item Update Event\n * Emitted when a calendar item has been updated\n * @event calendar:meeting:update\n * @instance\n * @memberof Calendar\n */\n\n/**\n * Calendar Item Update Event\n * Emitted when a calendar item has been deleted\n * @event calendar:meeting:delete\n * @instance\n * @memberof Calendar\n */\n\n/**\n * Calendar Registered Event\n * Emitted when the calendar instance has been registered and listening\n * @event calendar:registered\n * @instance\n * @memberof Calendar\n */\n\n/**\n * Calendar Registered Event\n * Emitted when the calendar instance has been registered and listening\n * @event calendar:unregistered\n * @instance\n * @memberof Calendar\n */\n\nimport btoa from 'btoa';\nimport {WebexPlugin} from '@webex/webex-core';\n\nimport CalendarCollection from './collection';\nimport {\n CALENDAR_REGISTERED,\n CALENDAR_UNREGISTERED,\n CALENDAR_DELETE,\n CALENDAR_CREATE,\n CALENDAR_UPDATED,\n} from './constants';\n\nconst Calendar = WebexPlugin.extend({\n namespace: 'Calendar',\n\n /**\n * registered value indicating events registration is successful\n * @instance\n * @type {Boolean}\n * @memberof Calendar\n */\n registered: false,\n\n /**\n * Explicitly sets up the calendar plugin by registering\n * the device, connecting to mercury, and listening for calendar events.\n * @returns {Promise}\n * @public\n * @memberof Calendar\n */\n register() {\n if (!this.webex.canAuthorize) {\n this.logger.error('calendar->register#ERROR, Unable to register, SDK cannot authorize');\n\n return Promise.reject(new Error('SDK cannot authorize'));\n }\n\n if (this.registered) {\n this.logger.info('calendar->register#INFO, Calendar plugin already registered');\n\n return Promise.resolve();\n }\n\n return this.webex.internal.device\n .register()\n .then(() => this.webex.internal.mercury.connect())\n .then(() => {\n this.listenForEvents();\n this.trigger(CALENDAR_REGISTERED);\n this.registered = true;\n })\n .catch((error) => {\n this.logger.error(`calendar->register#ERROR, Unable to register, ${error.message}`);\n\n return Promise.reject(error);\n });\n },\n\n /**\n * Explicitly tears down the calendar plugin by deregistering\n * the device, disconnecting from mercury, and stops listening to calendar events\n *\n * @returns {Promise}\n * @public\n * @memberof Calendar\n */\n unregister() {\n if (!this.registered) {\n this.logger.info('calendar->unregister#INFO, Calendar plugin already unregistered');\n\n return Promise.resolve();\n }\n\n this.stopListeningForEvents();\n\n return this.webex.internal.mercury\n .disconnect()\n .then(() => this.webex.internal.device.unregister())\n .then(() => {\n this.trigger(CALENDAR_UNREGISTERED);\n this.registered = false;\n });\n },\n\n /**\n * registers for calendar events through mercury\n * @returns {undefined}\n * @private\n */\n listenForEvents() {\n // Calendar mercury events listener\n this.webex.internal.mercury.on('event:calendar.meeting.create', (envelope) => {\n this._handleCreate(envelope.data);\n });\n this.webex.internal.mercury.on('event:calendar.meeting.update', (envelope) => {\n this._handleUpdate(envelope.data);\n });\n this.webex.internal.mercury.on('event:calendar.meeting.create.minimal', (envelope) => {\n this._handleCreate(envelope.data);\n });\n this.webex.internal.mercury.on('event:calendar.meeting.update.minimal', (envelope) => {\n this._handleUpdate(envelope.data);\n });\n this.webex.internal.mercury.on('event:calendar.meeting.delete', (envelope) => {\n this._handleDelete(envelope.data);\n });\n },\n\n /**\n * unregisteres all the calendar events from mercury\n * @returns {undefined}\n * @private\n */\n stopListeningForEvents() {\n this.webex.internal.mercury.off('event:calendar.meeting.create');\n this.webex.internal.mercury.off('event:calendar.meeting.create.minimal');\n this.webex.internal.mercury.off('event:calendar.meeting.update');\n this.webex.internal.mercury.off('event:calendar.meeting.update.minimal');\n this.webex.internal.mercury.off('event:calendar.meeting.delete');\n },\n\n /**\n * handles update events, triggers after collection updates\n * @param {Object} data\n * @returns {undefined}\n * @private\n */\n _handleUpdate(data) {\n const id = CalendarCollection.set(data.calendarMeetingExternal);\n\n this.trigger(CALENDAR_UPDATED, CalendarCollection.get(id));\n },\n\n /**\n * handles create events, triggers after collection updates\n * @param {Object} data\n * @returns {undefined}\n * @private\n */\n _handleCreate(data) {\n const id = CalendarCollection.set(data.calendarMeetingExternal);\n\n this.trigger(CALENDAR_CREATE, CalendarCollection.get(id));\n },\n\n /**\n * handles delete events, triggers after collection updates\n * @param {Object} data\n * @returns {undefined}\n * @private\n */\n _handleDelete(data) {\n const item = CalendarCollection.remove(data.calendarMeetingExternal.id);\n\n this.trigger(CALENDAR_DELETE, item);\n },\n\n /**\n * Retrieves a collection of calendars based on the request parameters\n * Defaults to 1 day before and 7 days ahead\n * @param {Object} options\n * @param {Date} options.fromDate the start of the time range\n * @param {Date} options.toDate the end of the time range\n * @returns {Promise} Resolves with an array of calendars\n */\n syncCalendar(options = {fromDate: this.config.fromDate, toDate: this.config.toDate}) {\n return this.list({fromDate: options.fromDate, toDate: options.toDate}).then((res) => {\n CalendarCollection.setAll(res);\n\n return CalendarCollection.getAll();\n });\n },\n /**\n * get the calendar item that has a matching value\n * @param {String} key meeting property\n * @param {Any} value the meeting property to match\n * @returns {Object}\n */\n getByType(key, value) {\n if (['spaceURI', 'spaceMeetURL', 'conversationId'].includes(key)) {\n return CalendarCollection.getBy(key, value);\n }\n throw new Error('key must be one of, spaceURI, spaceMeetURL, or conversationId');\n },\n\n /**\n * gets all the calendar items that have been populated\n * @returns {Object}\n */\n getAll() {\n return CalendarCollection.getAll();\n },\n\n /**\n * Decrypts an encrypted incoming calendar event\n * @param {Object} event\n * @returns {Promise} Resolves with a decrypted calendar event\n */\n processMeetingEvent(event) {\n return this.webex.transform('inbound', event).then(() => event);\n },\n\n /**\n * Retrieves an array of meeting participants for the meeting id\n * @param {String} id\n * @returns {Promise} Resolves with an object of meeting participants\n */\n getParticipants(id) {\n return this.request({\n method: 'GET',\n service: 'calendar',\n resource: `calendarEvents/${btoa(id)}/participants`,\n });\n },\n\n /**\n * Retrieves a collection of meetings based on the request parameters\n * @param {String} id\n * @returns {Promise} Resolves with an object of meeting notes\n */\n getNotes(id) {\n return this.request({\n method: 'GET',\n service: 'calendar',\n resource: `calendarEvents/${btoa(id)}/notes`,\n });\n },\n\n /**\n * Retrieves a collection of meetings based on the request parameters\n * @param {Object} options\n * @param {Date} options.fromDate the start of the time range\n * @param {Date} options.toDate the end of the time range\n * @returns {Promise} Resolves with an array of meetings\n */\n list(options) {\n options = options || {};\n\n return this.webex\n .request({\n method: 'GET',\n service: 'calendar',\n resource: 'calendarEvents',\n qs: options,\n })\n .then((res) => {\n const meetingObjects = res.body.items;\n const promises = [];\n\n meetingObjects.forEach((meeting) => {\n if (!meeting.encryptedNotes) {\n promises.push(\n this.getNotes(meeting.id).then((notesResponse) => {\n meeting.encryptedNotes = notesResponse.body && notesResponse.body.encryptedNotes;\n })\n );\n }\n\n if (!meeting.encryptedParticipants) {\n promises.push(\n this.getParticipants(meeting.id).then((notesResponse) => {\n meeting.encryptedParticipants = notesResponse.body.encryptedParticipants;\n })\n );\n }\n });\n\n return Promise.all(promises).then(() => meetingObjects);\n });\n },\n});\n\nexport default Calendar;\n"],"mappings":";;;;;;;;;AA4CA;AACA;AAEA;AACA;AAhDA;AACA;AACA;;AAEA;AACA;AACA;AACA;AAC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C,CAAC,CACH;QACH;QAEA,IAAI,CAACD,OAAO,CAACI,qBAAqB,EAAE;UAClCN,QAAQ,CAACI,IAAI,CACX,MAAI,CAACf,eAAe,CAACa,OAAO,CAACxC,EAAE,CAAC,CAACnB,IAAI,CAAC,UAAC8D,aAAa,EAAK;YACvDH,OAAO,CAACI,qBAAqB,GAAGD,aAAa,CAACP,IAAI,CAACQ,qBAAqB;UAC1E,CAAC,CAAC,CACH;QACH;MACF,CAAC,CAAC;MAEF,OAAO,iBAAQC,GAAG,CAACP,QAAQ,CAAC,CAACzD,IAAI,CAAC;QAAA,OAAMsD,cAAc;MAAA,EAAC;IACzD,CAAC,CAAC;EACN,CAAC;EAAA;AACH,CAAC,CAAC;AAAC,eAEYtE,QAAQ;AAAA"}
1
+ {"version":3,"names":["Calendar","WebexPlugin","extend","namespace","registered","register","webex","canAuthorize","logger","error","reject","Error","info","resolve","internal","device","then","mercury","connect","listenForEvents","trigger","CALENDAR_REGISTERED","catch","message","unregister","stopListeningForEvents","disconnect","CALENDAR_UNREGISTERED","on","envelope","_handleCreate","data","_handleUpdate","_handleDelete","off","id","CalendarCollection","set","calendarMeetingExternal","CALENDAR_UPDATED","get","CALENDAR_CREATE","item","remove","CALENDAR_DELETE","syncCalendar","options","fromDate","config","toDate","list","res","setAll","getAll","getByType","key","value","includes","getBy","processMeetingEvent","event","transform","getParticipants","participantsUrl","request","method","uri","getNotesByUrl","notesUrl","getNotes","service","resource","btoa","qs","meetingObjects","body","items","promises","forEach","meeting","encryptedParticipants","push","notesResponse","all"],"sources":["calendar.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\n/**\n * Calendar Item Create Event\n * Emitted when a calendar item has been added\n * @event calendar:meeting:create\n * @instance\n * @memberof Calendar\n */\n\n/**\n * Calendar Item Update Event\n * Emitted when a calendar item has been updated\n * @event calendar:meeting:update\n * @instance\n * @memberof Calendar\n */\n\n/**\n * Calendar Item Update Event\n * Emitted when a calendar item has been deleted\n * @event calendar:meeting:delete\n * @instance\n * @memberof Calendar\n */\n\n/**\n * Calendar Registered Event\n * Emitted when the calendar instance has been registered and listening\n * @event calendar:registered\n * @instance\n * @memberof Calendar\n */\n\n/**\n * Calendar Registered Event\n * Emitted when the calendar instance has been registered and listening\n * @event calendar:unregistered\n * @instance\n * @memberof Calendar\n */\n\nimport btoa from 'btoa';\nimport {WebexPlugin} from '@webex/webex-core';\n\nimport CalendarCollection from './collection';\nimport {\n CALENDAR_REGISTERED,\n CALENDAR_UNREGISTERED,\n CALENDAR_DELETE,\n CALENDAR_CREATE,\n CALENDAR_UPDATED,\n} from './constants';\n\nconst Calendar = WebexPlugin.extend({\n namespace: 'Calendar',\n\n /**\n * registered value indicating events registration is successful\n * @instance\n * @type {Boolean}\n * @memberof Calendar\n */\n registered: false,\n\n /**\n * Explicitly sets up the calendar plugin by registering\n * the device, connecting to mercury, and listening for calendar events.\n * @returns {Promise}\n * @public\n * @memberof Calendar\n */\n register() {\n if (!this.webex.canAuthorize) {\n this.logger.error('calendar->register#ERROR, Unable to register, SDK cannot authorize');\n\n return Promise.reject(new Error('SDK cannot authorize'));\n }\n\n if (this.registered) {\n this.logger.info('calendar->register#INFO, Calendar plugin already registered');\n\n return Promise.resolve();\n }\n\n return this.webex.internal.device\n .register()\n .then(() => this.webex.internal.mercury.connect())\n .then(() => {\n this.listenForEvents();\n this.trigger(CALENDAR_REGISTERED);\n this.registered = true;\n })\n .catch((error) => {\n this.logger.error(`calendar->register#ERROR, Unable to register, ${error.message}`);\n\n return Promise.reject(error);\n });\n },\n\n /**\n * Explicitly tears down the calendar plugin by deregistering\n * the device, disconnecting from mercury, and stops listening to calendar events\n *\n * @returns {Promise}\n * @public\n * @memberof Calendar\n */\n unregister() {\n if (!this.registered) {\n this.logger.info('calendar->unregister#INFO, Calendar plugin already unregistered');\n\n return Promise.resolve();\n }\n\n this.stopListeningForEvents();\n\n return this.webex.internal.mercury\n .disconnect()\n .then(() => this.webex.internal.device.unregister())\n .then(() => {\n this.trigger(CALENDAR_UNREGISTERED);\n this.registered = false;\n });\n },\n\n /**\n * registers for calendar events through mercury\n * @returns {undefined}\n * @private\n */\n listenForEvents() {\n // Calendar mercury events listener\n this.webex.internal.mercury.on('event:calendar.meeting.create', (envelope) => {\n this._handleCreate(envelope.data);\n });\n this.webex.internal.mercury.on('event:calendar.meeting.update', (envelope) => {\n this._handleUpdate(envelope.data);\n });\n this.webex.internal.mercury.on('event:calendar.meeting.create.minimal', (envelope) => {\n this._handleCreate(envelope.data);\n });\n this.webex.internal.mercury.on('event:calendar.meeting.update.minimal', (envelope) => {\n this._handleUpdate(envelope.data);\n });\n this.webex.internal.mercury.on('event:calendar.meeting.delete', (envelope) => {\n this._handleDelete(envelope.data);\n });\n },\n\n /**\n * unregisteres all the calendar events from mercury\n * @returns {undefined}\n * @private\n */\n stopListeningForEvents() {\n this.webex.internal.mercury.off('event:calendar.meeting.create');\n this.webex.internal.mercury.off('event:calendar.meeting.create.minimal');\n this.webex.internal.mercury.off('event:calendar.meeting.update');\n this.webex.internal.mercury.off('event:calendar.meeting.update.minimal');\n this.webex.internal.mercury.off('event:calendar.meeting.delete');\n },\n\n /**\n * handles update events, triggers after collection updates\n * @param {Object} data\n * @returns {undefined}\n * @private\n */\n _handleUpdate(data) {\n const id = CalendarCollection.set(data.calendarMeetingExternal);\n\n this.trigger(CALENDAR_UPDATED, CalendarCollection.get(id));\n },\n\n /**\n * handles create events, triggers after collection updates\n * @param {Object} data\n * @returns {undefined}\n * @private\n */\n _handleCreate(data) {\n const id = CalendarCollection.set(data.calendarMeetingExternal);\n\n this.trigger(CALENDAR_CREATE, CalendarCollection.get(id));\n },\n\n /**\n * handles delete events, triggers after collection updates\n * @param {Object} data\n * @returns {undefined}\n * @private\n */\n _handleDelete(data) {\n const item = CalendarCollection.remove(data.calendarMeetingExternal.id);\n\n this.trigger(CALENDAR_DELETE, item);\n },\n\n /**\n * Retrieves a collection of calendars based on the request parameters\n * Defaults to 1 day before and 7 days ahead\n * @param {Object} options\n * @param {Date} options.fromDate the start of the time range\n * @param {Date} options.toDate the end of the time range\n * @returns {Promise} Resolves with an array of calendars\n */\n syncCalendar(options = {fromDate: this.config.fromDate, toDate: this.config.toDate}) {\n return this.list({fromDate: options.fromDate, toDate: options.toDate}).then((res) => {\n CalendarCollection.setAll(res);\n\n return CalendarCollection.getAll();\n });\n },\n /**\n * get the calendar item that has a matching value\n * @param {String} key meeting property\n * @param {Any} value the meeting property to match\n * @returns {Object}\n */\n getByType(key, value) {\n if (['spaceURI', 'spaceMeetURL', 'conversationId'].includes(key)) {\n return CalendarCollection.getBy(key, value);\n }\n throw new Error('key must be one of, spaceURI, spaceMeetURL, or conversationId');\n },\n\n /**\n * gets all the calendar items that have been populated\n * @returns {Object}\n */\n getAll() {\n return CalendarCollection.getAll();\n },\n\n /**\n * Decrypts an encrypted incoming calendar event\n * @param {Object} event\n * @returns {Promise} Resolves with a decrypted calendar event\n */\n processMeetingEvent(event) {\n return this.webex.transform('inbound', event).then(() => event);\n },\n\n /**\n * Retrieves an array of meeting participants for the meeting participantsUrl\n * @param {String} participantsUrl\n * @returns {Promise} Resolves with an object of meeting participants\n */\n getParticipants(participantsUrl) {\n return this.request({\n method: 'GET',\n uri: participantsUrl,\n });\n },\n\n /**\n * get meeting notes using notesUrl from meeting object.\n * @param {String} notesUrl\n * @returns {Promise} Resolves with an object of meeting notes\n */\n getNotesByUrl(notesUrl) {\n return this.request({\n method: 'GET',\n uri: notesUrl,\n });\n },\n\n /**\n * Retrieves a collection of meetings based on the request parameters\n * @param {String} id\n * @returns {Promise} Resolves with an object of meeting notes\n */\n getNotes(id) {\n return this.request({\n method: 'GET',\n service: 'calendar',\n resource: `calendarEvents/${btoa(id)}/notes`,\n });\n },\n\n /**\n * Retrieves a collection of meetings based on the request parameters\n * @param {Object} options\n * @param {Date} options.fromDate the start of the time range\n * @param {Date} options.toDate the end of the time range\n * @returns {Promise} Resolves with an array of meetings\n */\n list(options) {\n options = options || {};\n\n return this.webex\n .request({\n method: 'GET',\n service: 'calendar',\n resource: 'calendarEvents',\n qs: options,\n })\n .then((res) => {\n const meetingObjects = res.body.items;\n const promises = [];\n\n meetingObjects.forEach((meeting) => {\n if (!meeting.encryptedParticipants) {\n promises.push(\n this.getParticipants(meeting.participantsUrl).then((notesResponse) => {\n meeting.encryptedParticipants = notesResponse.body.encryptedParticipants;\n })\n );\n }\n });\n\n return Promise.all(promises).then(() => meetingObjects);\n });\n },\n});\n\nexport default Calendar;\n"],"mappings":";;;;;;;;;AA4CA;AACA;AAEA;AACA;AAhDA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAcA,IAAMA,QAAQ,GAAGC,sBAAW,CAACC,MAAM,CAAC;EAClCC,SAAS,EAAE,UAAU;EAErB;AACF;AACA;AACA;AACA;AACA;EACEC,UAAU,EAAE,KAAK;EAEjB;AACF;AACA;AACA;AACA;AACA;AACA;EACEC,QAAQ,sBAAG;IAAA;IACT,IAAI,CAAC,IAAI,CAACC,KAAK,CAACC,YAAY,EAAE;MAC5B,IAAI,CAACC,MAAM,CAACC,KAAK,CAAC,oEAAoE,CAAC;MAEvF,OAAO,iBAAQC,MAAM,CAAC,IAAIC,KAAK,CAAC,sBAAsB,CAAC,CAAC;IAC1D;IAEA,IAAI,IAAI,CAACP,UAAU,EAAE;MACnB,IAAI,CAACI,MAAM,CAACI,IAAI,CAAC,6DAA6D,CAAC;MAE/E,OAAO,iBAAQC,OAAO,EAAE;IAC1B;IAEA,OAAO,IAAI,CAACP,KAAK,CAACQ,QAAQ,CAACC,MAAM,CAC9BV,QAAQ,EAAE,CACVW,IAAI,CAAC;MAAA,OAAM,KAAI,CAACV,KAAK,CAACQ,QAAQ,CAACG,O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BC,QAAQ,EAAE,gBAAgB;MAC1BE,EAAE,EAAE3B;IACN,CAAC,CAAC,CACD9B,IAAI,CAAC,UAACmC,GAAG,EAAK;MACb,IAAMuB,cAAc,GAAGvB,GAAG,CAACwB,IAAI,CAACC,KAAK;MACrC,IAAMC,QAAQ,GAAG,EAAE;MAEnBH,cAAc,CAACI,OAAO,CAAC,UAACC,OAAO,EAAK;QAClC,IAAI,CAACA,OAAO,CAACC,qBAAqB,EAAE;UAClCH,QAAQ,CAACI,IAAI,CACX,MAAI,CAACnB,eAAe,CAACiB,OAAO,CAAChB,eAAe,CAAC,CAAC/C,IAAI,CAAC,UAACkE,aAAa,EAAK;YACpEH,OAAO,CAACC,qBAAqB,GAAGE,aAAa,CAACP,IAAI,CAACK,qBAAqB;UAC1E,CAAC,CAAC,CACH;QACH;MACF,CAAC,CAAC;MAEF,OAAO,iBAAQG,GAAG,CAACN,QAAQ,CAAC,CAAC7D,IAAI,CAAC;QAAA,OAAM0D,cAAc;MAAA,EAAC;IACzD,CAAC,CAAC;EACN,CAAC;EAAA;AACH,CAAC,CAAC;AAAC,eAEY1E,QAAQ;AAAA"}
package/package.json CHANGED
@@ -19,20 +19,20 @@
19
19
  "envify"
20
20
  ]
21
21
  },
22
- "version": "3.0.0-beta.20",
22
+ "version": "3.0.0-beta.200",
23
23
  "devDependencies": {
24
- "@webex/test-helper-chai": "3.0.0-beta.20",
25
- "@webex/test-helper-mock-webex": "3.0.0-beta.20",
26
- "@webex/test-helper-retry": "3.0.0-beta.20",
27
- "@webex/test-helper-test-users": "3.0.0-beta.20",
24
+ "@webex/test-helper-chai": "3.0.0-beta.200",
25
+ "@webex/test-helper-mock-webex": "3.0.0-beta.200",
26
+ "@webex/test-helper-retry": "3.0.0-beta.200",
27
+ "@webex/test-helper-test-users": "3.0.0-beta.200",
28
28
  "sinon": "^9.2.4"
29
29
  },
30
30
  "dependencies": {
31
- "@webex/internal-plugin-calendar": "3.0.0-beta.20",
32
- "@webex/internal-plugin-conversation": "3.0.0-beta.20",
33
- "@webex/internal-plugin-device": "3.0.0-beta.20",
34
- "@webex/internal-plugin-encryption": "3.0.0-beta.20",
35
- "@webex/webex-core": "3.0.0-beta.20",
31
+ "@webex/internal-plugin-calendar": "3.0.0-beta.200",
32
+ "@webex/internal-plugin-conversation": "3.0.0-beta.200",
33
+ "@webex/internal-plugin-device": "3.0.0-beta.200",
34
+ "@webex/internal-plugin-encryption": "3.0.0-beta.200",
35
+ "@webex/webex-core": "3.0.0-beta.200",
36
36
  "btoa": "^1.2.1",
37
37
  "lodash": "^4.17.21",
38
38
  "uuid": "^3.3.2"
package/src/calendar.js CHANGED
@@ -245,15 +245,26 @@ const Calendar = WebexPlugin.extend({
245
245
  },
246
246
 
247
247
  /**
248
- * Retrieves an array of meeting participants for the meeting id
249
- * @param {String} id
248
+ * Retrieves an array of meeting participants for the meeting participantsUrl
249
+ * @param {String} participantsUrl
250
250
  * @returns {Promise} Resolves with an object of meeting participants
251
251
  */
252
- getParticipants(id) {
252
+ getParticipants(participantsUrl) {
253
253
  return this.request({
254
254
  method: 'GET',
255
- service: 'calendar',
256
- resource: `calendarEvents/${btoa(id)}/participants`,
255
+ uri: participantsUrl,
256
+ });
257
+ },
258
+
259
+ /**
260
+ * get meeting notes using notesUrl from meeting object.
261
+ * @param {String} notesUrl
262
+ * @returns {Promise} Resolves with an object of meeting notes
263
+ */
264
+ getNotesByUrl(notesUrl) {
265
+ return this.request({
266
+ method: 'GET',
267
+ uri: notesUrl,
257
268
  });
258
269
  },
259
270
 
@@ -292,17 +303,9 @@ const Calendar = WebexPlugin.extend({
292
303
  const promises = [];
293
304
 
294
305
  meetingObjects.forEach((meeting) => {
295
- if (!meeting.encryptedNotes) {
296
- promises.push(
297
- this.getNotes(meeting.id).then((notesResponse) => {
298
- meeting.encryptedNotes = notesResponse.body && notesResponse.body.encryptedNotes;
299
- })
300
- );
301
- }
302
-
303
306
  if (!meeting.encryptedParticipants) {
304
307
  promises.push(
305
- this.getParticipants(meeting.id).then((notesResponse) => {
308
+ this.getParticipants(meeting.participantsUrl).then((notesResponse) => {
306
309
  meeting.encryptedParticipants = notesResponse.body.encryptedParticipants;
307
310
  })
308
311
  );
@@ -203,18 +203,6 @@ describe('internal-plugin-calendar', () => {
203
203
  },
204
204
  })
205
205
  );
206
- // getNotes stub
207
- webexRequestStub
208
- .withArgs({
209
- method: 'GET',
210
- service: 'calendar',
211
- resource: `calendarEvents/${btoa('calendar1')}/notes`,
212
- })
213
- .returns(
214
- Promise.resolve({
215
- body: null,
216
- })
217
- );
218
206
 
219
207
  // Assign webexRequestStub to webex.request
220
208
  webex.request = webexRequestStub;
@@ -223,7 +211,7 @@ describe('internal-plugin-calendar', () => {
223
211
 
224
212
  assert.equal(res.length, 2);
225
213
  assert.deepEqual(res, [
226
- {id: 'calendar1', encryptedNotes: null, encryptedParticipants: ['participant1']},
214
+ {id: 'calendar1', encryptedParticipants: ['participant1']},
227
215
  {id: 'calendar2', encryptedNotes: 'notes2', encryptedParticipants: ['participant2']},
228
216
  ]);
229
217
  assert.calledWith(webex.request, {
@@ -232,11 +220,6 @@ describe('internal-plugin-calendar', () => {
232
220
  resource: 'calendarEvents',
233
221
  qs: {fromDate: 'xx-xx', toDate: 'xx-nn'},
234
222
  });
235
- assert.calledWith(webex.request, {
236
- method: 'GET',
237
- service: 'calendar',
238
- resource: `calendarEvents/${btoa('calendar1')}/notes`,
239
- });
240
223
  });
241
224
 
242
225
  it('should fetch the calendar list and resolves with fetched encryptedNotes', async () => {
@@ -254,7 +237,7 @@ describe('internal-plugin-calendar', () => {
254
237
  Promise.resolve({
255
238
  body: {
256
239
  items: [
257
- {id: 'calendar1', encryptedParticipants: ['participant1']},
240
+ {id: 'calendar1', encryptedNotes: 'notes1', encryptedParticipants: ['participant1']},
258
241
  {
259
242
  id: 'calendar2',
260
243
  encryptedNotes: 'notes2',
@@ -264,20 +247,6 @@ describe('internal-plugin-calendar', () => {
264
247
  },
265
248
  })
266
249
  );
267
- // getNotes stub
268
- webexRequestStub
269
- .withArgs({
270
- method: 'GET',
271
- service: 'calendar',
272
- resource: `calendarEvents/${btoa('calendar1')}/notes`,
273
- })
274
- .returns(
275
- Promise.resolve({
276
- body: {
277
- encryptedNotes: 'notes1',
278
- },
279
- })
280
- );
281
250
 
282
251
  // Assign webexRequestStub to webex.request
283
252
  webex.request = webexRequestStub;
@@ -295,11 +264,6 @@ describe('internal-plugin-calendar', () => {
295
264
  resource: 'calendarEvents',
296
265
  qs: {fromDate: 'xx-xx', toDate: 'xx-nn'},
297
266
  });
298
- assert.calledWith(webex.request, {
299
- method: 'GET',
300
- service: 'calendar',
301
- resource: `calendarEvents/${btoa('calendar1')}/notes`,
302
- });
303
267
  });
304
268
  });
305
269
 
@@ -327,7 +291,7 @@ describe('internal-plugin-calendar', () => {
327
291
  });
328
292
 
329
293
  describe('#getParticipants()', () => {
330
- const id = 'meetingId123';
294
+ const uri = 'participantsUrl';
331
295
 
332
296
  it('should fetch the meeting participants', async () => {
333
297
  webex.request = sinon.stub().returns(
@@ -338,13 +302,34 @@ describe('internal-plugin-calendar', () => {
338
302
  })
339
303
  );
340
304
 
341
- const res = await webex.internal.calendar.getParticipants(id);
305
+ const res = await webex.internal.calendar.getParticipants(uri);
342
306
 
343
307
  assert.equal(res.body.encryptedParticipants.length, 1);
344
308
  assert.calledWith(webex.request, {
345
309
  method: 'GET',
346
- service: 'calendar',
347
- resource: `calendarEvents/${btoa(id)}/participants`,
310
+ uri,
311
+ });
312
+ });
313
+ });
314
+
315
+ describe('#getNotesByUrl()', () => {
316
+ const uri = 'notesUrl';
317
+
318
+ it('should fetch the meeting notes', async () => {
319
+ webex.request = sinon.stub().returns(
320
+ Promise.resolve({
321
+ body: {
322
+ encryptedParticipants: ['participant1'],
323
+ },
324
+ })
325
+ );
326
+
327
+ const res = await webex.internal.calendar.getNotesByUrl(uri);
328
+
329
+ assert.equal(res.body.encryptedParticipants.length, 1);
330
+ assert.calledWith(webex.request, {
331
+ method: 'GET',
332
+ uri,
348
333
  });
349
334
  });
350
335
  });