mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Expand webhooks to support multiple delivery payloads, event triggers and responses.
This commit is contained in:
@@ -35,25 +35,10 @@ class AccountTypeSeeder extends Seeder
|
||||
{
|
||||
public function run(): void
|
||||
{
|
||||
$types = [
|
||||
AccountTypeEnum::DEFAULT->value,
|
||||
AccountTypeEnum::CASH->value,
|
||||
AccountTypeEnum::ASSET->value,
|
||||
AccountTypeEnum::EXPENSE->value,
|
||||
AccountTypeEnum::REVENUE->value,
|
||||
AccountTypeEnum::INITIAL_BALANCE->value,
|
||||
AccountTypeEnum::BENEFICIARY->value,
|
||||
AccountTypeEnum::IMPORT->value,
|
||||
AccountTypeEnum::LOAN->value,
|
||||
AccountTypeEnum::RECONCILIATION->value,
|
||||
AccountTypeEnum::DEBT->value,
|
||||
AccountTypeEnum::MORTGAGE->value,
|
||||
AccountTypeEnum::LIABILITY_CREDIT->value,
|
||||
];
|
||||
foreach ($types as $type) {
|
||||
if (null === AccountType::where('type', $type)->first()) {
|
||||
foreach(AccountTypeEnum::cases() as $type) {
|
||||
if (null === AccountType::where('type', $type->value)->first()) {
|
||||
try {
|
||||
AccountType::create(['type' => $type]);
|
||||
AccountType::create(['type' => $type->value]);
|
||||
} catch (PDOException $e) {
|
||||
// @ignoreException
|
||||
}
|
||||
|
@@ -43,5 +43,6 @@ class DatabaseSeeder extends Seeder
|
||||
$this->call(ConfigSeeder::class);
|
||||
$this->call(UserRoleSeeder::class);
|
||||
$this->call(ExchangeRateSeeder::class);
|
||||
$this->call(WebhookDataSeeder::class);
|
||||
}
|
||||
}
|
||||
|
@@ -35,24 +35,17 @@ class TransactionTypeSeeder extends Seeder
|
||||
{
|
||||
public function run(): void
|
||||
{
|
||||
$types = [
|
||||
TransactionTypeEnum::WITHDRAWAL->value,
|
||||
TransactionTypeEnum::DEPOSIT->value,
|
||||
TransactionTypeEnum::TRANSFER->value,
|
||||
TransactionTypeEnum::OPENING_BALANCE->value,
|
||||
TransactionTypeEnum::RECONCILIATION->value,
|
||||
TransactionTypeEnum::INVALID->value,
|
||||
TransactionTypeEnum::LIABILITY_CREDIT->value,
|
||||
];
|
||||
|
||||
foreach ($types as $type) {
|
||||
if (null === TransactionType::where('type', $type)->first()) {
|
||||
/** @var TransactionTypeEnum $type */
|
||||
foreach (TransactionTypeEnum::cases() as $type) {
|
||||
if (null === TransactionType::where('type', $type->value)->first()) {
|
||||
try {
|
||||
TransactionType::create(['type' => $type]);
|
||||
TransactionType::create(['type' => $type->value]);
|
||||
} catch (PDOException $e) {
|
||||
// @ignoreException
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -39,16 +39,11 @@ class UserRoleSeeder extends Seeder
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
$roles = [];
|
||||
/** @var UserRoleEnum $role */
|
||||
foreach (UserRoleEnum::cases() as $role) {
|
||||
$roles[] = $role->value;
|
||||
}
|
||||
|
||||
/** @var string $role */
|
||||
foreach ($roles as $role) {
|
||||
if (null === UserRole::where('title', $role)->first()) {
|
||||
if (null === UserRole::where('title', $role->value)->first()) {
|
||||
try {
|
||||
UserRole::create(['title' => $role]);
|
||||
UserRole::create(['title' => $role->value]);
|
||||
} catch (PDOException $e) {
|
||||
// @ignoreException
|
||||
}
|
||||
|
48
database/seeders/WebhookDataSeeder.php
Normal file
48
database/seeders/WebhookDataSeeder.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use FireflyIII\Enums\WebhookTrigger;
|
||||
use FireflyIII\Enums\WebhookResponse;
|
||||
use FireflyIII\Enums\WebhookDelivery;
|
||||
use FireflyIII\Models\WebhookTrigger as WebhookTriggerModel;
|
||||
use FireflyIII\Models\WebhookResponse as WebhookResponseModel;
|
||||
use FireflyIII\Models\WebhookDelivery as WebhookDeliveryModel;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class WebhookDataSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
foreach (WebhookTrigger::cases() as $trigger) {
|
||||
if (null === WebhookTriggerModel::where('key', $trigger->value)->where('title', $trigger->name)->first()) {
|
||||
try {
|
||||
WebhookTriggerModel::create(['key' => $trigger->value, 'title' => $trigger->name]);
|
||||
} catch (\PDOException $e) {
|
||||
// @ignoreException
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach (WebhookResponse::cases() as $response) {
|
||||
if (null === WebhookResponseModel::where('key', $response->value)->where('title', $response->name)->first()) {
|
||||
try {
|
||||
WebhookResponseModel::create(['key' => $response->value, 'title' => $response->name]);
|
||||
} catch (\PDOException $e) {
|
||||
// @ignoreException
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach (WebhookDelivery::cases() as $delivery) {
|
||||
if (null === WebhookDeliveryModel::where('key', $delivery->value)->where('title', $delivery->name)->first()) {
|
||||
try {
|
||||
WebhookDeliveryModel::create(['key' => $delivery->value, 'title' => $delivery->name]);
|
||||
} catch (\PDOException $e) {
|
||||
// @ignoreException
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user