Skip to content

Commit 6eef5a7

Browse files
committed
bug #60524 [Notifier] Fix Clicksend transport (BafS)
This PR was squashed before being merged into the 6.4 branch. Discussion ---------- [Notifier] Fix Clicksend transport | Q | A | ------------- | --- | Branch? | 6.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | Fix #52486 | License | MIT Hello, It seems to be an old issue (see #52486) but the format sent to Clicksend is not correct. When using the library we have this error: `[Symfony\Component\Notifier\Exception\TransportException] Unable to send the SMS - "{"http_code":400,"response_code":"BAD_REQUEST","response_msg":"The messages array is empty.","data":null}"`. The correct structure should have a "messages" key (see documentation: https://developers-dev.clicksend.net/docs/messaging/sms/other/send-sms). Commits ------- 734e60a [Notifier] Fix Clicksend transport
2 parents 6013f04 + 734e60a commit 6eef5a7

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/Symfony/Component/Notifier/Bridge/ClickSend/ClickSendTransport.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ protected function doSend(MessageInterface $message): SentMessage
8787

8888
$response = $this->client->request('POST', $endpoint, [
8989
'auth_basic' => [$this->apiUsername, $this->apiKey],
90-
'json' => array_filter($options),
90+
'json' => ['messages' => [array_filter($options)]],
9191
]);
9292

9393
try {

src/Symfony/Component/Notifier/Bridge/ClickSend/Tests/ClickSendTransportTest.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,14 @@ public function testNoInvalidArgumentExceptionIsThrownIfFromIsValid(string $from
6363
$response = $this->createMock(ResponseInterface::class);
6464
$response->expects(self::exactly(2))->method('getStatusCode')->willReturn(200);
6565
$response->expects(self::once())->method('getContent')->willReturn('');
66-
$client = new MockHttpClient(function (string $method, string $url) use ($response): ResponseInterface {
66+
$client = new MockHttpClient(function (string $method, string $url, array $options) use ($response): ResponseInterface {
6767
self::assertSame('POST', $method);
6868
self::assertSame('https://rest.clicksend.com/v3/sms/send', $url);
6969

70+
$body = json_decode($options['body'], true);
71+
self::assertIsArray($body);
72+
self::assertArrayHasKey('messages', $body);
73+
7074
return $response;
7175
});
7276
$transport = $this->createTransport($client, $from);

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