Add UnroutableSmsMessageException
This commit is contained in:
parent
7de3c7aea9
commit
661df5ac9e
|
@ -36,7 +36,7 @@ class SmsManager
|
|||
* @param string $message
|
||||
* @param null|string $fromName
|
||||
* @param int $status_report_req
|
||||
* @return mixed
|
||||
* @return SmsSendResponse
|
||||
*/
|
||||
public function sendText($number,$message,$fromName=null,$status_report_req=0) {
|
||||
$fromName = $fromName!==null ? $fromName : $this->defaultFromName;
|
||||
|
|
11
NexmoClient/Exceptions/UnroutableSmsMessageException.php
Normal file
11
NexmoClient/Exceptions/UnroutableSmsMessageException.php
Normal file
|
@ -0,0 +1,11 @@
|
|||
<?php
|
||||
namespace Jhg\NexmoBundle\NexmoClient\Exceptions;
|
||||
|
||||
/**
|
||||
* Class UnroutableSmsMessageException
|
||||
* @package Jhg\NexmoBundle\NexmoClient\Exceptions
|
||||
* @author Javi Hernández
|
||||
*/
|
||||
class UnroutableSmsMessageException extends \Exception {
|
||||
|
||||
}
|
|
@ -1,6 +1,8 @@
|
|||
<?php
|
||||
namespace Jhg\NexmoBundle\NexmoClient;
|
||||
|
||||
use Jhg\NexmoBundle\NexmoClient\Exceptions\UnroutableSmsMessageException;
|
||||
|
||||
class NexmoClient {
|
||||
|
||||
/**
|
||||
|
@ -99,7 +101,13 @@ class NexmoClient {
|
|||
$response = $this->jsonRequest('/sms/json',$params);
|
||||
|
||||
if((int)$response['messages'][0]['status']!=0) {
|
||||
throw new \Exception($response['messages'][0]['error-text']);
|
||||
switch((int)$response['messages'][0]['status']) {
|
||||
case 6:
|
||||
throw new UnroutableSmsMessageException();
|
||||
|
||||
default:
|
||||
throw new \Exception($response['messages'][0]['error-text']);
|
||||
}
|
||||
}
|
||||
|
||||
return $response['messages'][0];
|
||||
|
|
Loading…
Reference in New Issue
Block a user