diff --git a/app/Api/V1/Controllers/Webhook/MessageController.php b/app/Api/V1/Controllers/Webhook/MessageController.php
index 5208666a70..d6d7df57fc 100644
--- a/app/Api/V1/Controllers/Webhook/MessageController.php
+++ b/app/Api/V1/Controllers/Webhook/MessageController.php
@@ -117,7 +117,6 @@ final class MessageController extends Controller
/** @var WebhookMessageTransformer $transformer */
$transformer = app(WebhookMessageTransformer::class);
- $transformer->setParameters($this->parameters);
$resource = new Item($message, $transformer, self::RESOURCE_KEY);
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
diff --git a/resources/assets/v3/js/api/model/webhook/get.js b/resources/assets/v3/js/api/model/webhook/get.js
new file mode 100644
index 0000000000..9644acf4d6
--- /dev/null
+++ b/resources/assets/v3/js/api/model/webhook/get.js
@@ -0,0 +1,38 @@
+/*
+ * get.js
+ * Copyright (c) 2023 james@firefly-iii.org
+ *
+ * This file is part of Firefly III (https://github.com/firefly-iii).
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+
+import {api} from "../../../boot/axios";
+
+export default class Get {
+
+ show(id, params){
+ return api.get('/api/v1/webhooks/' + parseInt(id), {params: params});
+ }
+ messages(id, params){
+ return api.get('/api/v1/webhooks/' + parseInt(id) + '/messages', {params: params});
+ }
+ message(webhook, message, params){
+ return api.get('/api/v1/webhooks/' + parseInt(webhook) + '/messages/' + parseInt(message), {params: params});
+ }
+ attempts(webhook, message, params){
+ return api.get('/api/v1/webhooks/' + parseInt(webhook) + '/messages/' + parseInt(message) + '/attempts', {params: params});
+ }
+}
diff --git a/resources/assets/v3/js/api/model/webhook/post.js b/resources/assets/v3/js/api/model/webhook/post.js
new file mode 100644
index 0000000000..1ab1056da9
--- /dev/null
+++ b/resources/assets/v3/js/api/model/webhook/post.js
@@ -0,0 +1,28 @@
+/*
+ * post.js
+ * Copyright (c) 2023 james@firefly-iii.org
+ *
+ * This file is part of Firefly III (https://github.com/firefly-iii).
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+import {api} from "../../../boot/axios";
+
+export default class Post {
+ triggerTransaction(webhook, transaction) {
+ let url = '/api/v1/webhooks';
+ return api.post('./api/v1/webhooks/' + webhook + '/trigger-transaction/' + transaction, {});
+ }
+}
diff --git a/resources/assets/v3/js/api/model/webhook/put.js b/resources/assets/v3/js/api/model/webhook/put.js
new file mode 100644
index 0000000000..70b33329d2
--- /dev/null
+++ b/resources/assets/v3/js/api/model/webhook/put.js
@@ -0,0 +1,28 @@
+/*
+ * post.js
+ * Copyright (c) 2023 james@firefly-iii.org
+ *
+ * This file is part of Firefly III (https://github.com/firefly-iii).
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+import {api} from "../../../boot/axios";
+
+export default class Put {
+ put(submission, params) {
+ let url = '/api/v1/webhooks/' + parseInt(params.id);
+ return api.put(url, submission);
+ }
+}
diff --git a/resources/assets/v3/js/pages/webhooks/shared/load-deliveries.js b/resources/assets/v3/js/pages/webhooks/shared/load-deliveries.js
index 071741dd37..b3978a7df9 100644
--- a/resources/assets/v3/js/pages/webhooks/shared/load-deliveries.js
+++ b/resources/assets/v3/js/pages/webhooks/shared/load-deliveries.js
@@ -19,20 +19,20 @@
*/
import i18next from "i18next";
+import Get from "../../../api/configuration/get.js";
function loadDeliveries() {
let result = [];
- return axios.get('./api/v1/configuration/webhook.deliveries').then((response) => {
+ return (new Get).getByName('webhook.deliveries').then(response => {
for (let key in response.data.data.value) {
- if (!response.data.data.value.hasOwnProperty(key)) {
- continue;
+ if(Object.hasOwn(response.data.data.value, key)) {
+ result.push(
+ {
+ id: key,
+ name: i18next.t('firefly.webhook_delivery_' + key),
+ }
+ );
}
- result.push(
- {
- id: key,
- name: i18next.t('firefly.webhook_delivery_' + key),
- }
- );
}
return result;
}).catch((error) => {
diff --git a/resources/assets/v3/js/pages/webhooks/shared/load-responses.js b/resources/assets/v3/js/pages/webhooks/shared/load-responses.js
index 54fee7ede9..5e41d3b3a6 100644
--- a/resources/assets/v3/js/pages/webhooks/shared/load-responses.js
+++ b/resources/assets/v3/js/pages/webhooks/shared/load-responses.js
@@ -19,20 +19,20 @@
*/
import i18next from "i18next";
+import Get from "../../../api/configuration/get.js";
function loadResponses() {
let result = [];
- return axios.get('./api/v1/configuration/webhook.responses').then((response) => {
+ return (new Get).getByName('webhook.responses').then(response => {
for (let key in response.data.data.value) {
- if (!response.data.data.value.hasOwnProperty(key)) {
- continue;
+ if(Object.hasOwn(response.data.data.value, key)) {
+ result.push(
+ {
+ id: key,
+ name: i18next.t('firefly.webhook_response_' + key),
+ }
+ );
}
- result.push(
- {
- id: key,
- name: i18next.t('firefly.webhook_response_' + key),
- }
- );
}
return result;
}).catch((error) => {
diff --git a/resources/assets/v3/js/pages/webhooks/shared/load-triggers.js b/resources/assets/v3/js/pages/webhooks/shared/load-triggers.js
index 6a5cfa2f55..91e672391e 100644
--- a/resources/assets/v3/js/pages/webhooks/shared/load-triggers.js
+++ b/resources/assets/v3/js/pages/webhooks/shared/load-triggers.js
@@ -19,21 +19,21 @@
*/
import i18next from "i18next";
+import Get from '../../../api/configuration/get.js';
export function loadTriggers() {
let result = [];
- return axios.get('./api/v1/configuration/webhook.triggers').then((response) => {
- //console.log(response.data.data);
+
+ return (new Get).getByName('webhook.triggers').then(response => {
for (let key in response.data.data.value) {
- if (!response.data.data.value.hasOwnProperty(key)) {
- continue;
+ if(Object.hasOwn(response.data.data.value, key)) {
+ result.push(
+ {
+ id: key,
+ name: i18next.t('firefly.webhook_trigger_' + key),
+ }
+ );
}
- result.push(
- {
- id: key,
- name: i18next.t('firefly.webhook_trigger_' + key),
- }
- );
}
return result;
}).catch((error) => {
diff --git a/resources/assets/v3/js/pages/webhooks/show.js b/resources/assets/v3/js/pages/webhooks/show.js
index 2aa482910b..c9250e8dc0 100644
--- a/resources/assets/v3/js/pages/webhooks/show.js
+++ b/resources/assets/v3/js/pages/webhooks/show.js
@@ -23,6 +23,10 @@ import sidebar from '../../pages/shared/sidebar.js';
import dates from '../shared/dates.js';
import format from "date-fns/format";
import i18next from "i18next";
+import Post from '../../api/model/webhook/post.js';
+import Get from '../../api/model/webhook/get.js';
+import Put from '../../api/model/webhook/put.js';
+import Alpine from 'alpinejs'
window.enableDates = false;
@@ -70,17 +74,9 @@ let show = function () {
}
let journalId = parseInt(prompt('Enter a transaction ID'));
if (journalId !== null && journalId > 0 && journalId <= 16777216) {
- // console.log('OK 1');
this.disabledTrigger = true;
- // disable button. Add informative message.
- //let button = $('#triggerButton');
- //button.prop('disabled', true).addClass('disabled');
-
- this.success_message = this.$t('firefly.webhook_was_triggered');
- // TODO actually trigger the webhook.
- axios.post('./api/v1/webhooks/' + this.id + '/trigger-transaction/' + journalId, {});
- //button.prop('disabled', false).removeClass('disabled');
- // console.log('OK 2');
+ this.success_message = i18next.t('firefly.webhook_was_triggered');
+ (new Post).triggerTransaction(this.id, journalId);
// set a time-outs.
this.loading = true;
@@ -96,8 +92,7 @@ let show = function () {
},
downloadWebhook: function () {
- axios.get('./api/v1/webhooks/' + this.id).then(response => {
- // console.log(response.data.data.attributes);
+ (new Get).show(this.id).then(response => {
this.edit_url = './webhooks/edit/' + this.id;
this.delete_url = './webhooks/delete/' + this.id;
this.title = response.data.data.attributes.title;
@@ -106,9 +101,6 @@ let show = function () {
this.triggers = response.data.data.attributes.triggers;
this.responses = response.data.data.attributes.responses;
this.deliveries = response.data.data.attributes.deliveries;
-
- console.log(response.data.data);
-
this.active = response.data.data.attributes.active;
this.url = response.data.data.attributes.url;
}).catch(error => {
@@ -117,13 +109,13 @@ let show = function () {
},
downloadWebhookMessages: function () {
this.messages = [];
- axios.get('./api/v1/webhooks/' + this.id + '/messages').then(response => {
+ (new Get).messages(this.id, {}).then(response => {
for (let i in response.data.data) {
- if (response.data.data.hasOwnProperty(i)) {
+ if (Object.hasOwn(response.data.data,i)) {
let current = response.data.data[i];
this.messages.push({
id: current.id,
- created_at: format(new Date(current.attributes.created_at), this.$t('config.date_time_fns')),
+ created_at: format(new Date(current.attributes.created_at), i18next.t('config.date_time_fns')),
uuid: current.attributes.uuid,
success: current.attributes.sent && !current.attributes.errored,
message: current.attributes.message,
@@ -134,27 +126,26 @@ let show = function () {
});
},
resetSecret: function () {
- axios.put('./api/v1/webhooks/' + this.id, {secret: 'anything'}).then(() => {
+ (new Put).put({secret: 'anything'}, {id: this.id}).then(() => {
this.downloadWebhook();
});
},
showWebhookMessage: function (id) {
- axios.get('./api/v1/webhooks/' + this.id + '/messages/' + id).then(response => {
- $('#messageModal').modal('show');
+ (new Get).message(this.id, id, {}).then(response => {
this.message_content = response.data.data.attributes.message;
});
},
showWebhookAttempts: function (id) {
+ console.log('showWebhookAttempts', id);
this.message_attempts = [];
- axios.get('./api/v1/webhooks/' + this.id + '/messages/' + id + '/attempts').then(response => {
- $('#attemptModal').modal('show');
+ (new Get).attempts(this.id, id, {}).then(response => {
for (let i in response.data.data) {
- if (response.data.data.hasOwnProperty(i)) {
+ if (Object.hasOwn(response.data.data,i)) {
let current = response.data.data[i];
this.message_attempts.push({
id: current.id,
- created_at: format(new Date(current.attributes.created_at), this.$t('config.date_time_fns')),
+ created_at: format(new Date(current.attributes.created_at), i18next.t('config.date_time_fns')),
logs: current.attributes.logs,
status_code: current.attributes.status_code,
response: current.attributes.response,
@@ -163,7 +154,6 @@ let show = function () {
}
});
},
-
}
};
@@ -179,7 +169,7 @@ function loadPage(comps) {
Object.keys(comps).forEach(comp => {
let data = comps[comp]();
Alpine.data(comp, () => data);
- console.log(comp);
+ //console.log(comp);
});
Alpine.start();
}
diff --git a/resources/lang/en_US/list.php b/resources/lang/en_US/list.php
index 80a1b56875..04b69f0f05 100644
--- a/resources/lang/en_US/list.php
+++ b/resources/lang/en_US/list.php
@@ -23,50 +23,54 @@
declare(strict_types=1);
return [
- 'buttons' => 'Buttons',
- 'icon' => 'Icon',
- 'id' => 'ID',
- 'create_date' => 'Created at',
- 'responds_when' => 'Responds when',
- 'responds_with' => 'Responds with',
- 'primary_currency' => 'Primary currency',
- 'update_date' => 'Updated at',
- 'updated_at' => 'Updated at',
- 'balance_before' => 'Balance before',
- 'balance_after' => 'Balance after',
- 'name' => 'Name',
- 'role' => 'Role',
- 'currentBalance' => 'Current balance',
- 'linked_to_rules' => 'Relevant rules',
- 'active' => 'Is active?',
- 'percentage' => 'pct.',
- 'recurring_transaction' => 'Recurring transaction',
- 'next_due' => 'Next due',
- 'transaction_type' => 'Type',
- 'running_balance' => 'Running balance',
- 'lastActivity' => 'Last activity',
- 'balanceDiff' => 'Balance difference',
- 'other_meta_data' => 'Other meta data',
- 'invited_at' => 'Invited at',
- 'expires' => 'Invitation expires',
- 'invited_by' => 'Invited by',
- 'invite_link' => 'Invite link',
- 'account_type' => 'Account type',
- 'created_at' => 'Created at',
- 'account' => 'Account',
- 'external_url' => 'External URL',
- 'matchingAmount' => 'Amount',
- 'destination' => 'Destination',
- 'source' => 'Source',
- 'next_expected_match' => 'Next expected match',
- 'automatch' => 'Auto match?',
- 'drag_and_drop' => 'Drag and drop',
- 'number' => 'Account number',
- 'current_balance' => 'Current balance',
- 'last_activity' => 'Last activity',
- 'amount_due' => 'Amount due',
- 'balance_difference' => 'Balance difference',
- 'menu' => 'Menu',
+ 'buttons' => 'Buttons',
+ 'icon' => 'Icon',
+ 'id' => 'ID',
+ 'create_date' => 'Created at',
+ 'date_time' => 'Date and time',
+ 'uuid' => 'UUID',
+ 'success' => 'Success?',
+ 'more_details' => 'More details',
+ 'responds_when' => 'Responds when',
+ 'responds_with' => 'Responds with',
+ 'primary_currency' => 'Primary currency',
+ 'update_date' => 'Updated at',
+ 'updated_at' => 'Updated at',
+ 'balance_before' => 'Balance before',
+ 'balance_after' => 'Balance after',
+ 'name' => 'Name',
+ 'role' => 'Role',
+ 'currentBalance' => 'Current balance',
+ 'linked_to_rules' => 'Relevant rules',
+ 'active' => 'Is active?',
+ 'percentage' => 'pct.',
+ 'recurring_transaction' => 'Recurring transaction',
+ 'next_due' => 'Next due',
+ 'transaction_type' => 'Type',
+ 'running_balance' => 'Running balance',
+ 'lastActivity' => 'Last activity',
+ 'balanceDiff' => 'Balance difference',
+ 'other_meta_data' => 'Other meta data',
+ 'invited_at' => 'Invited at',
+ 'expires' => 'Invitation expires',
+ 'invited_by' => 'Invited by',
+ 'invite_link' => 'Invite link',
+ 'account_type' => 'Account type',
+ 'created_at' => 'Created at',
+ 'account' => 'Account',
+ 'external_url' => 'External URL',
+ 'matchingAmount' => 'Amount',
+ 'destination' => 'Destination',
+ 'source' => 'Source',
+ 'next_expected_match' => 'Next expected match',
+ 'automatch' => 'Auto match?',
+ 'drag_and_drop' => 'Drag and drop',
+ 'number' => 'Account number',
+ 'current_balance' => 'Current balance',
+ 'last_activity' => 'Last activity',
+ 'amount_due' => 'Amount due',
+ 'balance_difference' => 'Balance difference',
+ 'menu' => 'Menu',
'repeat_freq' => 'Repeats',
'description' => 'Description',
@@ -134,30 +138,30 @@ return [
'account_at_bunq' => 'Account with bunq',
'file_name' => 'File name',
- 'file_size' => 'File size',
- 'file_type' => 'File type',
- 'attached_to' => 'Attached to',
- 'file_exists' => 'File exists',
- 'spectre_bank' => 'Bank',
- 'spectre_last_use' => 'Last login',
- 'spectre_status' => 'Status',
- 'bunq_payment_id' => 'bunq payment ID',
- 'repetitions' => 'Repetitions',
- 'title' => 'Title',
- 'transaction_s' => 'Transaction(s)',
- 'field' => 'Field',
- 'value' => 'Value',
- 'interest' => 'Interest',
- 'interest_period' => 'Interest period',
- 'liability_type' => 'Type of liability',
- 'liability_direction' => 'Liability in/out',
- 'end_date' => 'End date',
- 'payment_info' => 'Payment information',
- 'expected_info' => 'Next expected transaction',
- 'start_date' => 'Start date',
- 'trigger' => 'Trigger',
- 'response' => 'Response',
- 'delivery' => 'Delivery',
- 'url' => 'URL',
- 'secret' => 'Secret',
+ 'file_size' => 'File size',
+ 'file_type' => 'File type',
+ 'attached_to' => 'Attached to',
+ 'file_exists' => 'File exists',
+ 'spectre_bank' => 'Bank',
+ 'spectre_last_use' => 'Last login',
+ 'spectre_status' => 'Status',
+ 'bunq_payment_id' => 'bunq payment ID',
+ 'repetitions' => 'Repetitions',
+ 'title' => 'Title',
+ 'transaction_s' => 'Transaction(s)',
+ 'field' => 'Field',
+ 'value' => 'Value',
+ 'interest' => 'Interest',
+ 'interest_period' => 'Interest period',
+ 'liability_type' => 'Type of liability',
+ 'liability_direction' => 'Liability in/out',
+ 'end_date' => 'End date',
+ 'payment_info' => 'Payment information',
+ 'expected_info' => 'Next expected transaction',
+ 'start_date' => 'Start date',
+ 'trigger' => 'Trigger',
+ 'response' => 'Response',
+ 'delivery' => 'Delivery',
+ 'url' => 'URL',
+ 'secret' => 'Secret',
];
diff --git a/resources/views/webhooks/show.blade.php b/resources/views/webhooks/show.blade.php
index a0fa348907..fe06fb0e32 100644
--- a/resources/views/webhooks/show.blade.php
+++ b/resources/views/webhooks/show.blade.php
@@ -5,7 +5,8 @@
-
+
{{ __("firefly.flash_success") }}
@@ -72,11 +73,15 @@
@@ -89,29 +94,30 @@
@@ -136,9 +142,9 @@
-
- {{ __('firefly.no_webhook_messages') }}
-
+
+ {{ __('firefly.no_webhook_messages') }}
+
@@ -149,56 +155,60 @@
{{ __('firefly.thinking') }}
+
-
-
+
+
+
+
+ |
+ {{ __('list.date_time') }}
+ |
+
+ {{ __('list.uuid') }}
+ |
+
+ {{ __('list.success') }}
+ |
+
+ {{ __('list.more_details') }}
+ |
+
+
+
+
+
+ |
+
+ |
+
+
+ |
+
+
+
+ |
+
+
+
+ {{ __('firefly.view_message') }}
+
+
+ |
+
+
+
+
+
@@ -217,7 +227,8 @@
@@ -234,31 +245,36 @@
{{ __('firefly.attempt_content_help') }}
-
-
- {{ __('firefly.no_attempts') }}
-
-
-
-
-
-
- ()
-
+
- {{ __('firefly.logs') }}:
-
+
+ {{ __('firefly.no_attempts') }}
+
-
- {{ __('firefly.response') }}:
-
-
-
+
+
+
+
+
+ ()
+
+
+ {{ __('firefly.logs') }}:
+
+
+
+ {{ __('firefly.response') }}:
+
+
+