mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-08-01 07:21:15 +00:00
Merge branch 'cvuorinen-11290-get-webhooks-api' into develop
This commit is contained in:
commit
39a00cd009
2 changed files with 51 additions and 0 deletions
33
test/api/v3/integration/webhook/GET-user-webhook.test.js
Normal file
33
test/api/v3/integration/webhook/GET-user-webhook.test.js
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
import { generateUser } from '../../../../helpers/api-integration/v3';
|
||||
|
||||
describe('GET /user/webhook', () => {
|
||||
let user;
|
||||
|
||||
beforeEach(async () => {
|
||||
user = await generateUser();
|
||||
|
||||
await user.post('/user/webhook', {
|
||||
url: 'http://some-url.com',
|
||||
label: 'Label',
|
||||
enabled: true,
|
||||
type: 'taskActivity',
|
||||
options: { created: true, scored: true },
|
||||
});
|
||||
await user.post('/user/webhook', {
|
||||
url: 'http://some-other-url.com',
|
||||
enabled: false,
|
||||
});
|
||||
|
||||
await user.sync();
|
||||
});
|
||||
|
||||
it('returns users webhooks', async () => {
|
||||
let response = await user.get('/user/webhook');
|
||||
|
||||
expect(response).to.eql(user.webhooks.map(w => {
|
||||
w.createdAt = w.createdAt.toISOString();
|
||||
w.updatedAt = w.updatedAt.toISOString();
|
||||
return w;
|
||||
}));
|
||||
});
|
||||
});
|
||||
|
|
@ -95,6 +95,24 @@ api.addWebhook = {
|
|||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* @api {get} /api/v3/user/webhook Get webhooks
|
||||
* @apiName UserGetWebhook
|
||||
* @apiGroup Webhook
|
||||
*
|
||||
* @apiSuccess {Array} data User's webhooks
|
||||
*/
|
||||
api.getWebhook = {
|
||||
method: 'GET',
|
||||
middlewares: [authWithHeaders()],
|
||||
url: '/user/webhook',
|
||||
async handler (req, res) {
|
||||
const user = res.locals.user;
|
||||
|
||||
res.respond(200, user.webhooks);
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* @api {put} /api/v3/user/webhook/:id Edit a webhook - BETA
|
||||
* @apiName UserUpdateWebhook
|
||||
|
|
|
|||
Loading…
Reference in a new issue