Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 90103f1

Browse filesBrowse files
committed
bug #59611 [Mailer][Notifier] Fix channel parameter value to fixed value for Mailer and Notifier Sweego Transports (welcoMattic)
This PR was merged into the 7.2 branch. Discussion ---------- [Mailer][Notifier] Fix channel parameter value to fixed value for Mailer and Notifier Sweego Transports | Q | A | ------------- | --- | Branch? | 7.2 | Bug fix? | yes | New feature? | no <!-- please update src/**/CHANGELOG.md files --> | Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Issues | Fix #... <!-- prefix each issue number with "Fix #", no need to create an issue if none exists, explain below instead --> | License | MIT Sweego made a change on their API: the `channel` parameter in body is now mandatory with no default value (their documentation does not reflect this yet, but `@pydubreucq` reach me directly for this change). As the fix is surgical and does not require backward compatibility layer, I guess we can pass it as bug fix. WDYT `@OskarStark`? Commits ------- c24fd12 fix(sweego): Fix channel parameter value to fixed value for Mailer and Notifier Transports
2 parents b765290 + c24fd12 commit 90103f1
Copy full SHA for 90103f1

File tree

Expand file treeCollapse file tree

3 files changed

+23
-0
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+23
-0
lines changed

‎src/Symfony/Component/Mailer/Bridge/Sweego/Tests/Transport/SweegoApiTransportTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Mailer/Bridge/Sweego/Tests/Transport/SweegoApiTransportTest.php
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,9 @@ public function testSend()
110110
$this->assertSame('https://api.sweego.io:8984/send', $url);
111111
$this->assertStringContainsString('Accept: */*', $options['headers'][2] ?? $options['request_headers'][1]);
112112

113+
$payload = json_decode($options['body'], true);
114+
$this->assertSame('email', $payload['channel']);
115+
113116
return new JsonMockResponse(['transaction_id' => 'foobar'], [
114117
'http_code' => 200,
115118
]);

‎src/Symfony/Component/Mailer/Bridge/Sweego/Transport/SweegoApiTransport.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Mailer/Bridge/Sweego/Transport/SweegoApiTransport.php
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ private function getPayload(Email $email, Envelope $envelope): array
9090
'from' => $this->formatAddress($envelope->getSender()),
9191
'subject' => $email->getSubject(),
9292
'campaign-type' => 'transac',
93+
'channel' => 'email',
9394
];
9495

9596
if ($email->getTextBody()) {

‎src/Symfony/Component/Notifier/Bridge/Sweego/Tests/SweegoTransportTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Notifier/Bridge/Sweego/Tests/SweegoTransportTest.php
+19Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Component\Notifier\Bridge\Sweego\Tests;
1313

1414
use Symfony\Component\HttpClient\MockHttpClient;
15+
use Symfony\Component\HttpClient\Response\JsonMockResponse;
1516
use Symfony\Component\Notifier\Bridge\Sweego\SweegoTransport;
1617
use Symfony\Component\Notifier\Exception\UnsupportedMessageTypeException;
1718
use Symfony\Component\Notifier\Message\ChatMessage;
@@ -68,4 +69,22 @@ public function testSendWithInvalidMessageType()
6869
$message = $this->createMock(MessageInterface::class);
6970
$transport->send($message);
7071
}
72+
73+
public function testSendSmsMessage()
74+
{
75+
$client = new MockHttpClient(function ($method, $url, $options) {
76+
$this->assertSame('POST', $method);
77+
$this->assertSame('https://api.sweego.io/send', $url);
78+
79+
$body = json_decode($options['body'], true);
80+
$this->assertSame('sms', $body['channel']);
81+
82+
return new JsonMockResponse(['swg_uids' => ['123']]);
83+
});
84+
85+
$transport = self::createTransport($client);
86+
$sentMessage = $transport->send(new SmsMessage('0611223344', 'Hello!'));
87+
88+
$this->assertSame('123', $sentMessage->getMessageId());
89+
}
7190
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.