package updates
This commit is contained in:
+82
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
/**
|
||||
* Nexmo Client Library for PHP
|
||||
*
|
||||
* @copyright Copyright (c) 2016 Nexmo, Inc. (http://nexmo.com)
|
||||
* @license https://github.com/Nexmo/nexmo-php/blob/master/LICENSE.txt MIT License
|
||||
*/
|
||||
|
||||
namespace Nexmo\Voice\Call;
|
||||
use Nexmo\Client\Request\AbstractRequest;
|
||||
use Nexmo\Client\Request\RequestInterface;
|
||||
|
||||
class Call extends AbstractRequest implements RequestInterface
|
||||
{
|
||||
public function __construct($url, $to, $from = null)
|
||||
{
|
||||
$this->params['answer_url'] = $url;
|
||||
$this->params['to'] = $to;
|
||||
|
||||
if(!is_null($from)){
|
||||
$this->params['from'] = $from;
|
||||
}
|
||||
}
|
||||
|
||||
public function setAnswer($url, $method = null)
|
||||
{
|
||||
$this->params['answer_url'] = $url;
|
||||
if(!is_null($method)){
|
||||
$this->params['answer_method'] = $method;
|
||||
} else {
|
||||
unset($this->params['answer_method']);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setError($url, $method = null)
|
||||
{
|
||||
$this->params['error_url'] = $url;
|
||||
if(!is_null($method)){
|
||||
$this->params['error_method'] = $method;
|
||||
} else {
|
||||
unset($this->params['error_method']);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setStatus($url, $method = null)
|
||||
{
|
||||
$this->params['status_url'] = $url;
|
||||
if(!is_null($method)){
|
||||
$this->params['status_method'] = $method;
|
||||
} else {
|
||||
unset($this->params['status_method']);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
public function setMachineDetection($hangup = true, $timeout = null)
|
||||
{
|
||||
$this->params['machine_detection'] = ($hangup ? 'hangup' : 'true');
|
||||
if(!is_null($timeout)){
|
||||
$this->params['machine_timeout'] = (int) $timeout;
|
||||
} else {
|
||||
unset($this->params['machine_timeout']);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getURI()
|
||||
{
|
||||
return '/call/json';
|
||||
}
|
||||
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
/**
|
||||
* Nexmo Client Library for PHP
|
||||
*
|
||||
* @copyright Copyright (c) 2016 Nexmo, Inc. (http://nexmo.com)
|
||||
* @license https://github.com/Nexmo/nexmo-php/blob/master/LICENSE.txt MIT License
|
||||
*/
|
||||
|
||||
namespace Nexmo\Voice\Call;
|
||||
|
||||
|
||||
class Inbound
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
/**
|
||||
* Nexmo Client Library for PHP
|
||||
*
|
||||
* @copyright Copyright (c) 2016 Nexmo, Inc. (http://nexmo.com)
|
||||
* @license https://github.com/Nexmo/nexmo-php/blob/master/LICENSE.txt MIT License
|
||||
*/
|
||||
|
||||
namespace Nexmo\Voice\Message;
|
||||
use Nexmo\Client\Callback\CallbackInterface;
|
||||
use Nexmo\Client\Callback\Callback as BaseCallback;
|
||||
|
||||
class Callback extends BaseCallback implements CallbackInterface
|
||||
{
|
||||
const TIME_FORMAT = 'Y-m-d H:i:s';
|
||||
|
||||
protected $expected = array(
|
||||
'call-id',
|
||||
'status',
|
||||
'call-price',
|
||||
'call-rate',
|
||||
'call-duration',
|
||||
'to',
|
||||
'call-request',
|
||||
'network-code',
|
||||
);
|
||||
|
||||
public function getId()
|
||||
{
|
||||
return $this->data['call-id'];
|
||||
}
|
||||
|
||||
public function getTo()
|
||||
{
|
||||
return $this->data['to'];
|
||||
}
|
||||
|
||||
public function getStatus()
|
||||
{
|
||||
return $this->data['status'];
|
||||
}
|
||||
|
||||
public function getPrice()
|
||||
{
|
||||
return $this->data['call-price'];
|
||||
}
|
||||
|
||||
public function getRate()
|
||||
{
|
||||
return $this->data['call-rate'];
|
||||
}
|
||||
|
||||
public function getDuration()
|
||||
{
|
||||
return $this->data['call-duration'];
|
||||
}
|
||||
|
||||
public function getCreated()
|
||||
{
|
||||
return \DateTime::createFromFormat(self::TIME_FORMAT, $this->data['call-request']);
|
||||
}
|
||||
|
||||
public function getStart()
|
||||
{
|
||||
if(!isset($this->data['call-start'])){
|
||||
return null;
|
||||
}
|
||||
|
||||
return \DateTime::createFromFormat(self::TIME_FORMAT, $this->data['call-start']);
|
||||
}
|
||||
|
||||
public function getEnd()
|
||||
{
|
||||
if(!isset($this->data['call-end'])){
|
||||
return null;
|
||||
}
|
||||
|
||||
return \DateTime::createFromFormat(self::TIME_FORMAT, $this->data['call-end']);
|
||||
}
|
||||
|
||||
public function getNetwork()
|
||||
{
|
||||
return $this->data['network-code'];
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
/**
|
||||
* Nexmo Client Library for PHP
|
||||
*
|
||||
* @copyright Copyright (c) 2016 Nexmo, Inc. (http://nexmo.com)
|
||||
* @license https://github.com/Nexmo/nexmo-php/blob/master/LICENSE.txt MIT License
|
||||
*/
|
||||
|
||||
namespace Nexmo\Voice\Message;
|
||||
use Nexmo\Client\Request\AbstractRequest;
|
||||
use Nexmo\Client\Request\RequestInterface;
|
||||
|
||||
class Message extends AbstractRequest implements RequestInterface
|
||||
{
|
||||
protected $params = array();
|
||||
|
||||
public function __construct($text, $to, $from = null)
|
||||
{
|
||||
$this->params['text'] = $text;
|
||||
$this->params['to'] = $to;
|
||||
$this->params['from'] = $from;
|
||||
}
|
||||
|
||||
public function setLanguage($lang)
|
||||
{
|
||||
$this->params['lg'] = $lang;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setVoice($voice)
|
||||
{
|
||||
$this->params['voice'] = $voice;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setRepeat($count)
|
||||
{
|
||||
$this->params['repeat'] = (int) $count;
|
||||
return $this;
|
||||
}
|
||||
public function setCallback($url, $method = null)
|
||||
{
|
||||
$this->params['callback'] = $url;
|
||||
if(!is_null($method)){
|
||||
$this->params['callback_method'] = $method;
|
||||
} else {
|
||||
unset($this->params['callback_method']);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setMachineDetection($hangup = true, $timeout = null)
|
||||
{
|
||||
$this->params['machine_detection'] = ($hangup ? 'hangup' : 'true');
|
||||
if(!is_null($timeout)){
|
||||
$this->params['machine_timeout'] = (int) $timeout;
|
||||
} else {
|
||||
unset($this->params['machine_timeout']);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getURI()
|
||||
{
|
||||
return '/tts/json';
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user