@reactivehub/cli
Version:
92 lines (76 loc) • 2.52 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
var _asyncToGenerator2 = require('babel-runtime/helpers/asyncToGenerator');
var _asyncToGenerator3 = _interopRequireDefault(_asyncToGenerator2);
var _extends2 = require('babel-runtime/helpers/extends');
var _extends3 = _interopRequireDefault(_extends2);
var _api = require('../../services/api');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const hookTypes = [{
id: 'WEBHOOK.CONVERTED'
}, {
id: 'WEBHOOK.MARKED_OPPORTUNITY'
}];
const LIST_WEBHOOKS = {
name: 'LIST_WEBHOOKS',
deploy: (action, eventInfo) => (0, _api.sendAction)(eventInfo, (0, _extends3.default)({ serviceAction: 'LIST_WEBHOOKS' }, action)),
buildTemplate: () => ({}),
questions: () => []
};
const template = {
entity_type: 'CONTACT',
http_method: 'POST',
include_relations: ['COMPANY', 'CONTACT_FUNNEL']
};
const questions = [{
type: 'autocomplete',
name: 'event_type',
message: 'Select the event type?',
source: (() => {
var _ref = (0, _asyncToGenerator3.default)(function* (answersSoFar, input) {
return hookTypes.filter(function ({ id = '', name = '' }) {
return id.match(input) || name.match(input) || !input;
}).map(function ({ id }) {
return id;
});
});
return function source(_x, _x2) {
return _ref.apply(this, arguments);
};
})()
}, {
type: 'input',
name: 'url',
message: 'Destination URL:'
}];
const CREATE_WEBHOOK = {
name: 'CREATE_WEBHOOK',
deploy: (action, eventInfo) => (0, _api.sendAction)(eventInfo, (0, _extends3.default)({ serviceAction: 'CREATE_WEBHOOK' }, action)),
buildTemplate: (answers = {}) => (0, _extends3.default)({}, answers, template),
questions: () => questions
};
const UPDATE_WEBHOOK = {
name: 'UPDATE_WEBHOOK',
deploy: (action, eventInfo) => (0, _api.sendAction)(eventInfo, (0, _extends3.default)({ serviceAction: 'UPDATE_WEBHOOK' }, action)),
buildTemplate: (answers = {}) => (0, _extends3.default)({
uuid: 'String'
}, answers, template),
questions: () => questions
};
const DELETE_WEBHOOK = {
name: 'DELETE_WEBHOOK',
deploy: (action, eventInfo) => (0, _api.sendAction)(eventInfo, (0, _extends3.default)({ serviceAction: 'DELETE_WEBHOOK' }, action)),
buildTemplate: () => ({
uuid: 'String'
}),
questions: () => null
};
exports.default = {
LIST_WEBHOOKS,
CREATE_WEBHOOK,
UPDATE_WEBHOOK,
DELETE_WEBHOOK
};
//# sourceMappingURL=webhook.js.map