Skip to content

Commit

Permalink
Add log for hook creation and deletion commands
Browse files Browse the repository at this point in the history
  • Loading branch information
Rémi committed Jul 21, 2017
1 parent a5ad08d commit 69de8e0
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/clients/HookClient.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
const PageableStream = require('./PageableStream');
const HTTPClient = require('./HTTPClient');
const logger = require('../utils/logger');

const endpoints = {
createHook: {
method: 'POST',
path: '/api/dispatcher/hooks'
},
getHooks: {
method: 'GET',
path: '/api/dispatcher/hooks'
},
deleteHook: {
method: 'DELETE',
path: '/api/dispatcher/hooks/:hook'
Expand All @@ -30,7 +36,12 @@ class HookClient {
).then(response => {
resolve(response.body);
}).catch(err => {
reject(err.message);
if (err.statusCode === 400) {
reject('A hook with this name already exists.');
}
else {
reject(err.message);
}
});
});
}
Expand All @@ -50,7 +61,12 @@ class HookClient {
).then(response => {
resolve(response.body);
}).catch(err => {
reject(err.message);
if (err.statusCode === 404) {
reject('The hook you are trying to remove does not exist.');
}
else {
reject(err.message);
}
});
});
}
Expand Down

0 comments on commit 69de8e0

Please sign in to comment.