diff options
author | Paweł Kuffel <pawel@kuffel.io> | 2021-10-04 10:06:20 +0300 |
---|---|---|
committer | Paweł Kuffel <pawel@kuffel.io> | 2021-10-04 10:06:20 +0300 |
commit | f465ef41b2f738d0c357349685bfeec59c370020 (patch) | |
tree | 7a17c4e206fcd81f13f70ca9731d4984ffcc1046 /lib/Service/Gateway/SMS/Provider | |
parent | c125c389a9af06defc6a6d70b607fe701a8e4c4c (diff) |
add SerwerSMS.pl API response error handling
Signed-off-by: Paweł Kuffel <pawel@kuffel.io>
Diffstat (limited to 'lib/Service/Gateway/SMS/Provider')
-rw-r--r-- | lib/Service/Gateway/SMS/Provider/SerwerSMS.php | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/Service/Gateway/SMS/Provider/SerwerSMS.php b/lib/Service/Gateway/SMS/Provider/SerwerSMS.php index 97cdff0..1ed445f 100644 --- a/lib/Service/Gateway/SMS/Provider/SerwerSMS.php +++ b/lib/Service/Gateway/SMS/Provider/SerwerSMS.php @@ -55,7 +55,7 @@ class SerwerSMS implements IProvider { $password = $config->getPassword(); $sender = $config->getSender(); try { - $this->client->post('https://api2.serwersms.pl/messages/send_sms', [ + $response = $this->client->post('https://api2.serwersms.pl/messages/send_sms', [ 'headers' => [ 'Content-Type' => 'application/json', ], @@ -67,6 +67,12 @@ class SerwerSMS implements IProvider { 'sender' => $sender, ], ]); + + $responseData = json_decode($response->getBody(), true); + + if ($responseData['success'] !== true) { + throw new SmsTransmissionException(); + } } catch (Exception $ex) { throw new SmsTransmissionException(); } |