nexmo-bundle/Managers/SmsManager.php

79 lines
2.2 KiB
PHP
Raw Normal View History

2014-03-30 22:20:02 +00:00
<?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
2014-04-07 23:27:44 +00:00
* @return SmsSendResponse
2014-03-30 22:20:02 +00:00
*/
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);
}
2016-01-20 22:14:58 +00:00
/**
* @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);
}
2014-03-30 22:20:02 +00:00
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');
}
}