Add delivery form feature for development
This commit is contained in:
parent
734e4f61a8
commit
e4eb388074
|
@ -30,6 +30,11 @@ class Configuration implements ConfigurationInterface
|
|||
->isRequired()
|
||||
->end()
|
||||
|
||||
->enumNode('api_method')
|
||||
->defaultValue('GET')
|
||||
->values(array('GET','POST'))
|
||||
->end()
|
||||
|
||||
->scalarNode('from_name')
|
||||
->validate()
|
||||
->ifTrue(function ($s) {
|
||||
|
@ -39,6 +44,10 @@ class Configuration implements ConfigurationInterface
|
|||
->end()
|
||||
->end()
|
||||
|
||||
->scalarNode('delivery_phone')
|
||||
->defaultNull()
|
||||
->end()
|
||||
|
||||
->booleanNode('disable_delivery')
|
||||
->defaultFalse()
|
||||
->end()
|
||||
|
|
|
@ -23,7 +23,9 @@ class JhgNexmoExtension extends Extension
|
|||
|
||||
$container->setParameter('jhg_nexmo.api_key', $config['api_key']);
|
||||
$container->setParameter('jhg_nexmo.api_secret', $config['api_secret']);
|
||||
$container->setParameter('jhg_nexmo.api_method', $config['api_method']);
|
||||
$container->setParameter('jhg_nexmo.disable_delivery', $config['disable_delivery']);
|
||||
$container->setParameter('jhg_nexmo.delivery_phone', $config['delivery_phone']);
|
||||
$container->setParameter('jhg_nexmo.from_name', $config['from_name']);
|
||||
|
||||
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
|
||||
|
|
|
@ -26,16 +26,23 @@ class NexmoClient {
|
|||
*/
|
||||
protected $api_method;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $delivery_phone;
|
||||
|
||||
/**
|
||||
* @param $api_key
|
||||
* @param $api_secret
|
||||
* @param string $api_method GET|POST configured in Nexmo API preferences
|
||||
* @param $delivery_phone
|
||||
*/
|
||||
public function __construct($api_key,$api_secret,$api_method='GET') {
|
||||
public function __construct($api_key,$api_secret,$api_method='GET',$delivery_phone) {
|
||||
$this->rest_url = 'https://rest.nexmo.com';
|
||||
$this->api_key = $api_key;
|
||||
$this->api_secret = $api_secret;
|
||||
$this->api_method = $api_method;
|
||||
$this->delivery_phone = $delivery_phone;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -93,6 +100,11 @@ class NexmoClient {
|
|||
* @throws \Exception
|
||||
*/
|
||||
public function sendTextMessage($fromName,$toNumber,$text,$status_report_req=0) {
|
||||
// delivery phone for development
|
||||
if($this->delivery_phone) {
|
||||
$toNumber = $this->delivery_phone;
|
||||
}
|
||||
|
||||
$params = array(
|
||||
'from'=>$fromName,
|
||||
'to'=>$toNumber,
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
services:
|
||||
jhg_nexmo_client:
|
||||
class: Jhg\NexmoBundle\NexmoClient\NexmoClient
|
||||
arguments: ["%jhg_nexmo.api_key%","%jhg_nexmo.api_secret%"]
|
||||
arguments: ["%jhg_nexmo.api_key%","%jhg_nexmo.api_secret%","%jhg_nexmo.api_method%","%jhg_nexmo.delivery_phone%"]
|
||||
|
||||
jhg_nexmo_account:
|
||||
class: Jhg\NexmoBundle\Managers\AccountManager
|
||||
|
|
Loading…
Reference in New Issue
Block a user