Move constants to dedicated enum

This commit is contained in:
James Cole 2022-04-13 14:21:33 +02:00
parent a2627b5158
commit 9cfced1732
No known key found for this signature in database
GPG Key ID: B49A324B7EAD6D80
4 changed files with 85 additions and 14 deletions

View File

@ -0,0 +1,27 @@
<?php
/*
* WebhookDelivery.php
* Copyright (c) 2022 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 <https://www.gnu.org/licenses/>.
*/
namespace FireflyIII\Enums;
enum WebhookDelivery: int
{
case DELIVERY_JSON = 300;
}

View File

@ -0,0 +1,29 @@
<?php
/*
* WebhookResponse.php
* Copyright (c) 2022 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 <https://www.gnu.org/licenses/>.
*/
namespace FireflyIII\Enums;
enum WebhookResponse: int
{
case RESPONSE_TRANSACTIONS = 200;
case RESPONSE_ACCOUNTS = 210;
case RESPONSE_NONE = 220;
}

View File

@ -0,0 +1,29 @@
<?php
/*
* WebhookTrigger.php
* Copyright (c) 2022 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 <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;
}

View File

@ -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',