Better webhooks (#155)
* Enable Pro plan - WIP * no pricing page if have no paid plans * Set pricing ids in env * views & submissions FREE for all * extra param for env * form password FREE for all * Custom Code is PRO feature * Replace codeinput prism with codemirror * Better form Cleaning message * Added risky user email spam protection * fix form cleaning * Custom SEO * fix custom seo formcleaner * Better webhooks * fix test case
This commit is contained in:
32
app/Service/Forms/Webhooks/WebhookHandlerProvider.php
Normal file
32
app/Service/Forms/Webhooks/WebhookHandlerProvider.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Service\Forms\Webhooks;
|
||||
|
||||
use App\Models\Forms\Form;
|
||||
|
||||
class WebhookHandlerProvider
|
||||
{
|
||||
const SLACK_PROVIDER = 'slack';
|
||||
const DISCORD_PROVIDER = 'discord';
|
||||
const SIMPLE_WEBHOOK_PROVIDER = 'webhook';
|
||||
const ZAPIER_PROVIDER = 'zapier';
|
||||
|
||||
public static function getProvider(Form $form, array $data, string $provider, ?string $webhookUrl = null)
|
||||
{
|
||||
switch ($provider) {
|
||||
case self::SLACK_PROVIDER:
|
||||
return new SlackHandler($form, $data);
|
||||
case self::DISCORD_PROVIDER:
|
||||
return new DiscordHandler($form, $data);
|
||||
case self::SIMPLE_WEBHOOK_PROVIDER:
|
||||
return new SimpleWebhookHandler($form, $data);
|
||||
case self::ZAPIER_PROVIDER:
|
||||
if (is_null($webhookUrl)) {
|
||||
throw new \Exception('Zapier webhook url is required');
|
||||
}
|
||||
return new ZapierHandler($form, $data, $webhookUrl);
|
||||
default:
|
||||
throw new \Exception('Unknown webhook provider');
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user