diff --git a/src/Symfony/Component/Notifier/Bridge/Esendex/CHANGELOG.md b/src/Symfony/Component/Notifier/Bridge/Esendex/CHANGELOG.md index d8e243dcb9b42..aba2665873c56 100644 --- a/src/Symfony/Component/Notifier/Bridge/Esendex/CHANGELOG.md +++ b/src/Symfony/Component/Notifier/Bridge/Esendex/CHANGELOG.md @@ -5,6 +5,10 @@ CHANGELOG ----- * The bridge is not marked as `@experimental` anymore +* [BC BREAK] Changed signature of `EsendexTransport::__construct()` method from: + `public function __construct(string $token, string $accountReference, string $from, HttpClientInterface $client = null, EventDispatcherInterface $dispatcher = null)` + to: + `public function __construct(string $email, string $password, string $accountReference, string $from, HttpClientInterface $client = null, EventDispatcherInterface $dispatcher = null)` 5.2.0 ----- diff --git a/src/Symfony/Component/Notifier/Bridge/Esendex/EsendexTransport.php b/src/Symfony/Component/Notifier/Bridge/Esendex/EsendexTransport.php index 0cdfc933a7302..7be72d8264849 100644 --- a/src/Symfony/Component/Notifier/Bridge/Esendex/EsendexTransport.php +++ b/src/Symfony/Component/Notifier/Bridge/Esendex/EsendexTransport.php @@ -26,13 +26,15 @@ final class EsendexTransport extends AbstractTransport { protected const HOST = 'api.esendex.com'; - private $token; + private $email; + private $password; private $accountReference; private $from; - public function __construct(string $token, string $accountReference, string $from, HttpClientInterface $client = null, EventDispatcherInterface $dispatcher = null) + public function __construct(string $email, string $password, string $accountReference, string $from, HttpClientInterface $client = null, EventDispatcherInterface $dispatcher = null) { - $this->token = $token; + $this->email = $email; + $this->password = $password; $this->accountReference = $accountReference; $this->from = $from; @@ -41,7 +43,7 @@ public function __construct(string $token, string $accountReference, string $fro public function __toString(): string { - return sprintf('esendex://%s', $this->getEndpoint()); + return sprintf('esendex://%s?accountreference=%s&from=%s', $this->getEndpoint(), $this->accountReference, $this->from); } public function supports(MessageInterface $message): bool @@ -65,18 +67,20 @@ protected function doSend(MessageInterface $message): SentMessage } $response = $this->client->request('POST', 'https://'.$this->getEndpoint().'/v1.0/messagedispatcher', [ - 'auth_basic' => $this->token, + 'auth_basic' => sprintf('%s:%s', $this->email, $this->password), 'json' => [ 'accountreference' => $this->accountReference, 'messages' => [$messageData], ], ]); - if (200 === $response->getStatusCode()) { + $statusCode = $response->getStatusCode(); + + if (200 === $statusCode) { return new SentMessage($message, (string) $this); } - $message = sprintf('Unable to send the SMS: error %d.', $response->getStatusCode()); + $message = sprintf('Unable to send the SMS: error %d.', $statusCode); try { $result = $response->toArray(false); diff --git a/src/Symfony/Component/Notifier/Bridge/Esendex/EsendexTransportFactory.php b/src/Symfony/Component/Notifier/Bridge/Esendex/EsendexTransportFactory.php index cde7d600279d8..62b8b6a559134 100644 --- a/src/Symfony/Component/Notifier/Bridge/Esendex/EsendexTransportFactory.php +++ b/src/Symfony/Component/Notifier/Bridge/Esendex/EsendexTransportFactory.php @@ -30,7 +30,8 @@ public function create(Dsn $dsn): TransportInterface throw new UnsupportedSchemeException($dsn, 'esendex', $this->getSupportedSchemes()); } - $token = $this->getUser($dsn).':'.$this->getPassword($dsn); + $email = $this->getUser($dsn); + $password = $this->getPassword($dsn); $accountReference = $dsn->getOption('accountreference'); if (!$accountReference) { @@ -46,7 +47,7 @@ public function create(Dsn $dsn): TransportInterface $host = 'default' === $dsn->getHost() ? null : $dsn->getHost(); $port = $dsn->getPort(); - return (new EsendexTransport($token, $accountReference, $from, $this->client, $this->dispatcher))->setHost($host)->setPort($port); + return (new EsendexTransport($email, $password, $accountReference, $from, $this->client, $this->dispatcher))->setHost($host)->setPort($port); } protected function getSupportedSchemes(): array diff --git a/src/Symfony/Component/Notifier/Bridge/Esendex/Tests/EsendexTransportFactoryTest.php b/src/Symfony/Component/Notifier/Bridge/Esendex/Tests/EsendexTransportFactoryTest.php index 469a23c985367..0fe29f74e4656 100644 --- a/src/Symfony/Component/Notifier/Bridge/Esendex/Tests/EsendexTransportFactoryTest.php +++ b/src/Symfony/Component/Notifier/Bridge/Esendex/Tests/EsendexTransportFactoryTest.php @@ -25,7 +25,25 @@ public function testCreateWithDsn() $transport = $factory->create(Dsn::fromString('esendex://email:password@host.test?accountreference=testAccountreference&from=testFrom')); - $this->assertSame('esendex://host.test', (string) $transport); + $this->assertSame('esendex://host.test?accountreference=testAccountreference&from=testFrom', (string) $transport); + } + + public function testCreateWithMissingEmailThrowsIncompleteDsnException() + { + $factory = $this->createFactory(); + + $this->expectException(IncompleteDsnException::class); + + $factory->create(Dsn::fromString('esendex://:password@host?accountreference=testAccountreference&from=FROM')); + } + + public function testCreateWithMissingPasswordThrowsIncompleteDsnException() + { + $factory = $this->createFactory(); + + $this->expectException(IncompleteDsnException::class); + + $factory->create(Dsn::fromString('esendex://email:@host?accountreference=testAccountreference&from=FROM')); } public function testCreateWithMissingOptionAccountreferenceThrowsIncompleteDsnException() diff --git a/src/Symfony/Component/Notifier/Bridge/Esendex/Tests/EsendexTransportTest.php b/src/Symfony/Component/Notifier/Bridge/Esendex/Tests/EsendexTransportTest.php index 28999d43eef42..7f606ad983790 100644 --- a/src/Symfony/Component/Notifier/Bridge/Esendex/Tests/EsendexTransportTest.php +++ b/src/Symfony/Component/Notifier/Bridge/Esendex/Tests/EsendexTransportTest.php @@ -27,7 +27,7 @@ public function testToString() { $transport = $this->createTransport(); - $this->assertSame('esendex://host.test', (string) $transport); + $this->assertSame('esendex://host.test?accountreference=testAccountReference&from=testFrom', (string) $transport); } public function testSupportsSmsMessage() @@ -90,6 +90,6 @@ public function testSendWithErrorResponseContainingDetailsThrows() private function createTransport(?HttpClientInterface $client = null): EsendexTransport { - return (new EsendexTransport('testToken', 'testAccountReference', 'testFrom', $client ?: $this->createMock(HttpClientInterface::class)))->setHost('host.test'); + return (new EsendexTransport('testEmail', 'testPassword', 'testAccountReference', 'testFrom', $client ?: $this->createMock(HttpClientInterface::class)))->setHost('host.test'); } } diff --git a/src/Symfony/Component/Notifier/Bridge/Mattermost/CHANGELOG.md b/src/Symfony/Component/Notifier/Bridge/Mattermost/CHANGELOG.md index b1c417c0b309b..34c179f2c7ea5 100644 --- a/src/Symfony/Component/Notifier/Bridge/Mattermost/CHANGELOG.md +++ b/src/Symfony/Component/Notifier/Bridge/Mattermost/CHANGELOG.md @@ -5,6 +5,10 @@ CHANGELOG ----- * The bridge is not marked as `@experimental` anymore +* [BC BREAK] Changed signature of `MattermostTransport::__construct()` method from: + `public function __construct(string $token, string $channel, HttpClientInterface $client = null, EventDispatcherInterface $dispatcher = null, string $path = null)` + to: + `public function __construct(string $token, string $channel, ?string $path = null, HttpClientInterface $client = null, EventDispatcherInterface $dispatcher = null)` 5.1.0 ----- diff --git a/src/Symfony/Component/Notifier/Bridge/Mattermost/MattermostTransport.php b/src/Symfony/Component/Notifier/Bridge/Mattermost/MattermostTransport.php index 6a718b9145d10..fd5b892071480 100644 --- a/src/Symfony/Component/Notifier/Bridge/Mattermost/MattermostTransport.php +++ b/src/Symfony/Component/Notifier/Bridge/Mattermost/MattermostTransport.php @@ -29,7 +29,7 @@ final class MattermostTransport extends AbstractTransport private $channel; private $path; - public function __construct(string $token, string $channel, HttpClientInterface $client = null, EventDispatcherInterface $dispatcher = null, string $path = null) + public function __construct(string $token, string $channel, ?string $path = null, HttpClientInterface $client = null, EventDispatcherInterface $dispatcher = null) { $this->token = $token; $this->channel = $channel; diff --git a/src/Symfony/Component/Notifier/Bridge/Mattermost/MattermostTransportFactory.php b/src/Symfony/Component/Notifier/Bridge/Mattermost/MattermostTransportFactory.php index 002c760cb7f32..472f63e0eaa9c 100644 --- a/src/Symfony/Component/Notifier/Bridge/Mattermost/MattermostTransportFactory.php +++ b/src/Symfony/Component/Notifier/Bridge/Mattermost/MattermostTransportFactory.php @@ -41,7 +41,7 @@ public function create(Dsn $dsn): TransportInterface $host = $dsn->getHost(); $port = $dsn->getPort(); - return (new MattermostTransport($token, $channel, $this->client, $this->dispatcher, $path))->setHost($host)->setPort($port); + return (new MattermostTransport($token, $channel, $path, $this->client, $this->dispatcher))->setHost($host)->setPort($port); } protected function getSupportedSchemes(): array diff --git a/src/Symfony/Component/Notifier/Bridge/Mattermost/Tests/MattermostTransportTest.php b/src/Symfony/Component/Notifier/Bridge/Mattermost/Tests/MattermostTransportTest.php index 53f91afd46cbd..c5ebe44db40fd 100644 --- a/src/Symfony/Component/Notifier/Bridge/Mattermost/Tests/MattermostTransportTest.php +++ b/src/Symfony/Component/Notifier/Bridge/Mattermost/Tests/MattermostTransportTest.php @@ -29,7 +29,7 @@ final class MattermostTransportTest extends TransportTestCase */ public function createTransport(?HttpClientInterface $client = null): TransportInterface { - return (new MattermostTransport('testAccessToken', 'testChannel', $client ?: $this->createMock(HttpClientInterface::class)))->setHost('host.test'); + return (new MattermostTransport('testAccessToken', 'testChannel', null, $client ?: $this->createMock(HttpClientInterface::class)))->setHost('host.test'); } public function toStringProvider(): iterable pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy