Skip to content

Commit 90103f1

Browse 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

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

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

Lines 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

Lines 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

Lines 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)
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