Skip to content

Commit

Permalink
Fix the type of the message to save a lot of money 💸 (#69)
Browse files Browse the repository at this point in the history
* Fix the type of the message to save a lot of money

Without specifying the type, the default is unicode and messages are split at 70 chars according to the official documentation : https://developer.vonage.com/en/messaging/sms/guides/concatenation-and-encoding

The default type is defined in class `VonageMessage` message line 26 as `public $type = 'text';`

* Update tests to add the default type "text"

* Fix one test
  • Loading branch information
potsky authored Jan 24, 2023
1 parent f13d3a9 commit 63d208f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/Channels/VonageSmsChannel.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ public function send($notifiable, Notification $notification)
$vonageSms = new SMS(
$to,
$message->from ?: $this->from,
trim($message->content)
trim($message->content),
$message->type
);

$vonageSms->setClientRef($message->clientReference);
Expand Down
9 changes: 6 additions & 3 deletions tests/Unit/Channels/VonageSmsChannelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ public function testSmsIsSentViaVonage()
$mockSms = (new SMS(
'5555555555',
'4444444444',
'this is my message'
'this is my message',
'text'
));

$vonage->shouldReceive('sms->send')
Expand All @@ -46,7 +47,8 @@ public function testSmsIsSentViaVonageWithCustomClient()
->with(IsEqual::equalTo(new SMS(
'5555555555',
'4444444444',
'this is my message'
'this is my message',
'text'
)))
->once();

Expand Down Expand Up @@ -177,7 +179,8 @@ public function testCallbackIsApplied()
$mockSms = (new SMS(
'5555555555',
'4444444444',
'this is my message'
'this is my message',
'text'
));

$mockSms->setDeliveryReceiptCallback('https://example.com');
Expand Down

0 comments on commit 63d208f

Please sign in to comment.