mirror of
https://github.com/ascribe/onion.git
synced 2024-06-30 13:41:57 +02:00
48 lines
1.1 KiB
JavaScript
48 lines
1.1 KiB
JavaScript
|
'use strict';
|
||
|
|
||
|
import { alt } from '../alt';
|
||
|
import WebhookFetcher from '../fetchers/webhook_fetcher';
|
||
|
|
||
|
|
||
|
class WebhookActions {
|
||
|
constructor() {
|
||
|
this.generateActions(
|
||
|
'updateWebhooks',
|
||
|
'updateEvents',
|
||
|
'removeWebhook'
|
||
|
);
|
||
|
}
|
||
|
|
||
|
fetchWebhooks() {
|
||
|
WebhookFetcher.fetch()
|
||
|
.then((res) => {
|
||
|
this.actions.updateWebhooks(res.webhooks);
|
||
|
})
|
||
|
.catch((err) => {
|
||
|
console.logGlobal(err);
|
||
|
});
|
||
|
}
|
||
|
|
||
|
fetchWebhookEvents() {
|
||
|
WebhookFetcher.fetchEvents()
|
||
|
.then((res) => {
|
||
|
this.actions.updateEvents(res.events);
|
||
|
})
|
||
|
.catch((err) => {
|
||
|
console.logGlobal(err);
|
||
|
});
|
||
|
}
|
||
|
|
||
|
deleteWebhook(id){
|
||
|
WebhookFetcher.deleteWebhook(id)
|
||
|
.then((res) => {
|
||
|
this.actions.removeWebhook(id);
|
||
|
})
|
||
|
.catch((err) => {
|
||
|
console.logGlobal(err);
|
||
|
});
|
||
|
}
|
||
|
}
|
||
|
|
||
|
export default alt.createActions(WebhookActions);
|