Skip to content

Firefly III: a personal finances manager

Move constants to dedicated enum

James Cole9cfced173263
diff --git a/app/Enums/WebhookDelivery.php b/app/Enums/WebhookDelivery.php
new file mode 100644
index 0000000000..c81dbc31b6
--- /dev/null
+++ b/app/Enums/WebhookDelivery.php
@@ -0,0 +1,27 @@
+<?php
+/*
+ * WebhookDelivery.php
+ * Copyright (c) 2022 [email protected]
+ *
+ * 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 <https://www.gnu.org/licenses/>.
+ */
+
+namespace FireflyIII\Enums;
+
+enum WebhookDelivery: int
+{
+ case DELIVERY_JSON = 300;
+}
\ No newline at end of file
diff --git a/app/Enums/WebhookResponse.php b/app/Enums/WebhookResponse.php
new file mode 100644
index 0000000000..c7d1eeb67f
--- /dev/null
+++ b/app/Enums/WebhookResponse.php
@@ -0,0 +1,29 @@
+<?php
+/*
+ * WebhookResponse.php
+ * Copyright (c) 2022 [email protected]
+ *
+ * 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 <https://www.gnu.org/licenses/>.
+ */
+
+namespace FireflyIII\Enums;
+
+enum WebhookResponse: int
+{
+ case RESPONSE_TRANSACTIONS = 200;
+ case RESPONSE_ACCOUNTS = 210;
+ case RESPONSE_NONE = 220;
+}
\ No newline at end of file
diff --git a/app/Enums/WebhookTrigger.php b/app/Enums/WebhookTrigger.php
new file mode 100644
index 0000000000..e08b9af436
--- /dev/null
+++ b/app/Enums/WebhookTrigger.php
@@ -0,0 +1,29 @@
+<?php
+/*
+ * WebhookTrigger.php
+ * Copyright (c) 2022 [email protected]
+ *
+ * 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 <https://www.gnu.org/licenses/>.
+ */
+
+namespace FireflyIII\Enums;
+
+enum WebhookTrigger: int
+{
+ case TRIGGER_STORE_TRANSACTION = 100;
+ case TRIGGER_UPDATE_TRANSACTION = 110;
+ case TRIGGER_DESTROY_TRANSACTION = 120;
+}
\ No newline at end of file
diff --git a/app/Models/Webhook.php b/app/Models/Webhook.php
index f036fb3abe..b16ec4ef30 100644
--- a/app/Models/Webhook.php
+++ b/app/Models/Webhook.php
@@ -77,20 +77,6 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
class Webhook extends Model
{
use SoftDeletes;
-
- // dont forget to update the config in firefly.php
- // triggers
- public const DELIVERY_JSON = 300;
- public const RESPONSE_ACCOUNTS = 210;
- public const RESPONSE_NONE = 220;
-
- // actions
- public const RESPONSE_TRANSACTIONS = 200;
- public const TRIGGER_DESTROY_TRANSACTION = 120;
- public const TRIGGER_STORE_TRANSACTION = 100;
-
- // delivery
- public const TRIGGER_UPDATE_TRANSACTION = 110;
protected $casts
= [
'active' => 'boolean',