@webex/plugin-webhooks 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 +3 -6
- package/dist/webhooks.js +1 -1
- package/dist/webhooks.js.map +1 -1
- package/package.json +8 -8
- package/src/webhooks.js +18 -23
- package/test/integration/spec/webhooks.js +78 -60
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
|
-
.
|
|
38
|
-
|
|
39
|
-
})
|
|
40
|
-
|
|
35
|
+
webex.webhooks.get(id).then((webhook) => {
|
|
36
|
+
console.log(webhook);
|
|
37
|
+
});
|
|
41
38
|
```
|
|
42
39
|
|
|
43
40
|
## Maintainers
|
package/dist/webhooks.js
CHANGED
package/dist/webhooks.js.map
CHANGED
|
@@ -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
|
|
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,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,EAKJM,IALI,CAKC,UAACC,GAAD;MAAA,OAASA,GAAG,CAACF,IAAb;IAAA,CALD,CAAP;EAMD,CArCiC;;EAuClC;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,GApEkC,eAoE9BR,OApE8B,EAoErB;IACX,IAAMS,EAAE,GAAGT,OAAO,CAACS,EAAR,IAAcT,OAAzB;IAEA,OAAO,KAAKC,OAAL,CAAa;MAClBE,OAAO,EAAE,OADS;MAElBC,QAAQ,qBAAcK,EAAd;IAFU,CAAb,EAGJH,IAHI,CAGC,UAACC,GAAD;MAAA,OAASA,GAAG,CAACF,IAAJ,CAASK,KAAT,IAAkBH,GAAG,CAACF,IAA/B;IAAA,CAHD,CAAP;EAID,CA3EiC;;EA6ElC;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,IA9GkC,gBA8G7BC,OA9G6B,EA8GpB;IAAA;;IACZ,OAAO,KAAKX,OAAL,CAAa;MAClBE,OAAO,EAAE,OADS;MAElBC,QAAQ,EAAE,WAFQ;MAGlBS,EAAE,EAAED;IAHc,CAAb,EAIJN,IAJI,CAIC,UAACC,GAAD;MAAA,OAAS,IAAIO,eAAJ,CAASP,GAAT,EAAc,KAAI,CAACQ,KAAnB,CAAT;IAAA,CAJD,CAAP;EAKD,CApHiC;;EAsHlC;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,MAzJkC,kBAyJ3BhB,OAzJ2B,EAyJlB;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,EAIJH,IAJI,CAIC,UAACC,GAAD,EAAS;MACf;MACA;MACA,IAAIA,GAAG,CAACU,UAAJ,KAAmB,GAAvB,EAA4B;QAC1B,OAAOC,SAAP;MACD;;MAED,OAAOX,GAAG,CAACF,IAAX;IACD,CAZM,CAAP;EAaD,CAzKiC;;EA2KlC;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,MA5MkC,kBA4M3BnB,OA5M2B,EA4MlB;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,EAKJM,IALI,CAKC,UAACC,GAAD;MAAA,OAASA,GAAG,CAACF,IAAb;IAAA,CALD,CAAP;EAMD,CArNiC;EAAA;AAAA,CAAnB,CAAjB;;eAwNeT,Q"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webex/plugin-webhooks",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
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.
|
|
24
|
-
"@webex/test-helper-test-users": "3.0.0-beta.
|
|
23
|
+
"@webex/test-helper-chai": "3.0.0-beta.15",
|
|
24
|
+
"@webex/test-helper-test-users": "3.0.0-beta.15",
|
|
25
25
|
"sinon": "^9.2.4"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@webex/internal-plugin-device": "3.0.0-beta.
|
|
29
|
-
"@webex/plugin-logger": "3.0.0-beta.
|
|
30
|
-
"@webex/plugin-rooms": "3.0.0-beta.
|
|
31
|
-
"@webex/plugin-webhooks": "3.0.0-beta.
|
|
32
|
-
"@webex/webex-core": "3.0.0-beta.
|
|
28
|
+
"@webex/internal-plugin-device": "3.0.0-beta.15",
|
|
29
|
+
"@webex/plugin-logger": "3.0.0-beta.15",
|
|
30
|
+
"@webex/plugin-rooms": "3.0.0-beta.15",
|
|
31
|
+
"@webex/plugin-webhooks": "3.0.0-beta.15",
|
|
32
|
+
"@webex/webex-core": "3.0.0-beta.15"
|
|
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
|
-
.
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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(() =>
|
|
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(() =>
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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(() =>
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
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', () =>
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
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', () =>
|
|
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', () =>
|
|
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
|
|
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
|
-
.
|
|
119
|
-
|
|
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
|
-
.
|
|
128
|
-
|
|
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', () =>
|
|
135
|
-
.
|
|
136
|
-
|
|
150
|
+
it('removes the specified webhook', () =>
|
|
151
|
+
webex.webhooks
|
|
152
|
+
.remove(webhook)
|
|
153
|
+
.then((body) => {
|
|
154
|
+
assert.notOk(body);
|
|
137
155
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
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
|
});
|