-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Notifier] [BC BREAK] Change constructor signature for Mattermost and Esendex transport #39592
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I also updated the |
||
} | ||
|
||
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), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Before, this was assembled in the factory |
||
'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); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,7 +25,25 @@ public function testCreateWithDsn() | |
|
||
$transport = $factory->create(Dsn::fromString('esendex://email:[email protected]?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() | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,10 @@ CHANGELOG | |
----- | ||
|
||
* The bridge is not marked as `@experimental` anymore | ||
* [BC BREAK] Changed signature of `MattermostTransport::__construct()` method from: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same |
||
`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 | ||
----- | ||
|
Uh oh!
There was an error while loading. Please reload this page.