Compare commits
No commits in common. "master" and "v0.9.0" have entirely different histories.
@ -26,7 +26,7 @@ class AccountBalanceCommand extends ContainerAwareCommand
|
||||
* @see Command
|
||||
*/
|
||||
protected function execute(InputInterface $input, OutputInterface $output) {
|
||||
$account = $this->getContainer()->get('jhg_nexmo_account');
|
||||
$account = $this->getContainer()->get('jhg_nexmo.account');
|
||||
$balance = $account->balance();
|
||||
$output->writeln(sprintf('Account balance: %f',$balance));
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ class SmsPricingCommand extends ContainerAwareCommand
|
||||
protected function execute(InputInterface $input, OutputInterface $output) {
|
||||
$country = $input->getArgument('country');
|
||||
|
||||
$account = $this->getContainer()->get('jhg_nexmo_account');
|
||||
$account = $this->getContainer()->get('jhg_nexmo.account');
|
||||
$price = $account->smsPricing($country);
|
||||
|
||||
if($price===false) {
|
||||
|
2
LICENSE
2
LICENSE
@ -1,6 +1,6 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2013 Javi H. Gil
|
||||
Copyright (c) 2013 javihernandezgil
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
|
@ -45,18 +45,6 @@ class SmsManager
|
||||
return SmsSendResponse::createFromResponse($response);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $number
|
||||
* @param string $pin
|
||||
* @param int $client_ref
|
||||
* @return SmsSendResponse
|
||||
*/
|
||||
public function send2fa($number,$pin,$client_ref=false) {
|
||||
$number = PhoneNumber::prefixFilter($number);
|
||||
$response = $this->nexmoClient->send2faMessage($number,$pin,$client_ref);
|
||||
return SmsSendResponse::createFromResponse($response);
|
||||
}
|
||||
|
||||
public function sendBinary() {
|
||||
throw new \Exception(__METHOD__.' not yet implemented');
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ namespace Jhg\NexmoBundle\NexmoClient\Exceptions;
|
||||
/**
|
||||
* Class NexmoClientException
|
||||
* @package Jhg\NexmoBundle\NexmoClient\Exceptions
|
||||
* @author Javi H. Gil <javihgil@gmail.com>
|
||||
* @author Javi Hernández <javibilboweb@gmail.com>
|
||||
*/
|
||||
class NexmoClientException extends \Exception {
|
||||
|
||||
|
@ -4,7 +4,7 @@ namespace Jhg\NexmoBundle\NexmoClient\Exceptions;
|
||||
/**
|
||||
* Class QuotaExcededException
|
||||
* @package Jhg\NexmoBundle\NexmoClient\Exceptions
|
||||
* @author Javi H. Gil <javihgil@gmail.com>
|
||||
* @author Javi Hernández <javibilboweb@gmail.com>
|
||||
*/
|
||||
class QuotaExcededException extends NexmoClientException {
|
||||
|
||||
|
@ -107,66 +107,6 @@ class NexmoClient {
|
||||
return $this->jsonRequest('/account/get-pricing/outbound',array('country'=>$country));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a verifiation PIN using the Two-Factor Authentication API
|
||||
*
|
||||
* @param string $toNumber
|
||||
* @param string $pin
|
||||
* @param int $client_ref
|
||||
* @return array
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function send2faMessage($toNumber,$pin,$client_ref=false) {
|
||||
$this->logger->debug("Nexmo send2faMessage to $toNumber with PIN '$pin'");
|
||||
|
||||
// delivery phone for development
|
||||
if($this->delivery_phone) {
|
||||
$toNumber = $this->delivery_phone;
|
||||
|
||||
$this->logger->debug("Nexmo send2faMessage delivery to $toNumber");
|
||||
}
|
||||
|
||||
$params = array(
|
||||
'to'=>$toNumber,
|
||||
'pin'=>$pin,
|
||||
);
|
||||
|
||||
if($client_ref) {
|
||||
$params['client_ref'] = $client_ref;
|
||||
}
|
||||
|
||||
if($this->disable_delivery) {
|
||||
$this->logger->debug("Nexmo send2faMessage delivery disabled by config");
|
||||
return array(
|
||||
"status" => "0",
|
||||
"message-id" => "delivery-disabled",
|
||||
"to" => $toNumber,
|
||||
"client-ref" => 0,
|
||||
"remaining-balance" => 0,
|
||||
"message-price" => 0,
|
||||
"network" => 0,
|
||||
);
|
||||
}
|
||||
|
||||
$response = $this->jsonRequest('sc/us/2fa/json',$params);
|
||||
|
||||
if(0 !== $code = (int)$response['messages'][0]['status']) {
|
||||
$error = $response['messages'][0]['error-text'];
|
||||
switch( $code) {
|
||||
case 6:
|
||||
throw new UnroutableSmsMessageException($error, $code);
|
||||
|
||||
case 9:
|
||||
throw new QuotaExcededException($error, $code);
|
||||
|
||||
default:
|
||||
throw new NexmoClientException($error, $code);
|
||||
}
|
||||
}
|
||||
|
||||
return $response['messages'][0];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $fromName
|
||||
* @param string $toNumber
|
||||
|
@ -10,7 +10,7 @@ For documentation, see:
|
||||
|
||||
Resources/doc/
|
||||
|
||||
[Read the documentation](https://github.com/javihgil/nexmo-bundle/blob/master/Resources/doc/index.md)
|
||||
[Read the documentation](https://github.com/javihernandezgil/nexmo-bundle/blob/master/Resources/doc/index.md)
|
||||
|
||||
|
||||
License
|
||||
@ -18,4 +18,4 @@ License
|
||||
|
||||
This bundle is under the MIT license:
|
||||
|
||||
[LICENSE](https://github.com/javihgil/nexmo-bundle/blob/master/LICENSE)
|
||||
[LICENSE](https://github.com/javihernandezgil/nexmo-bundle/blob/master/LICENSE)
|
@ -13,12 +13,12 @@ Add this bundle to your `composer.json` file:
|
||||
"repositories": [
|
||||
{
|
||||
"type": "vcs",
|
||||
"url": "https://github.com/javihgil/nexmo-bundle.git"
|
||||
"url": "https://github.com/javihernandezgil/nexmo-bundle.git"
|
||||
}
|
||||
],
|
||||
|
||||
"require": {
|
||||
"javihgil/nexmo-bundle": "dev-master"
|
||||
"javihernandezgil/nexmo-bundle": "dev-master"
|
||||
}
|
||||
}
|
||||
|
||||
@ -65,8 +65,8 @@ Usage
|
||||
|
||||
### Send SMS with service
|
||||
|
||||
$sender = $this->getContainer()->get('jhg_nexmo_sms');
|
||||
$sender->sendText($number, $message, $fromName);
|
||||
$sender = $this->getContainer()->get('jhg_nexmo.sms.sender');
|
||||
$sender->send($number,$fromName,$message);
|
||||
|
||||
If no $fromName is provided 'jhg_nexmo.from_name' is used. This from name is limited to 11 characters (spaces and special chars are not allowed).
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
{
|
||||
"name": "javihgil/nexmo-bundle",
|
||||
"name": "javihernandezgil/nexmo-bundle",
|
||||
"type": "symfony-bundle",
|
||||
"description": "This bundle integrates Nexmo libs",
|
||||
"keywords": ["symfony", "bundle", "nexmo", "sms"],
|
||||
@ -8,7 +8,7 @@
|
||||
"authors": [
|
||||
{
|
||||
"name": "Javi Hernández Gil",
|
||||
"homepage": "https://github.com/javihgil/nexmo-bundle"
|
||||
"homepage": "https://github.com/javihernandezgil/nexmo-bundle"
|
||||
}
|
||||
],
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user