Skip to content

Commit 45990af

Browse files
committed
[Notifier] resolve PR issues
1 parent 9ef4083 commit 45990af

File tree

4 files changed

+30
-7
lines changed

4 files changed

+30
-7
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
/Tests export-ignore
22
/phpunit.xml.dist export-ignore
3-
/.gitignore export-ignore
3+
/.gitignore export-ignore

src/Symfony/Component/Notifier/Bridge/Smsapi/README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,25 @@ SMSAPI Notifier
22
===============
33

44
Provides Smsapi integration for Symfony Notifier.
5+
6+
DSN example
7+
-----------
8+
9+
```
10+
// .env file
11+
SMSAPI_DSN=smsapi://TOKEN@default?from=FROM
12+
```
13+
14+
where:
15+
- `TOKEN` is API Token (OAuth)
16+
- `FROM` is sender name
17+
18+
See your account info at https://ssl.smsapi.pl/
19+
20+
Resources
21+
---------
22+
23+
* [Contributing](https://symfony.com/doc/current/contributing/index.html)
24+
* [Report issues](https://github.com/symfony/symfony/issues) and
25+
[send Pull Requests](https://github.com/symfony/symfony/pulls)
26+
in the [main Symfony repository](https://github.com/symfony/symfony)

src/Symfony/Component/Notifier/Bridge/Smsapi/SmsapiTransport.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@
55
use Symfony\Component\Notifier\Exception\LogicException;
66
use Symfony\Component\Notifier\Exception\TransportException;
77
use Symfony\Component\Notifier\Message\MessageInterface;
8+
use Symfony\Component\Notifier\Message\SentMessage;
89
use Symfony\Component\Notifier\Message\SmsMessage;
910
use Symfony\Component\Notifier\Transport\AbstractTransport;
1011
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
1112
use Symfony\Contracts\HttpClient\HttpClientInterface;
1213

1314
/**
1415
* @author Marcin Szepczynski <szepczynski@gmail.com>
16+
* @experimental in 5.2
1517
*/
1618
final class SmsapiTransport extends AbstractTransport
1719
{
@@ -38,7 +40,7 @@ public function supports(MessageInterface $message): bool
3840
return $message instanceof SmsMessage;
3941
}
4042

41-
protected function doSend(MessageInterface $message): void
43+
protected function doSend(MessageInterface $message): SentMessage
4244
{
4345
if (!$message instanceof SmsMessage) {
4446
throw new LogicException(sprintf('The "%s" transport only supports instances of "%s" (instance of "%s" given).', __CLASS__, SmsMessage::class, get_debug_type($message)));
@@ -58,7 +60,9 @@ protected function doSend(MessageInterface $message): void
5860
if (200 !== $response->getStatusCode()) {
5961
$error = $response->toArray(false);
6062

61-
throw new TransportException(sprintf('Unable to send the SMS: '.$error['message'].' (see %s).', $error['more_info']), $response);
63+
throw new TransportException(sprintf('Unable to send the SMS: %s', $error['message']), $response);
6264
}
65+
66+
return new SentMessage($message, (string) $this);
6367
}
6468
}

src/Symfony/Component/Notifier/Bridge/Smsapi/SmsapiTransportFactory.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
/**
1212
* @author Marcin Szepczynski <szepczynski@gmail.com>
13+
* @experimental in 5.2
1314
*/
1415
class SmsapiTransportFactory extends AbstractTransportFactory
1516
{
@@ -24,10 +25,6 @@ public function create(Dsn $dsn): TransportInterface
2425
$from = $dsn->getOption('from');
2526
$port = $dsn->getPort();
2627

27-
if (!$authToken) {
28-
throw new IncompleteDsnException('Missing path (maybe you haven\'t update the DSN when upgrading from 5.0).', $dsn->getOriginalDsn());
29-
}
30-
3128
if ('smsapi' === $scheme) {
3229
return (new SmsapiTransport($authToken, $from, $this->client, $this->dispatcher))->setHost($host)->setPort($port);
3330
}

0 commit comments

Comments
 (0)