Skip to content

Commit e70407d

Browse files
authored
fix: channel fixes (#4)
1 parent f39e903 commit e70407d

File tree

4 files changed

+15
-14
lines changed

4 files changed

+15
-14
lines changed

src/Exceptions/CouldNotSendNotification.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,4 @@
44

55
class CouldNotSendNotification extends \Exception
66
{
7-
public static function touchSmsError(string $message, int $code): self
8-
{
9-
return new static(sprintf('TouchSms responded with error %d, message: %s', $code, $message), $code);
10-
}
117
}

src/TouchSmsChannel.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function send($notifiable, Notification $notification): void
4242

4343
$apiMessage = (new OutboundMessage())
4444
->setTo($to)
45-
->setFrom($message->sender ?? config('services.touchsms.default_sender'))
45+
->setFrom($message->sender ?? config('services.touchsms.default_sender') ?? 'SHARED_NUMBER')
4646
->setBody($message->content)
4747
->setReference($message->reference)
4848
->setMetadata($message->metadata);
@@ -51,13 +51,13 @@ public function send($notifiable, Notification $notification): void
5151
$apiMessage->setDate($message->sendAt->format(\DateTimeInterface::ATOM));
5252
}
5353

54-
$response = $this->client->sendMessages(new SendMessageBody([
55-
'messages' => [$apiMessage],
56-
]));
54+
$response = $this->client->sendMessages(
55+
(new SendMessageBody())->setMessages([$apiMessage])
56+
);
5757

5858
if (! $response || count($response->getData()->getErrors())) {
5959
$error = $response->getData()->getErrors()[0];
60-
throw CouldNotSendNotification::touchSmsError($error->getErrorCode().$error->getErrorHelp() ? ' - '.$error->getErrorHelp() : '', 400);
60+
throw new CouldNotSendNotification($error->getErrorCode().($error->getErrorHelp() ? ' - '.$error->getErrorHelp() : ''), 400);
6161
}
6262
}
6363
}

src/TouchSmsMessage.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,19 @@ class TouchSmsMessage
1010
public string $content;
1111

1212
/** @var string|null */
13-
public ?string $sender;
13+
public ?string $sender = null;
1414

1515
/** @var string|null */
16-
public ?string $campaign;
16+
public ?string $campaign = null;
1717

1818
/** @var string|null */
19-
public ?string $reference;
19+
public ?string $reference = null;
2020

2121
/** @var DateTimeInterface|null */
22-
public ?DateTimeInterface $sendAt;
22+
public ?DateTimeInterface $sendAt = null;
2323

2424
/** @var array|null */
25-
public ?array $metadata;
25+
public ?array $metadata = null;
2626

2727
public function __construct(string $content = '')
2828
{

src/TouchSmsServiceProvider.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,9 @@ public function register(): void
2828
);
2929
});
3030
}
31+
32+
public function provides(): array
33+
{
34+
return [Client::class];
35+
}
3136
}

0 commit comments

Comments
 (0)