Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -67,7 +66,7 @@ public function onAuthorize(AuthorizeIntegrationEvent $event): void
'platform' => 'freeform',
];

$client = new Client();
$client = \Craft::createGuzzleClient();
$response = $client->post(
$integration->getAccessTokenUrl(),
[
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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, [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -27,7 +26,7 @@ public function processAccountInfo(SaveEvent $event): void
return;
}

$client = new Client([
$client = \Craft::createGuzzleClient([
'headers' => [
'Content-Type' => 'application/json',
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -143,8 +142,9 @@ public function sendPostPayload(SubmitEvent $event): void
}
}

$client = \Craft::createGuzzleClient();
$payloadEvent = new PostForwardingEvent(
new Client(),
$client,
new Request('POST', $url),
$url,
[],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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]);
Expand Down
3 changes: 1 addition & 2 deletions packages/plugin/src/Integrations/Webhooks/Slack/Slack.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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]);
Expand Down
3 changes: 1 addition & 2 deletions packages/plugin/src/Services/FreeformFeedService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -197,7 +196,7 @@ public function parseFeed(): void
*/
private function getFeed(): array
{
$client = new Client(['verify' => false]);
$client = \Craft::createGuzzleClient(['verify' => false]);

$feed = [];

Expand Down
5 changes: 2 additions & 3 deletions packages/plugin/src/controllers/api/AiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
Loading