Disable delivery

This commit is contained in:
Javier Hernández Gil 2014-04-08 21:57:45 +02:00
parent e4eb388074
commit 946f86d962
2 changed files with 17 additions and 3 deletions

View File

@ -31,18 +31,25 @@ class NexmoClient {
*/ */
protected $delivery_phone; protected $delivery_phone;
/**
* @var boolean
*/
protected $disable_delivery;
/** /**
* @param $api_key * @param $api_key
* @param $api_secret * @param $api_secret
* @param string $api_method GET|POST configured in Nexmo API preferences * @param string $api_method GET|POST configured in Nexmo API preferences
* @param $delivery_phone * @param string $delivery_phone
* @param boolean $disable_delivery
*/ */
public function __construct($api_key,$api_secret,$api_method='GET',$delivery_phone) { public function __construct($api_key,$api_secret,$api_method='GET',$delivery_phone,$disable_delivery=false) {
$this->rest_url = 'https://rest.nexmo.com'; $this->rest_url = 'https://rest.nexmo.com';
$this->api_key = $api_key; $this->api_key = $api_key;
$this->api_secret = $api_secret; $this->api_secret = $api_secret;
$this->api_method = $api_method; $this->api_method = $api_method;
$this->delivery_phone = $delivery_phone; $this->delivery_phone = $delivery_phone;
$this->disable_delivery = $disable_delivery;
} }
/** /**
@ -111,6 +118,11 @@ class NexmoClient {
'text'=>$text, 'text'=>$text,
'status-report-req'=>$status_report_req, 'status-report-req'=>$status_report_req,
); );
if($this->disable_delivery) {
return null;
}
$response = $this->jsonRequest('/sms/json',$params); $response = $this->jsonRequest('/sms/json',$params);
if((int)$response['messages'][0]['status']!=0) { if((int)$response['messages'][0]['status']!=0) {

View File

@ -1,7 +1,9 @@
services: services:
jhg_nexmo_client: jhg_nexmo_client:
class: Jhg\NexmoBundle\NexmoClient\NexmoClient class: Jhg\NexmoBundle\NexmoClient\NexmoClient
arguments: ["%jhg_nexmo.api_key%","%jhg_nexmo.api_secret%","%jhg_nexmo.api_method%","%jhg_nexmo.delivery_phone%"] arguments: ["%jhg_nexmo.api_key%","%jhg_nexmo.api_secret%",
"%jhg_nexmo.api_method%","%jhg_nexmo.delivery_phone%",
"%jhg_nexmo.disable_delivery%"]
jhg_nexmo_account: jhg_nexmo_account:
class: Jhg\NexmoBundle\Managers\AccountManager class: Jhg\NexmoBundle\Managers\AccountManager