@webex/plugin-webhooks 3.0.0-beta.9 → 3.0.0-beta.91

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-webhooks
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.webhooks.get(id)
37
- .then((webhook) => {
38
- console.log(webhook);
39
- })
40
-
35
+ webex.webhooks.get(id).then((webhook) => {
36
+ console.log(webhook);
37
+ });
41
38
  ```
42
39
 
43
40
  ## Maintainers
package/dist/index.js CHANGED
@@ -1,22 +1,17 @@
1
1
  "use strict";
2
2
 
3
3
  var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
4
-
5
4
  var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
6
-
7
5
  _Object$defineProperty(exports, "__esModule", {
8
6
  value: true
9
7
  });
10
-
11
8
  exports.default = void 0;
12
-
13
9
  var _webexCore = require("@webex/webex-core");
14
-
15
10
  var _webhooks = _interopRequireDefault(require("./webhooks"));
16
-
17
11
  /*!
18
12
  * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
19
13
  */
14
+
20
15
  (0, _webexCore.registerPlugin)('webhooks', _webhooks.default);
21
16
  var _default = _webhooks.default;
22
17
  exports.default = _default;
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["registerPlugin","Webhooks"],"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 Webhooks from './webhooks';\n\nregisterPlugin('webhooks', Webhooks);\n\nexport default Webhooks;\n"],"mappings":";;;;;;;;;;;;AAIA;;AAEA;;AANA;AACA;AACA;AAMA,IAAAA,yBAAA,EAAe,UAAf,EAA2BC,iBAA3B;eAEeA,iB"}
1
+ {"version":3,"names":["registerPlugin","Webhooks"],"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 Webhooks from './webhooks';\n\nregisterPlugin('webhooks', Webhooks);\n\nexport default Webhooks;\n"],"mappings":";;;;;;;;AAIA;AAEA;AANA;AACA;AACA;;AAMA,IAAAA,yBAAc,EAAC,UAAU,EAAEC,iBAAQ,CAAC;AAAC,eAEtBA,iBAAQ;AAAA"}
package/dist/webhooks.js CHANGED
@@ -1,15 +1,11 @@
1
1
  "use strict";
2
2
 
3
3
  var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
4
-
5
4
  _Object$defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
-
9
7
  exports.default = void 0;
10
-
11
8
  var _webexCore = require("@webex/webex-core");
12
-
13
9
  /*!
14
10
  * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
15
11
  */
@@ -71,7 +67,6 @@ var Webhooks = _webexCore.WebexPlugin.extend({
71
67
  return res.body;
72
68
  });
73
69
  },
74
-
75
70
  /**
76
71
  * Shows details for a webhook.
77
72
  * @instance
@@ -110,7 +105,6 @@ var Webhooks = _webexCore.WebexPlugin.extend({
110
105
  return res.body.items || res.body;
111
106
  });
112
107
  },
113
-
114
108
  /**
115
109
  * Lists all webhooks.
116
110
  * @instance
@@ -146,7 +140,6 @@ var Webhooks = _webexCore.WebexPlugin.extend({
146
140
  */
147
141
  list: function list(options) {
148
142
  var _this = this;
149
-
150
143
  return this.request({
151
144
  service: 'hydra',
152
145
  resource: 'webhooks/',
@@ -155,7 +148,6 @@ var Webhooks = _webexCore.WebexPlugin.extend({
155
148
  return new _webexCore.Page(res, _this.webex);
156
149
  });
157
150
  },
158
-
159
151
  /**
160
152
  * Delete a webhook.
161
153
  * @instance
@@ -203,11 +195,9 @@ var Webhooks = _webexCore.WebexPlugin.extend({
203
195
  if (res.statusCode === 204) {
204
196
  return undefined;
205
197
  }
206
-
207
198
  return res.body;
208
199
  });
209
200
  },
210
-
211
201
  /**
212
202
  * Update a webhook.
213
203
  * @instance
@@ -252,9 +242,8 @@ var Webhooks = _webexCore.WebexPlugin.extend({
252
242
  return res.body;
253
243
  });
254
244
  },
255
- version: "3.0.0-beta.9"
245
+ version: "3.0.0-beta.91"
256
246
  });
257
-
258
247
  var _default = Webhooks;
259
248
  exports.default = _default;
260
249
  //# sourceMappingURL=webhooks.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["Webhooks","WebexPlugin","extend","create","webhook","request","method","service","resource","body","then","res","get","id","items","list","options","qs","Page","webex","remove","statusCode","undefined","update"],"sources":["webhooks.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport {WebexPlugin, Page} from '@webex/webex-core';\n\n/**\n * @typedef {Object} WebhookObject\n * @property {string} id - (server generated) Unique identifier for the webhook\n * @property {string} resource - The resource type for the webhook\n * @property {string} event - The event type for the webhook\n * @property {string} filter - The filter that defines the webhook scope\n * @property {string} targetUrl - The URL that receives POST requests for each event\n * @property {string} name - A user-friendly name for this webhook\n * @property {string} created - (server generated) The date and time that the webhook was created\n */\n\n/**\n * Webhooks allow your app to be notified via HTTP when a specific event\n * occurs on Webex. For example, your app can register a webhook to be\n * notified when a new message is posted into a specific room.\n * @class\n */\nconst Webhooks = WebexPlugin.extend({\n /**\n * Posts a webhook.\n * @instance\n * @memberof Webhooks\n * @param {WebhookObject} webhook\n * @returns {Promise<Webhook>}\n * @example\n * webex.rooms.create({title: 'Create Webhook Example'})\n * .then(function(room) {\n * return webex.webhooks.create({\n * resource: 'messages',\n * event: 'created',\n * filter: 'roomId=' + room.id,\n * targetUrl: 'https://example.com/webhook',\n * name: 'Test Webhook'\n * });\n * })\n * .then(function(webhook) {\n * var assert = require('assert');\n * assert(webhook.id);\n * assert(webhook.resource);\n * assert(webhook.event);\n * assert(webhook.filter);\n * assert(webhook.targetUrl);\n * assert(webhook.name);\n * return 'success';\n * });\n * // => success\n */\n create(webhook) {\n return this.request({\n method: 'POST',\n service: 'hydra',\n resource: 'webhooks',\n body: webhook\n })\n .then((res) => res.body);\n },\n\n /**\n * Shows details for a webhook.\n * @instance\n * @memberof Webhooks\n * @param {Webhook|string} webhook\n * @returns {Promise<Webhook>}\n * @example\n * var webhook;\n * webex.rooms.create({title: 'Get Webhook Example'})\n * .then(function(room) {\n * return webex.webhooks.create({\n * resource: 'messages',\n * event: 'created',\n * filter: 'roomId=' + room.id,\n * targetUrl: 'https://example.com/webhook',\n * name: 'Test Webhook'\n * });\n * })\n * .then(function(w) {\n * webhook = w;\n * return webex.webhooks.get(webhook.id);\n * })\n * .then(function(webhook2) {\n * var assert = require('assert');\n * assert.deepEqual(webhook2, webhook);\n * return 'success';\n * });\n * // => success\n */\n get(webhook) {\n const id = webhook.id || webhook;\n\n return this.request({\n service: 'hydra',\n resource: `webhooks/${id}`\n })\n .then((res) => res.body.items || res.body);\n },\n\n /**\n * Lists all webhooks.\n * @instance\n * @memberof Webhooks\n * @param {Object} options\n * @param {integer} options.max Limit the maximum number of webhooks in the response.\n * @returns {Promise<Array<Webhook>>}\n * @example\n * var room, webhook;\n * webex.rooms.create({title: 'List Webhooks Example'})\n * .then(function(r) {\n * room = r;\n * return webex.webhooks.create({\n * resource: 'messages',\n * event: 'created',\n * filter: 'roomId=' + room.id,\n * targetUrl: 'https://example.com/webhook',\n * name: 'Test Webhook'\n * });\n * })\n * .then(function(w) {\n * webhook = w;\n * return webex.webhooks.list();\n * })\n * .then(function(webhooks) {\n * var assert = require('assert');\n * assert.equal(webhooks.items.filter(function(w) {\n * return w.id === webhook.id;\n * }).length, 1);\n * return 'success';\n * });\n * // => success\n */\n list(options) {\n return this.request({\n service: 'hydra',\n resource: 'webhooks/',\n qs: options\n })\n .then((res) => new Page(res, this.webex));\n },\n\n /**\n * Delete a webhook.\n * @instance\n * @memberof Webhooks\n * @param {Webhook|string} webhook\n * @returns {Promise}\n * @example\n * var room, webhook;\n * webex.rooms.create({title: 'Remove Webhook Example'})\n * .then(function(r) {\n * room = r;\n * return webex.webhooks.create({\n * resource: 'messages',\n * event: 'created',\n * filter: 'roomId=' + room.id,\n * targetUrl: 'https://example.com/webhook',\n * name: 'Test Webhook'\n * });\n * })\n * .then(function(w) {\n * webhook = w;\n * return webex.webhooks.remove(webhook);\n * })\n * .then(function() {\n * return webex.webhooks.list();\n * })\n * .then(function(webhooks) {\n * var assert = require('assert');\n * assert.equal(webhooks.items.filter(function(w) {\n * return w.id === webhook.id;\n * }).length, 0);\n * return 'success';\n * });\n * // => success\n */\n remove(webhook) {\n const id = webhook.id || webhook;\n\n return this.request({\n method: 'DELETE',\n service: 'hydra',\n resource: `webhooks/${id}`\n })\n .then((res) => {\n // Firefox has some issues with 204s and/or DELETE. This should move to\n // http-core\n if (res.statusCode === 204) {\n return undefined;\n }\n\n return res.body;\n });\n },\n\n /**\n * Update a webhook.\n * @instance\n * @memberof Webhooks\n * @param {Webhook} webhook\n * @returns {Promise<Webhook>}\n * @example\n * var webhook;\n * webex.rooms.create({title: 'Webhook Example'})\n * .then(function(room) {\n * return webex.webhooks.create({\n * resource: 'messages',\n * event: 'created',\n * filter: 'roomId=' + room.id,\n * targetUrl: 'https://example.com/webhook',\n * name: 'Test Webhook'\n * });\n * })\n * .then(function(w) {\n * webhook = w;\n * webhook.targetUrl = 'https://example.com/webhook/newtarget';\n * return webex.webhooks.update(webhook);\n * })\n * .then(function() {\n * return webex.webhooks.get(webhook);\n * })\n * .then(function(webhook) {\n * var assert = require('assert');\n * assert.equal(webhook.targetUrl, 'https://example.com/webhook/newtarget');\n * return 'success';\n * });\n * // => success\n */\n update(webhook) {\n const {id} = webhook;\n\n return this.request({\n method: 'PUT',\n service: 'hydra',\n resource: `webhooks/${id}`,\n body: webhook\n })\n .then((res) => res.body);\n }\n});\n\nexport default Webhooks;\n"],"mappings":";;;;;;;;;;AAIA;;AAJA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,IAAMA,QAAQ,GAAGC,sBAAA,CAAYC,MAAZ,CAAmB;EAClC;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;EACEC,MA9BkC,kBA8B3BC,OA9B2B,EA8BlB;IACd,OAAO,KAAKC,OAAL,CAAa;MAClBC,MAAM,EAAE,MADU;MAElBC,OAAO,EAAE,OAFS;MAGlBC,QAAQ,EAAE,UAHQ;MAIlBC,IAAI,EAAEL;IAJY,CAAb,EAMJM,IANI,CAMC,UAACC,GAAD;MAAA,OAASA,GAAG,CAACF,IAAb;IAAA,CAND,CAAP;EAOD,CAtCiC;;EAwClC;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;EACEG,GArEkC,eAqE9BR,OArE8B,EAqErB;IACX,IAAMS,EAAE,GAAGT,OAAO,CAACS,EAAR,IAAcT,OAAzB;IAEA,OAAO,KAAKC,OAAL,CAAa;MAClBE,OAAO,EAAE,OADS;MAElBC,QAAQ,qBAAcK,EAAd;IAFU,CAAb,EAIJH,IAJI,CAIC,UAACC,GAAD;MAAA,OAASA,GAAG,CAACF,IAAJ,CAASK,KAAT,IAAkBH,GAAG,CAACF,IAA/B;IAAA,CAJD,CAAP;EAKD,CA7EiC;;EA+ElC;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;EACEM,IAhHkC,gBAgH7BC,OAhH6B,EAgHpB;IAAA;;IACZ,OAAO,KAAKX,OAAL,CAAa;MAClBE,OAAO,EAAE,OADS;MAElBC,QAAQ,EAAE,WAFQ;MAGlBS,EAAE,EAAED;IAHc,CAAb,EAKJN,IALI,CAKC,UAACC,GAAD;MAAA,OAAS,IAAIO,eAAJ,CAASP,GAAT,EAAc,KAAI,CAACQ,KAAnB,CAAT;IAAA,CALD,CAAP;EAMD,CAvHiC;;EAyHlC;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;EACEC,MA5JkC,kBA4J3BhB,OA5J2B,EA4JlB;IACd,IAAMS,EAAE,GAAGT,OAAO,CAACS,EAAR,IAAcT,OAAzB;IAEA,OAAO,KAAKC,OAAL,CAAa;MAClBC,MAAM,EAAE,QADU;MAElBC,OAAO,EAAE,OAFS;MAGlBC,QAAQ,qBAAcK,EAAd;IAHU,CAAb,EAKJH,IALI,CAKC,UAACC,GAAD,EAAS;MACb;MACA;MACA,IAAIA,GAAG,CAACU,UAAJ,KAAmB,GAAvB,EAA4B;QAC1B,OAAOC,SAAP;MACD;;MAED,OAAOX,GAAG,CAACF,IAAX;IACD,CAbI,CAAP;EAcD,CA7KiC;;EA+KlC;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;EACEc,MAhNkC,kBAgN3BnB,OAhN2B,EAgNlB;IACd,IAAOS,EAAP,GAAaT,OAAb,CAAOS,EAAP;IAEA,OAAO,KAAKR,OAAL,CAAa;MAClBC,MAAM,EAAE,KADU;MAElBC,OAAO,EAAE,OAFS;MAGlBC,QAAQ,qBAAcK,EAAd,CAHU;MAIlBJ,IAAI,EAAEL;IAJY,CAAb,EAMJM,IANI,CAMC,UAACC,GAAD;MAAA,OAASA,GAAG,CAACF,IAAb;IAAA,CAND,CAAP;EAOD,CA1NiC;EAAA;AAAA,CAAnB,CAAjB;;eA6NeT,Q"}
1
+ {"version":3,"names":["Webhooks","WebexPlugin","extend","create","webhook","request","method","service","resource","body","then","res","get","id","items","list","options","qs","Page","webex","remove","statusCode","undefined","update"],"sources":["webhooks.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport {WebexPlugin, Page} from '@webex/webex-core';\n\n/**\n * @typedef {Object} WebhookObject\n * @property {string} id - (server generated) Unique identifier for the webhook\n * @property {string} resource - The resource type for the webhook\n * @property {string} event - The event type for the webhook\n * @property {string} filter - The filter that defines the webhook scope\n * @property {string} targetUrl - The URL that receives POST requests for each event\n * @property {string} name - A user-friendly name for this webhook\n * @property {string} created - (server generated) The date and time that the webhook was created\n */\n\n/**\n * Webhooks allow your app to be notified via HTTP when a specific event\n * occurs on Webex. For example, your app can register a webhook to be\n * notified when a new message is posted into a specific room.\n * @class\n */\nconst Webhooks = WebexPlugin.extend({\n /**\n * Posts a webhook.\n * @instance\n * @memberof Webhooks\n * @param {WebhookObject} webhook\n * @returns {Promise<Webhook>}\n * @example\n * webex.rooms.create({title: 'Create Webhook Example'})\n * .then(function(room) {\n * return webex.webhooks.create({\n * resource: 'messages',\n * event: 'created',\n * filter: 'roomId=' + room.id,\n * targetUrl: 'https://example.com/webhook',\n * name: 'Test Webhook'\n * });\n * })\n * .then(function(webhook) {\n * var assert = require('assert');\n * assert(webhook.id);\n * assert(webhook.resource);\n * assert(webhook.event);\n * assert(webhook.filter);\n * assert(webhook.targetUrl);\n * assert(webhook.name);\n * return 'success';\n * });\n * // => success\n */\n create(webhook) {\n return this.request({\n method: 'POST',\n service: 'hydra',\n resource: 'webhooks',\n body: webhook,\n }).then((res) => res.body);\n },\n\n /**\n * Shows details for a webhook.\n * @instance\n * @memberof Webhooks\n * @param {Webhook|string} webhook\n * @returns {Promise<Webhook>}\n * @example\n * var webhook;\n * webex.rooms.create({title: 'Get Webhook Example'})\n * .then(function(room) {\n * return webex.webhooks.create({\n * resource: 'messages',\n * event: 'created',\n * filter: 'roomId=' + room.id,\n * targetUrl: 'https://example.com/webhook',\n * name: 'Test Webhook'\n * });\n * })\n * .then(function(w) {\n * webhook = w;\n * return webex.webhooks.get(webhook.id);\n * })\n * .then(function(webhook2) {\n * var assert = require('assert');\n * assert.deepEqual(webhook2, webhook);\n * return 'success';\n * });\n * // => success\n */\n get(webhook) {\n const id = webhook.id || webhook;\n\n return this.request({\n service: 'hydra',\n resource: `webhooks/${id}`,\n }).then((res) => res.body.items || res.body);\n },\n\n /**\n * Lists all webhooks.\n * @instance\n * @memberof Webhooks\n * @param {Object} options\n * @param {integer} options.max Limit the maximum number of webhooks in the response.\n * @returns {Promise<Array<Webhook>>}\n * @example\n * var room, webhook;\n * webex.rooms.create({title: 'List Webhooks Example'})\n * .then(function(r) {\n * room = r;\n * return webex.webhooks.create({\n * resource: 'messages',\n * event: 'created',\n * filter: 'roomId=' + room.id,\n * targetUrl: 'https://example.com/webhook',\n * name: 'Test Webhook'\n * });\n * })\n * .then(function(w) {\n * webhook = w;\n * return webex.webhooks.list();\n * })\n * .then(function(webhooks) {\n * var assert = require('assert');\n * assert.equal(webhooks.items.filter(function(w) {\n * return w.id === webhook.id;\n * }).length, 1);\n * return 'success';\n * });\n * // => success\n */\n list(options) {\n return this.request({\n service: 'hydra',\n resource: 'webhooks/',\n qs: options,\n }).then((res) => new Page(res, this.webex));\n },\n\n /**\n * Delete a webhook.\n * @instance\n * @memberof Webhooks\n * @param {Webhook|string} webhook\n * @returns {Promise}\n * @example\n * var room, webhook;\n * webex.rooms.create({title: 'Remove Webhook Example'})\n * .then(function(r) {\n * room = r;\n * return webex.webhooks.create({\n * resource: 'messages',\n * event: 'created',\n * filter: 'roomId=' + room.id,\n * targetUrl: 'https://example.com/webhook',\n * name: 'Test Webhook'\n * });\n * })\n * .then(function(w) {\n * webhook = w;\n * return webex.webhooks.remove(webhook);\n * })\n * .then(function() {\n * return webex.webhooks.list();\n * })\n * .then(function(webhooks) {\n * var assert = require('assert');\n * assert.equal(webhooks.items.filter(function(w) {\n * return w.id === webhook.id;\n * }).length, 0);\n * return 'success';\n * });\n * // => success\n */\n remove(webhook) {\n const id = webhook.id || webhook;\n\n return this.request({\n method: 'DELETE',\n service: 'hydra',\n resource: `webhooks/${id}`,\n }).then((res) => {\n // Firefox has some issues with 204s and/or DELETE. This should move to\n // http-core\n if (res.statusCode === 204) {\n return undefined;\n }\n\n return res.body;\n });\n },\n\n /**\n * Update a webhook.\n * @instance\n * @memberof Webhooks\n * @param {Webhook} webhook\n * @returns {Promise<Webhook>}\n * @example\n * var webhook;\n * webex.rooms.create({title: 'Webhook Example'})\n * .then(function(room) {\n * return webex.webhooks.create({\n * resource: 'messages',\n * event: 'created',\n * filter: 'roomId=' + room.id,\n * targetUrl: 'https://example.com/webhook',\n * name: 'Test Webhook'\n * });\n * })\n * .then(function(w) {\n * webhook = w;\n * webhook.targetUrl = 'https://example.com/webhook/newtarget';\n * return webex.webhooks.update(webhook);\n * })\n * .then(function() {\n * return webex.webhooks.get(webhook);\n * })\n * .then(function(webhook) {\n * var assert = require('assert');\n * assert.equal(webhook.targetUrl, 'https://example.com/webhook/newtarget');\n * return 'success';\n * });\n * // => success\n */\n update(webhook) {\n const {id} = webhook;\n\n return this.request({\n method: 'PUT',\n service: 'hydra',\n resource: `webhooks/${id}`,\n body: webhook,\n }).then((res) => res.body);\n },\n});\n\nexport default Webhooks;\n"],"mappings":";;;;;;;AAIA;AAJA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,IAAMA,QAAQ,GAAGC,sBAAW,CAACC,MAAM,CAAC;EAClC;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;EACEC,MAAM,kBAACC,OAAO,EAAE;IACd,OAAO,IAAI,CAACC,OAAO,CAAC;MAClBC,MAAM,EAAE,MAAM;MACdC,OAAO,EAAE,OAAO;MAChBC,QAAQ,EAAE,UAAU;MACpBC,IAAI,EAAEL;IACR,CAAC,CAAC,CAACM,IAAI,CAAC,UAACC,GAAG;MAAA,OAAKA,GAAG,CAACF,IAAI;IAAA,EAAC;EAC5B,CAAC;EAED;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;EACEG,GAAG,eAACR,OAAO,EAAE;IACX,IAAMS,EAAE,GAAGT,OAAO,CAACS,EAAE,IAAIT,OAAO;IAEhC,OAAO,IAAI,CAACC,OAAO,CAAC;MAClBE,OAAO,EAAE,OAAO;MAChBC,QAAQ,qBAAcK,EAAE;IAC1B,CAAC,CAAC,CAACH,IAAI,CAAC,UAACC,GAAG;MAAA,OAAKA,GAAG,CAACF,IAAI,CAACK,KAAK,IAAIH,GAAG,CAACF,IAAI;IAAA,EAAC;EAC9C,CAAC;EAED;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;EACEM,IAAI,gBAACC,OAAO,EAAE;IAAA;IACZ,OAAO,IAAI,CAACX,OAAO,CAAC;MAClBE,OAAO,EAAE,OAAO;MAChBC,QAAQ,EAAE,WAAW;MACrBS,EAAE,EAAED;IACN,CAAC,CAAC,CAACN,IAAI,CAAC,UAACC,GAAG;MAAA,OAAK,IAAIO,eAAI,CAACP,GAAG,EAAE,KAAI,CAACQ,KAAK,CAAC;IAAA,EAAC;EAC7C,CAAC;EAED;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;EACEC,MAAM,kBAAChB,OAAO,EAAE;IACd,IAAMS,EAAE,GAAGT,OAAO,CAACS,EAAE,IAAIT,OAAO;IAEhC,OAAO,IAAI,CAACC,OAAO,CAAC;MAClBC,MAAM,EAAE,QAAQ;MAChBC,OAAO,EAAE,OAAO;MAChBC,QAAQ,qBAAcK,EAAE;IAC1B,CAAC,CAAC,CAACH,IAAI,CAAC,UAACC,GAAG,EAAK;MACf;MACA;MACA,IAAIA,GAAG,CAACU,UAAU,KAAK,GAAG,EAAE;QAC1B,OAAOC,SAAS;MAClB;MAEA,OAAOX,GAAG,CAACF,IAAI;IACjB,CAAC,CAAC;EACJ,CAAC;EAED;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;EACEc,MAAM,kBAACnB,OAAO,EAAE;IACd,IAAOS,EAAE,GAAIT,OAAO,CAAbS,EAAE;IAET,OAAO,IAAI,CAACR,OAAO,CAAC;MAClBC,MAAM,EAAE,KAAK;MACbC,OAAO,EAAE,OAAO;MAChBC,QAAQ,qBAAcK,EAAE,CAAE;MAC1BJ,IAAI,EAAEL;IACR,CAAC,CAAC,CAACM,IAAI,CAAC,UAACC,GAAG;MAAA,OAAKA,GAAG,CAACF,IAAI;IAAA,EAAC;EAC5B,CAAC;EAAA;AACH,CAAC,CAAC;AAAC,eAEYT,QAAQ;AAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webex/plugin-webhooks",
3
- "version": "3.0.0-beta.9",
3
+ "version": "3.0.0-beta.91",
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.9",
24
- "@webex/test-helper-test-users": "3.0.0-beta.9",
23
+ "@webex/test-helper-chai": "3.0.0-beta.91",
24
+ "@webex/test-helper-test-users": "3.0.0-beta.91",
25
25
  "sinon": "^9.2.4"
26
26
  },
27
27
  "dependencies": {
28
- "@webex/internal-plugin-device": "3.0.0-beta.9",
29
- "@webex/plugin-logger": "3.0.0-beta.9",
30
- "@webex/plugin-rooms": "3.0.0-beta.9",
31
- "@webex/plugin-webhooks": "3.0.0-beta.9",
32
- "@webex/webex-core": "3.0.0-beta.9"
28
+ "@webex/internal-plugin-device": "3.0.0-beta.91",
29
+ "@webex/plugin-logger": "3.0.0-beta.91",
30
+ "@webex/plugin-rooms": "3.0.0-beta.91",
31
+ "@webex/plugin-webhooks": "3.0.0-beta.91",
32
+ "@webex/webex-core": "3.0.0-beta.91"
33
33
  }
34
34
  }
package/src/webhooks.js CHANGED
@@ -56,9 +56,8 @@ const Webhooks = WebexPlugin.extend({
56
56
  method: 'POST',
57
57
  service: 'hydra',
58
58
  resource: 'webhooks',
59
- body: webhook
60
- })
61
- .then((res) => res.body);
59
+ body: webhook,
60
+ }).then((res) => res.body);
62
61
  },
63
62
 
64
63
  /**
@@ -95,9 +94,8 @@ const Webhooks = WebexPlugin.extend({
95
94
 
96
95
  return this.request({
97
96
  service: 'hydra',
98
- resource: `webhooks/${id}`
99
- })
100
- .then((res) => res.body.items || res.body);
97
+ resource: `webhooks/${id}`,
98
+ }).then((res) => res.body.items || res.body);
101
99
  },
102
100
 
103
101
  /**
@@ -137,9 +135,8 @@ const Webhooks = WebexPlugin.extend({
137
135
  return this.request({
138
136
  service: 'hydra',
139
137
  resource: 'webhooks/',
140
- qs: options
141
- })
142
- .then((res) => new Page(res, this.webex));
138
+ qs: options,
139
+ }).then((res) => new Page(res, this.webex));
143
140
  },
144
141
 
145
142
  /**
@@ -183,17 +180,16 @@ const Webhooks = WebexPlugin.extend({
183
180
  return this.request({
184
181
  method: 'DELETE',
185
182
  service: 'hydra',
186
- resource: `webhooks/${id}`
187
- })
188
- .then((res) => {
189
- // Firefox has some issues with 204s and/or DELETE. This should move to
190
- // http-core
191
- if (res.statusCode === 204) {
192
- return undefined;
193
- }
183
+ resource: `webhooks/${id}`,
184
+ }).then((res) => {
185
+ // Firefox has some issues with 204s and/or DELETE. This should move to
186
+ // http-core
187
+ if (res.statusCode === 204) {
188
+ return undefined;
189
+ }
194
190
 
195
- return res.body;
196
- });
191
+ return res.body;
192
+ });
197
193
  },
198
194
 
199
195
  /**
@@ -236,10 +232,9 @@ const Webhooks = WebexPlugin.extend({
236
232
  method: 'PUT',
237
233
  service: 'hydra',
238
234
  resource: `webhooks/${id}`,
239
- body: webhook
240
- })
241
- .then((res) => res.body);
242
- }
235
+ body: webhook,
236
+ }).then((res) => res.body);
237
+ },
243
238
  });
244
239
 
245
240
  export default Webhooks;
@@ -16,68 +16,85 @@ describe('plugin-webhooks', function () {
16
16
 
17
17
  let webex;
18
18
 
19
- before(() => testUsers.create({count: 1})
20
- .then(([user]) => {
19
+ before(() =>
20
+ testUsers.create({count: 1}).then(([user]) => {
21
21
  webex = new WebexCore({credentials: user.token});
22
- }));
22
+ })
23
+ );
23
24
 
24
25
  describe('#webhooks', () => {
25
26
  let room;
26
27
 
27
- before(() => webex.rooms.create({
28
- title: 'Webex Webhook Test Room'
29
- })
30
- .then((r) => { room = r; }));
28
+ before(() =>
29
+ webex.rooms
30
+ .create({
31
+ title: 'Webex Webhook Test Room',
32
+ })
33
+ .then((r) => {
34
+ room = r;
35
+ })
36
+ );
31
37
 
32
38
  let webhook;
33
39
  const webhooks = [];
34
40
 
35
- beforeEach(() => webex.webhooks.create({
36
- resource: 'messages',
37
- event: 'created',
38
- filter: `roomId=${room.id}`,
39
- targetUrl: 'https://example.com',
40
- name: 'Test Webhook'
41
- })
42
- .then((w) => {
43
- webhook = w;
44
- webhooks.push(webhook);
45
- }));
46
-
47
- after(() => Promise.all(webhooks.map((webhook) => webex.webhooks.remove(webhook)
48
- .catch((reason) => {
49
- console.warn('failed to remove webhook', reason);
50
- }))));
51
-
52
- after(() => webex.rooms.remove(room)
53
- .catch((reason) => {
41
+ beforeEach(() =>
42
+ webex.webhooks
43
+ .create({
44
+ resource: 'messages',
45
+ event: 'created',
46
+ filter: `roomId=${room.id}`,
47
+ targetUrl: 'https://example.com',
48
+ name: 'Test Webhook',
49
+ })
50
+ .then((w) => {
51
+ webhook = w;
52
+ webhooks.push(webhook);
53
+ })
54
+ );
55
+
56
+ after(() =>
57
+ Promise.all(
58
+ webhooks.map((webhook) =>
59
+ webex.webhooks.remove(webhook).catch((reason) => {
60
+ console.warn('failed to remove webhook', reason);
61
+ })
62
+ )
63
+ )
64
+ );
65
+
66
+ after(() =>
67
+ webex.rooms.remove(room).catch((reason) => {
54
68
  console.warn('failed to remove room', reason);
55
- }));
69
+ })
70
+ );
56
71
 
57
72
  describe('#create()', () => {
58
- it('creates a webhook that listens for new messages', () => webex.webhooks.create({
59
- resource: 'messages',
60
- event: 'created',
61
- filter: `roomId=${room.id}`,
62
- targetUrl: 'https://example.com',
63
- name: 'Test Webhook'
64
- })
65
- .then((webhook) => {
66
- webhooks.push(webhook);
67
- assert.isWebhook(webhook);
68
- }));
73
+ it('creates a webhook that listens for new messages', () =>
74
+ webex.webhooks
75
+ .create({
76
+ resource: 'messages',
77
+ event: 'created',
78
+ filter: `roomId=${room.id}`,
79
+ targetUrl: 'https://example.com',
80
+ name: 'Test Webhook',
81
+ })
82
+ .then((webhook) => {
83
+ webhooks.push(webhook);
84
+ assert.isWebhook(webhook);
85
+ }));
69
86
  });
70
87
 
71
88
  describe('#get()', () => {
72
- it('retrieves a specific webhook', () => webex.webhooks.get(webhook.id)
73
- .then((w) => {
89
+ it('retrieves a specific webhook', () =>
90
+ webex.webhooks.get(webhook.id).then((w) => {
74
91
  assert.deepEqual(w, webhook);
75
92
  }));
76
93
  });
77
94
 
78
95
  describe('#list()', () => {
79
- it('retrieves all the webhooks to which I have access', () => webex.webhooks.list()
80
- .then((webhooks) => {
96
+ it('retrieves all the webhooks to which I have access', () =>
97
+ webex.webhooks.list().then((webhooks) => {
81
98
  assert.isAbove(webhooks.length, 0);
82
99
  for (webhook of webhooks) {
83
100
  assert.isWebhook(webhook);
@@ -88,7 +105,8 @@ describe('plugin-webhooks', function () {
88
105
  it('retrieves a bounded set of webhooks', () => {
89
106
  const spy = sinon.spy();
90
107
 
91
- return webex.webhooks.list({max: 1})
108
+ return webex.webhooks
109
+ .list({max: 1})
92
110
  .then((webhooks) => {
93
111
  assert.lengthOf(webhooks, 1);
94
112
 
@@ -102,7 +120,7 @@ describe('plugin-webhooks', function () {
102
120
  }
103
121
 
104
122
  return Promise.resolve();
105
- }(webhooks));
123
+ })(webhooks);
106
124
  })
107
125
  .then(() => {
108
126
  assert.isAbove(spy.callCount, 0);
@@ -114,32 +132,32 @@ describe('plugin-webhooks', function () {
114
132
  it('updates the target url of the specified webhook', () => {
115
133
  webhook.targetUrl = 'https://example.com/newpath';
116
134
 
117
- return webex.webhooks.update(webhook)
118
- .then((w) => {
119
- assert.deepEqual(w, webhook);
120
- });
135
+ return webex.webhooks.update(webhook).then((w) => {
136
+ assert.deepEqual(w, webhook);
137
+ });
121
138
  });
122
139
 
123
140
  it('updates the name of the specified webhook', () => {
124
141
  webhook.name = 'new name';
125
142
 
126
- return webex.webhooks.update(webhook)
127
- .then((w) => {
128
- assert.deepEqual(w, webhook);
129
- });
143
+ return webex.webhooks.update(webhook).then((w) => {
144
+ assert.deepEqual(w, webhook);
145
+ });
130
146
  });
131
147
  });
132
148
 
133
149
  describe('#remove()', () => {
134
- it('removes the specified webhook', () => webex.webhooks.remove(webhook)
135
- .then((body) => {
136
- assert.notOk(body);
150
+ it('removes the specified webhook', () =>
151
+ webex.webhooks
152
+ .remove(webhook)
153
+ .then((body) => {
154
+ assert.notOk(body);
137
155
 
138
- return assert.isRejected(webex.webhooks.get(webhook));
139
- })
140
- .then((reason) => {
141
- assert.instanceOf(reason, WebexHttpError.NotFound);
142
- }));
156
+ return assert.isRejected(webex.webhooks.get(webhook));
157
+ })
158
+ .then((reason) => {
159
+ assert.instanceOf(reason, WebexHttpError.NotFound);
160
+ }));
143
161
  });
144
162
  });
145
163
  });