Skip to content

Beautiful Open-Source Form Builder

879 B
Raw Blame
<?php

namespace App\Integrations\Handlers;

use App\Models\Forms\Form;
use App\Rules\PublicWebhookUrlRule;

class AlbatoIntegration extends AbstractIntegrationHandler
{
    public static function getValidationRules(?Form $form): array
    {
        return [
            'webhook_url' => ['required', 'url', new PublicWebhookUrlRule()],
            'provider_url' => 'nullable|url',
        ];
    }

    protected function getWebhookUrl(): ?string
    {
        return $this->integrationData->webhook_url ?? null;
    }

    protected function shouldRun(): bool
    {
        return !is_null($this->getWebhookUrl()) && parent::shouldRun();
    }

    protected function getWebhookData(): array
    {
        $data = parent::getWebhookData();

        // Remove deprecated fields if they exist
        unset($data['submission'], $data['message']);

        return $data;
    }
}