New implementation of bundle

This commit is contained in:
Javier Hernández Gil
2014-03-31 00:20:02 +02:00
parent f01d7194fe
commit cae1a2f071
17 changed files with 619 additions and 199 deletions

View File

@@ -0,0 +1,87 @@
<?php
namespace Jhg\NexmoBundle\Managers;
use Jhg\NexmoBundle\NexmoClient\NexmoClient;
/**
* Class AccountManager
* @package Jhg\NexmoBundle\Managers
* @Author Javi Hernández
*/
class AccountManager
{
/**
* @var \Jhg\NexmoBundle\NexmoClient\NexmoClient
*/
protected $nexmoClient;
/**
* @param NexmoClient $nexmoClient
*/
public function __construct(NexmoClient $nexmoClient) {
$this->nexmoClient = $nexmoClient;
}
/**
* @return bool|float - account balance | false on fail
*/
public function balance() {
$response = $this->nexmoClient->accountBalance();
return floatval($response['value']);
}
/**
* @param $country
* @return bool|float - sms pricing | false on fail
*/
public function smsPricing($country) {
$response = $this->nexmoClient->accountSmsPrice($country);
return floatval($response['mt']);
}
/**
* @todo Implement getCountryDialingCode method
* @param $country_code
* @throws \Exception
*/
public function getCountryDialingCode ($country_code) {
throw new \Exception(__METHOD__.' not yet implemented');
}
/**
* @todo Implement numbersList method
* @throws \Exception
*/
public function numbersList () {
throw new \Exception(__METHOD__.' not yet implemented');
}
/**
* @todo Implement numbersSearch method
* @param $country_code
* @param $pattern
* @throws \Exception
*/
public function numbersSearch ($country_code, $pattern) {
throw new \Exception(__METHOD__.' not yet implemented');
}
/**
* @todo Implement numbersBuy method
* @param $country_code
* @param $msisdn
* @throws \Exception
*/
public function numbersBuy ($country_code, $msisdn) {
throw new \Exception(__METHOD__.' not yet implemented');
}
/**
* @todo Implement numbersCancel method
* @throws \Exception
*/
public function numbersCancel() {
throw new \Exception(__METHOD__.' not yet implemented');
}
}

View File

@@ -0,0 +1,40 @@
<?php
namespace Jhg\NexmoBundle\Managers;
use Jhg\NexmoBundle\NexmoClient\NexmoClient;
/**
* Class NumberManager
* @package Jhg\NexmoBundle\Managers
* @Author Javi Hernández
*/
class NumberManager
{
/**
* @var \Jhg\NexmoBundle\NexmoClient\NexmoClient
*/
protected $nexmoClient;
/**
* @param NexmoClient $nexmoClient
*/
public function __construct(NexmoClient $nexmoClient) {
$this->nexmoClient = $nexmoClient;
}
public function search() {
throw new \Exception(__METHOD__.' not yet implemented');
}
public function buy() {
throw new \Exception(__METHOD__.' not yet implemented');
}
public function cancel() {
throw new \Exception(__METHOD__.' not yet implemented');
}
public function update() {
throw new \Exception(__METHOD__.' not yet implemented');
}
}

67
Managers/SmsManager.php Normal file
View File

@@ -0,0 +1,67 @@
<?php
namespace Jhg\NexmoBundle\Managers;
use Jhg\NexmoBundle\Model\SmsSendResponse;
use Jhg\NexmoBundle\NexmoClient\NexmoClient;
use Jhg\NexmoBundle\Utils\PhoneNumber;
/**
* Class SmsManager
* @package Jhg\NexmoBundle\Managers
* @Author Javi Hernández
*/
class SmsManager
{
/**
* @var \Jhg\NexmoBundle\NexmoClient\NexmoClient
*/
protected $nexmoClient;
/**
* @var string
*/
protected $defaultFromName;
/**
* @param NexmoClient $nexmoClient
* @param $defaultFromName
*/
public function __construct(NexmoClient $nexmoClient,$defaultFromName) {
$this->nexmoClient = $nexmoClient;
$this->defaultFromName = $defaultFromName;
}
/**
* @param string $number
* @param string $message
* @param null|string $fromName
* @param int $status_report_req
* @return mixed
*/
public function sendText($number,$message,$fromName=null,$status_report_req=0) {
$fromName = $fromName!==null ? $fromName : $this->defaultFromName;
$number = PhoneNumber::prefixFilter($number);
$response = $this->nexmoClient->sendTextMessage($fromName,$number,$message,$status_report_req);
return SmsSendResponse::createFromResponse($response);
}
public function sendBinary() {
throw new \Exception(__METHOD__.' not yet implemented');
}
public function sendWapPush() {
throw new \Exception(__METHOD__.' not yet implemented');
}
public function searchMessage() {
throw new \Exception(__METHOD__.' not yet implemented');
}
public function searchMessages() {
throw new \Exception(__METHOD__.' not yet implemented');
}
public function searchRejections() {
throw new \Exception(__METHOD__.' not yet implemented');
}
}