Frontend Webhooks
Helper module for working with webhooks in Zengine frontend plugins.
Installation
# Run this from your frontend plugin's src diretory.
npm i @zenginehq/frontend-webhooks --save
It's important that this gets inside under the plugins/myplugin/src
directory, alongside your plugin's other code if not Maya won't build it properly.
Usage
plugin.controller('MyAwesomeController', ['$scope', 'wgnWebhook', 'wgnScheduledWebhook', function ($scope, webhook, scheduledWebhook) {
$scope.onSomething(function () {
var params = {
'url': 'myservice',
'form.id': 123
};
webhook.create(params).then(function (webhook) {
console.log(webhook.id);
console.log(webhook.secretKey);
});
webhook.enable(webhookId);
webhook.disable(webhookId);
scheduledWebhook.create();
scheduledWebhook.enable();
scheduledWebhook.disable();
});
}]);
Regular vs Scheduled Webhooks
Notice in the example above there are 2 different services being used wgnWebhook
and wgnScheduledWebhook
, they each deal with different kinds of Zengine resources but both expose the exact same API with the following methods available:
- create: creates a new webhook
- enable: enables a webhook
- disable: disables a webhook
- delete: deletes a webhook
- update: updates a webhook