diff --git a/packages/plugin/src/Bundles/Integrations/OAuth/Controllers/OAuth2AuthController.php b/packages/plugin/src/Bundles/Integrations/OAuth/Controllers/OAuth2AuthController.php index fc564ffe56..27ae3d73c6 100644 --- a/packages/plugin/src/Bundles/Integrations/OAuth/Controllers/OAuth2AuthController.php +++ b/packages/plugin/src/Bundles/Integrations/OAuth/Controllers/OAuth2AuthController.php @@ -2,7 +2,6 @@ namespace Solspace\Freeform\Bundles\Integrations\OAuth\Controllers; -use GuzzleHttp\Client; use GuzzleHttp\Exception\RequestException; use Solspace\Freeform\Bundles\Integrations\OAuth\Providers\OAuth2StateProvider; use Solspace\Freeform\Bundles\Integrations\Providers\IntegrationLoggerProvider; @@ -59,7 +58,7 @@ public function actionCallback(): Response return $this->renderPopUpError('Integration does not implement OAuth2ConnectorInterface'); } - $client = new Client(); + $client = \Craft::createGuzzleClient(); $payload = [ 'grant_type' => 'authorization_code', 'client_id' => $integration->getClientId(), diff --git a/packages/plugin/src/Bundles/Integrations/OAuth/OAuth2RefreshTokenBundle.php b/packages/plugin/src/Bundles/Integrations/OAuth/OAuth2RefreshTokenBundle.php index 023f992efa..0578e5121b 100644 --- a/packages/plugin/src/Bundles/Integrations/OAuth/OAuth2RefreshTokenBundle.php +++ b/packages/plugin/src/Bundles/Integrations/OAuth/OAuth2RefreshTokenBundle.php @@ -2,7 +2,6 @@ namespace Solspace\Freeform\Bundles\Integrations\OAuth; -use GuzzleHttp\Client; use GuzzleHttp\Exception\RequestException; use Solspace\Freeform\Bundles\Integrations\Providers\IntegrationClientProvider; use Solspace\Freeform\Events\Integrations\FailedRequestEvent; @@ -160,7 +159,7 @@ private function refreshToken(OAuth2RefreshTokenInterface $integration): void throw new IntegrationException('Some or all of the configuration values are missing'); } - $client = new Client(); + $client = \Craft::createGuzzleClient(); $payload = [ 'refresh_token' => $refreshToken, diff --git a/packages/plugin/src/Integrations/AI/SolspaceAI/EventListeners/AuthorizationListener.php b/packages/plugin/src/Integrations/AI/SolspaceAI/EventListeners/AuthorizationListener.php index e15f041b43..08a85cbc79 100644 --- a/packages/plugin/src/Integrations/AI/SolspaceAI/EventListeners/AuthorizationListener.php +++ b/packages/plugin/src/Integrations/AI/SolspaceAI/EventListeners/AuthorizationListener.php @@ -2,7 +2,6 @@ namespace Solspace\Freeform\Integrations\AI\SolspaceAI\EventListeners; -use GuzzleHttp\Client; use GuzzleHttp\Exception\GuzzleException; use GuzzleHttp\Exception\RequestException; use Solspace\Freeform\Events\Integrations\AuthorizeIntegrationEvent; @@ -65,7 +64,7 @@ public function onAuthorize(AuthorizeIntegrationEvent $event): void ]; try { - $client = new Client(['timeout' => 15]); + $client = \Craft::createGuzzleClient(['timeout' => 15]); $response = $client->post($url, [ 'json' => $payload, 'http_errors' => false, diff --git a/packages/plugin/src/Integrations/AI/SolspaceAI/Versions/SolspaceAIV1.php b/packages/plugin/src/Integrations/AI/SolspaceAI/Versions/SolspaceAIV1.php index 79887182e4..97acb74490 100644 --- a/packages/plugin/src/Integrations/AI/SolspaceAI/Versions/SolspaceAIV1.php +++ b/packages/plugin/src/Integrations/AI/SolspaceAI/Versions/SolspaceAIV1.php @@ -84,7 +84,7 @@ public function processAiRequest( public function listModels(bool $refresh = false): array { try { - $client = new Client([ + $client = \Craft::createGuzzleClient([ 'headers' => [ 'Authorization' => 'Bearer '.$this->getApiKey(), ], diff --git a/packages/plugin/src/Integrations/CRM/SugarCRM/EventListeners/AuthorizationListener.php b/packages/plugin/src/Integrations/CRM/SugarCRM/EventListeners/AuthorizationListener.php index 33ab934239..9ed75569a9 100644 --- a/packages/plugin/src/Integrations/CRM/SugarCRM/EventListeners/AuthorizationListener.php +++ b/packages/plugin/src/Integrations/CRM/SugarCRM/EventListeners/AuthorizationListener.php @@ -2,7 +2,6 @@ namespace Solspace\Freeform\Integrations\CRM\SugarCRM\EventListeners; -use GuzzleHttp\Client; use GuzzleHttp\Exception\RequestException; use Solspace\Freeform\Bundles\Integrations\Providers\IntegrationClientProvider; use Solspace\Freeform\Events\Integrations\AuthorizeIntegrationEvent; @@ -67,7 +66,7 @@ public function onAuthorize(AuthorizeIntegrationEvent $event): void 'platform' => 'freeform', ]; - $client = new Client(); + $client = \Craft::createGuzzleClient(); $response = $client->post( $integration->getAccessTokenUrl(), [ @@ -157,7 +156,7 @@ private function refreshToken(SugarCRM $integration): void throw new IntegrationException('Refresh token is missing'); } - $client = new Client(); + $client = \Craft::createGuzzleClient(); $payload = [ 'refresh_token' => $refreshToken, diff --git a/packages/plugin/src/Integrations/Captchas/FriendlyCaptcha/FriendlyCaptcha.php b/packages/plugin/src/Integrations/Captchas/FriendlyCaptcha/FriendlyCaptcha.php index 34c39787d0..215deccc9e 100644 --- a/packages/plugin/src/Integrations/Captchas/FriendlyCaptcha/FriendlyCaptcha.php +++ b/packages/plugin/src/Integrations/Captchas/FriendlyCaptcha/FriendlyCaptcha.php @@ -2,7 +2,6 @@ namespace Solspace\Freeform\Integrations\Captchas\FriendlyCaptcha; -use GuzzleHttp\Client; use GuzzleHttp\Exception\GuzzleException; use Solspace\Freeform\Attributes\Integration\Type; use Solspace\Freeform\Attributes\Property\Flag; @@ -261,7 +260,7 @@ private function getValidationErrors(Form $form): array return ['The Friendly Captcha API key is not configured.']; } - $client = new Client(); + $client = \Craft::createGuzzleClient(); try { $response = $client->post(self::VERIFY_URL, [ diff --git a/packages/plugin/src/Integrations/Captchas/ReCaptcha/ReCaptcha.php b/packages/plugin/src/Integrations/Captchas/ReCaptcha/ReCaptcha.php index 004acc3e0d..2db538e242 100644 --- a/packages/plugin/src/Integrations/Captchas/ReCaptcha/ReCaptcha.php +++ b/packages/plugin/src/Integrations/Captchas/ReCaptcha/ReCaptcha.php @@ -2,7 +2,6 @@ namespace Solspace\Freeform\Integrations\Captchas\ReCaptcha; -use GuzzleHttp\Client; use Solspace\Freeform\Attributes\Integration\Type; use Solspace\Freeform\Attributes\Property\Flag; use Solspace\Freeform\Attributes\Property\Input; @@ -286,7 +285,7 @@ public function getCaptchaHandle(): string private function getValidationErrors(Form $form): array { - $client = new Client(); + $client = \Craft::createGuzzleClient(); $secret = $this->getSecretKey(); $captchaResponse = $this->getCaptchaResponse($form); diff --git a/packages/plugin/src/Integrations/Captchas/Turnstile/Turnstile.php b/packages/plugin/src/Integrations/Captchas/Turnstile/Turnstile.php index efd9aeb78e..b9ce9f68c9 100644 --- a/packages/plugin/src/Integrations/Captchas/Turnstile/Turnstile.php +++ b/packages/plugin/src/Integrations/Captchas/Turnstile/Turnstile.php @@ -2,7 +2,6 @@ namespace Solspace\Freeform\Integrations\Captchas\Turnstile; -use GuzzleHttp\Client; use Solspace\Freeform\Attributes\Integration\Type; use Solspace\Freeform\Attributes\Property\Flag; use Solspace\Freeform\Attributes\Property\Input; @@ -223,7 +222,7 @@ public function getCaptchaHandle(): string private function getValidationErrors(Form $form): array { - $client = new Client(); + $client = \Craft::createGuzzleClient(); $secret = $this->getSecretKey(); $captchaResponse = $this->getCaptchaResponse($form); diff --git a/packages/plugin/src/Integrations/Captchas/hCaptcha/hCaptcha.php b/packages/plugin/src/Integrations/Captchas/hCaptcha/hCaptcha.php index bbe44de110..bcb92be711 100644 --- a/packages/plugin/src/Integrations/Captchas/hCaptcha/hCaptcha.php +++ b/packages/plugin/src/Integrations/Captchas/hCaptcha/hCaptcha.php @@ -2,7 +2,6 @@ namespace Solspace\Freeform\Integrations\Captchas\hCaptcha; -use GuzzleHttp\Client; use Solspace\Freeform\Attributes\Integration\Type; use Solspace\Freeform\Attributes\Property\Flag; use Solspace\Freeform\Attributes\Property\Input; @@ -242,7 +241,7 @@ public function getCaptchaHandle(): string private function getValidationErrors(Form $form): array { - $client = new Client(); + $client = \Craft::createGuzzleClient(); $secret = $this->getSecretKey(); $captchaResponse = $this->getCaptchaResponse($form); diff --git a/packages/plugin/src/Integrations/EmailMarketing/Dotdigital/EventListeners/DotdigitalAccountInfoListener.php b/packages/plugin/src/Integrations/EmailMarketing/Dotdigital/EventListeners/DotdigitalAccountInfoListener.php index 8c3c0e877e..15068e7eea 100644 --- a/packages/plugin/src/Integrations/EmailMarketing/Dotdigital/EventListeners/DotdigitalAccountInfoListener.php +++ b/packages/plugin/src/Integrations/EmailMarketing/Dotdigital/EventListeners/DotdigitalAccountInfoListener.php @@ -2,7 +2,6 @@ namespace Solspace\Freeform\Integrations\EmailMarketing\Dotdigital\EventListeners; -use GuzzleHttp\Client; use Solspace\Freeform\Events\Integrations\SaveEvent; use Solspace\Freeform\Integrations\EmailMarketing\Dotdigital\DotdigitalIntegrationInterface; use Solspace\Freeform\Library\Bundles\FeatureBundle; @@ -27,7 +26,7 @@ public function processAccountInfo(SaveEvent $event): void return; } - $client = new Client([ + $client = \Craft::createGuzzleClient([ 'headers' => [ 'Content-Type' => 'application/json', ], diff --git a/packages/plugin/src/Integrations/EmailMarketing/Mailchimp/EventListeners/MailchimpTokenListener.php b/packages/plugin/src/Integrations/EmailMarketing/Mailchimp/EventListeners/MailchimpTokenListener.php index 39a42bd704..2a13254554 100644 --- a/packages/plugin/src/Integrations/EmailMarketing/Mailchimp/EventListeners/MailchimpTokenListener.php +++ b/packages/plugin/src/Integrations/EmailMarketing/Mailchimp/EventListeners/MailchimpTokenListener.php @@ -2,7 +2,6 @@ namespace Solspace\Freeform\Integrations\EmailMarketing\Mailchimp\EventListeners; -use GuzzleHttp\Client; use Solspace\Freeform\Events\Integrations\OAuth2\TokenPayloadEvent; use Solspace\Freeform\Integrations\EmailMarketing\MailChimp\MailchimpIntegrationInterface; use Solspace\Freeform\Library\Bundles\FeatureBundle; @@ -29,7 +28,7 @@ public function onAfterAuthorize(TokenPayloadEvent $event): void $payload = $event->getResponsePayload(); - $client = new Client([ + $client = \Craft::createGuzzleClient([ 'headers' => [ 'Content-Type' => 'application/json', 'Authorization' => 'OAuth '.$payload->access_token, diff --git a/packages/plugin/src/Integrations/Other/Jira/EventListeners/JiraTokenListener.php b/packages/plugin/src/Integrations/Other/Jira/EventListeners/JiraTokenListener.php index dac36fb0a2..de8821c70a 100644 --- a/packages/plugin/src/Integrations/Other/Jira/EventListeners/JiraTokenListener.php +++ b/packages/plugin/src/Integrations/Other/Jira/EventListeners/JiraTokenListener.php @@ -2,7 +2,6 @@ namespace Solspace\Freeform\Integrations\Other\Jira\EventListeners; -use GuzzleHttp\Client; use Solspace\Freeform\Events\Integrations\OAuth2\InitiateAuthenticationFlowEvent; use Solspace\Freeform\Events\Integrations\OAuth2\TokenPayloadEvent; use Solspace\Freeform\Integrations\Other\Jira\JiraIntegrationInterface; @@ -72,7 +71,7 @@ public function onAfterAuthorize(TokenPayloadEvent $event): void $accessToken = $payload->access_token; $instanceUrl = $integration->getInstanceUrl(); - $client = new Client([ + $client = \Craft::createGuzzleClient([ 'headers' => [ 'Authorization' => 'Bearer '.$accessToken, 'Accept' => 'application/json', diff --git a/packages/plugin/src/Integrations/Single/FormMonitor/EventListeners/AuthorizationListener.php b/packages/plugin/src/Integrations/Single/FormMonitor/EventListeners/AuthorizationListener.php index 8fd229d1ff..9187c2a61d 100644 --- a/packages/plugin/src/Integrations/Single/FormMonitor/EventListeners/AuthorizationListener.php +++ b/packages/plugin/src/Integrations/Single/FormMonitor/EventListeners/AuthorizationListener.php @@ -2,7 +2,6 @@ namespace Solspace\Freeform\Integrations\Single\FormMonitor\EventListeners; -use GuzzleHttp\Client; use Solspace\Freeform\Bundles\Integrations\Providers\IntegrationClientProvider; use Solspace\Freeform\Events\Integrations\AuthorizeIntegrationEvent; use Solspace\Freeform\Events\Integrations\GetAuthorizedClientEvent; @@ -82,7 +81,7 @@ public function onAuthorize(AuthorizeIntegrationEvent $event): void $payload['oldKey'] = $storedLicenseKey; } - $client = new Client(); + $client = \Craft::createGuzzleClient(); $response = $client->post( $integration->getApiRootUrl().'/handshake', ['json' => $payload] diff --git a/packages/plugin/src/Integrations/Single/PostForwarding/EventListeners/PostForwardingTrigger.php b/packages/plugin/src/Integrations/Single/PostForwarding/EventListeners/PostForwardingTrigger.php index 3712137508..c641d516d5 100644 --- a/packages/plugin/src/Integrations/Single/PostForwarding/EventListeners/PostForwardingTrigger.php +++ b/packages/plugin/src/Integrations/Single/PostForwarding/EventListeners/PostForwardingTrigger.php @@ -3,7 +3,6 @@ namespace Solspace\Freeform\Integrations\Single\PostForwarding\EventListeners; use craft\elements\Asset; -use GuzzleHttp\Client; use GuzzleHttp\Psr7\Request; use GuzzleHttp\RequestOptions; use Solspace\Freeform\Bundles\Integrations\Providers\FormIntegrationsProvider; @@ -143,8 +142,9 @@ public function sendPostPayload(SubmitEvent $event): void } } + $client = \Craft::createGuzzleClient(); $payloadEvent = new PostForwardingEvent( - new Client(), + $client, new Request('POST', $url), $url, [], diff --git a/packages/plugin/src/Integrations/Webhooks/Generic/Generic.php b/packages/plugin/src/Integrations/Webhooks/Generic/Generic.php index 1c250769f7..1fafb25319 100644 --- a/packages/plugin/src/Integrations/Webhooks/Generic/Generic.php +++ b/packages/plugin/src/Integrations/Webhooks/Generic/Generic.php @@ -2,7 +2,6 @@ namespace Solspace\Freeform\Integrations\Webhooks\Generic; -use GuzzleHttp\Client; use Solspace\Freeform\Attributes\Integration\Type; use Solspace\Freeform\Attributes\Property\Edition; use Solspace\Freeform\Fields\Implementations\FileUploadField; @@ -49,7 +48,7 @@ public function trigger(Form $form): void $json[$field->getHandle()] = $value; } - $client = new Client(); + $client = \Craft::createGuzzleClient(); $client->post($this->getUrl(), ['json' => $json]); $this->logger->info('Webhook triggered', ['form' => $form->getHandle(), 'submission' => $submission->id]); diff --git a/packages/plugin/src/Integrations/Webhooks/Slack/Slack.php b/packages/plugin/src/Integrations/Webhooks/Slack/Slack.php index d307fb8864..e1083a4886 100644 --- a/packages/plugin/src/Integrations/Webhooks/Slack/Slack.php +++ b/packages/plugin/src/Integrations/Webhooks/Slack/Slack.php @@ -2,7 +2,6 @@ namespace Solspace\Freeform\Integrations\Webhooks\Slack; -use GuzzleHttp\Client; use Solspace\Freeform\Attributes\Integration\Type; use Solspace\Freeform\Attributes\Property\Edition; use Solspace\Freeform\Attributes\Property\Input\TextArea; @@ -52,7 +51,7 @@ public function trigger(Form $form): void return; } - $client = new Client(); + $client = \Craft::createGuzzleClient(); $client->post($this->getUrl(), ['json' => ['text' => $message]]); $this->logger->info('Slack webhook triggered', ['form' => $form->getHandle(), 'submission' => $submission->id]); diff --git a/packages/plugin/src/Services/FreeformFeedService.php b/packages/plugin/src/Services/FreeformFeedService.php index 1bd680e9d2..19e8c05adb 100644 --- a/packages/plugin/src/Services/FreeformFeedService.php +++ b/packages/plugin/src/Services/FreeformFeedService.php @@ -5,7 +5,6 @@ use Carbon\Carbon; use craft\db\Query; use craft\helpers\App; -use GuzzleHttp\Client; use Solspace\Freeform\Freeform; use Solspace\Freeform\Library\DataObjects\FreeformFeed\FeedItem; use Solspace\Freeform\Library\DataObjects\Summary\InstallSummary; @@ -197,7 +196,7 @@ public function parseFeed(): void */ private function getFeed(): array { - $client = new Client(['verify' => false]); + $client = \Craft::createGuzzleClient(['verify' => false]); $feed = []; diff --git a/packages/plugin/src/controllers/api/AiController.php b/packages/plugin/src/controllers/api/AiController.php index 9f258eb97b..68bb3c32b8 100644 --- a/packages/plugin/src/controllers/api/AiController.php +++ b/packages/plugin/src/controllers/api/AiController.php @@ -2,7 +2,6 @@ namespace Solspace\Freeform\controllers\api; -use GuzzleHttp\Client; use GuzzleHttp\Exception\GuzzleException; use Solspace\Freeform\controllers\BaseApiController; use Solspace\Freeform\Freeform; @@ -137,7 +136,7 @@ public function actionCreateCheckoutSession(): Response ], static fn ($v) => $v !== null && $v !== ''); try { - $client = new Client(['timeout' => 15]); + $client = \Craft::createGuzzleClient(['timeout' => 15]); $response = $client->post($url, [ 'json' => $payload, 'headers' => $headers, @@ -192,7 +191,7 @@ private function getLicenseKey(): string private function fetchSolspaceAiUsage(string $url): Response { try { - $client = new Client(['timeout' => 15]); + $client = \Craft::createGuzzleClient(['timeout' => 15]); $response = $client->get($url, [ 'headers' => ['Accept' => 'application/json'], 'http_errors' => false,