Skip to content

Commit

Permalink
Merge pull request #41 from thomasvargiu/feature/agi_network
Browse files Browse the repository at this point in the history
Support for agi network variables (with tests)
  • Loading branch information
marcelog committed Sep 8, 2017
2 parents 4f90722 + 466cfc9 commit c72d503
Show file tree
Hide file tree
Showing 16 changed files with 103 additions and 18 deletions.
4 changes: 2 additions & 2 deletions doc/PAGI-CallSpool-CallFile.md
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ file_get_contents() or similar).</p>

### __construct

void PAGI\CallSpool\CallFile::__construct(\PAGI\DialDescriptor\DialDescriptor $dialDescriptor)
void PAGI\CallSpool\CallFile::__construct(\PAGI\CallSpool\PAGI\DialDescriptor\DialDescriptor $dialDescriptor)

Constructor.

Expand All @@ -522,6 +522,6 @@ Constructor.


#### Arguments
* $dialDescriptor **[PAGI\DialDescriptor\DialDescriptor](PAGI-DialDescriptor-DialDescriptor.md)**
* $dialDescriptor **PAGI\CallSpool\PAGI\DialDescriptor\DialDescriptor** - <p>dial descriptor</p>


26 changes: 26 additions & 0 deletions doc/PAGI-ChannelVariables-IChannelVariables.md
Original file line number Diff line number Diff line change
Expand Up @@ -463,3 +463,29 @@ Uses environment variable AST_RUN_DIR.




### getNetworkScript

string PAGI\ChannelVariables\IChannelVariables::getNetworkScript()

Returns agi_network_script.



* Visibility: **public**




### getNetwork

string PAGI\ChannelVariables\IChannelVariables::getNetwork()

Returns agi_network.



* Visibility: **public**



28 changes: 28 additions & 0 deletions doc/PAGI-ChannelVariables-Impl-ChannelVariablesFacade.md
Original file line number Diff line number Diff line change
Expand Up @@ -554,3 +554,31 @@ Constructor.
* $arguments **array<mixed,string>** - <p>AGI arguments given by asterisk (agi_arg_N).</p>



### getNetworkScript

string PAGI\ChannelVariables\IChannelVariables::getNetworkScript()

Returns agi_network_script.



* Visibility: **public**
* This method is defined by [PAGI\ChannelVariables\IChannelVariables](PAGI-ChannelVariables-IChannelVariables.md)




### getNetwork

string PAGI\ChannelVariables\IChannelVariables::getNetwork()

Returns agi_network.



* Visibility: **public**
* This method is defined by [PAGI\ChannelVariables\IChannelVariables](PAGI-ChannelVariables-IChannelVariables.md)



2 changes: 1 addition & 1 deletion doc/PAGI-Client-AbstractClient.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Properties

### $logger

protected \PAGI\Client\Logger $logger
protected \Psr\Log\LoggerInterface $logger

PSR-3 logger.

Expand Down
2 changes: 1 addition & 1 deletion doc/PAGI-Client-Impl-ClientImpl.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ AGI output

### $logger

protected \PAGI\Client\Logger $logger
protected \Psr\Log\LoggerInterface $logger

PSR-3 logger.

Expand Down
2 changes: 1 addition & 1 deletion doc/PAGI-Client-Impl-MockedClientImpl.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Mocked result strings.

### $logger

protected \PAGI\Client\Logger $logger
protected \Psr\Log\LoggerInterface $logger

PSR-3 logger.

Expand Down
4 changes: 2 additions & 2 deletions doc/PAGI-Node-MockedNode.md
Original file line number Diff line number Diff line change
Expand Up @@ -1500,7 +1500,7 @@ Returns the kind of digit entered by the user, CANCEL, END, NORMAL.

### acceptInput

void PAGI\Node\Node::acceptInput($digit)
void PAGI\Node\Node::acceptInput(\PAGI\Node\@param $digit)

Process a single digit input by the user. Changes the node state
according to the digit entered (CANCEL, COMPLETE).
Expand All @@ -1512,7 +1512,7 @@ according to the digit entered (CANCEL, COMPLETE).


#### Arguments
* $digit **mixed**
* $digit **PAGI\Node\@param** - <p>string $digit A single character, one of the DTMF_* constants.</p>



Expand Down
4 changes: 2 additions & 2 deletions doc/PAGI-Node-Node.md
Original file line number Diff line number Diff line change
Expand Up @@ -1119,7 +1119,7 @@ Returns the kind of digit entered by the user, CANCEL, END, NORMAL.

### acceptInput

void PAGI\Node\Node::acceptInput($digit)
void PAGI\Node\Node::acceptInput(\PAGI\Node\@param $digit)

Process a single digit input by the user. Changes the node state
according to the digit entered (CANCEL, COMPLETE).
Expand All @@ -1130,7 +1130,7 @@ according to the digit entered (CANCEL, COMPLETE).


#### Arguments
* $digit **mixed**
* $digit **PAGI\Node\@param** - <p>string $digit A single character, one of the DTMF_* constants.</p>



Expand Down
4 changes: 1 addition & 3 deletions src/PAGI/Application/PAGILauncher.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,12 @@
* limitations under the License.
*
*/
use PAGI\Application\Exception\InvalidApplicationException;
use PAGI\Application\PAGIApplication;

$appName = getenv('PAGIApplication');
$bootstrap = getenv('PAGIBootstrap');
$myApp = '';
try {

try {
include_once $bootstrap;
if (!class_exists($appName, true)) {
throw new \Exception($appName . ' is not loaded');
Expand Down
14 changes: 14 additions & 0 deletions src/PAGI/ChannelVariables/IChannelVariables.php
Original file line number Diff line number Diff line change
Expand Up @@ -291,4 +291,18 @@ public function getDirectoryKey();
* @return string
*/
public function getDirectoryRun();

/**
* Returns agi_network_script.
*
* @return string
*/
public function getNetworkScript();

/**
* Returns agi_network.
*
* @return string
*/
public function getNetwork();
}
18 changes: 18 additions & 0 deletions src/PAGI/ChannelVariables/Impl/ChannelVariablesFacade.php
Original file line number Diff line number Diff line change
Expand Up @@ -394,4 +394,22 @@ public function __construct(array $variables, array $arguments)
$this->variables = $variables;
$this->arguments = $arguments;
}

/**
* (non-PHPdoc)
* @see PAGI\ChannelVariables.IChannelVariables::getNetworkScript()
*/
public function getNetworkScript()
{
return $this->getAGIVariable('network_script');
}

/**
* (non-PHPdoc)
* @see PAGI\ChannelVariables.IChannelVariables::getNetwork()
*/
public function getNetwork()
{
return $this->getAGIVariable('network');
}
}
5 changes: 2 additions & 3 deletions src/PAGI/Client/AbstractClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ abstract class AbstractClient implements IClient
{
/**
* PSR-3 logger.
* @var Logger
* @var LoggerInterface
*/
protected $logger;

Expand Down Expand Up @@ -573,7 +573,6 @@ public function log($msg, $priority = 'NOTICE')
array($priority, str_replace('"', '\\"', $line))
);
}

}

/**
Expand Down Expand Up @@ -888,7 +887,7 @@ public function createNodeController($name)
/**
* Sets the logger implementation.
*
* @param Psr\Log\LoggerInterface $logger The PSR3-Logger
* @param LoggerInterface $logger The PSR3-Logger
*
* @return void
*/
Expand Down
2 changes: 1 addition & 1 deletion src/PAGI/Client/Impl/MockedClientImpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ private function assertCall($methodName, array $arguments)
$count = count($args);
for ($i = 0; $i < $count; $i++) {
if (!isset($arguments[$i])) {
throw new MockedException("Missing argument number " . $i + 1);
throw new MockedException("Missing argument number " . ($i + 1));
}
$arg = $arguments[$i];
if ($arg !== $args[$i]) {
Expand Down
2 changes: 0 additions & 2 deletions src/PAGI/Node/Node.php
Original file line number Diff line number Diff line change
Expand Up @@ -1184,7 +1184,6 @@ protected function doInput()
*/
protected function beforeOnValidInput()
{

}

/**
Expand All @@ -1194,7 +1193,6 @@ protected function beforeOnValidInput()
*/
protected function beforeOnInputFailed()
{

}

/**
Expand Down
2 changes: 2 additions & 0 deletions test/channelvars/Test_ChannelVariables.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ public function can_get_agi_variables()
$vars->getArguments()
);
$this->assertFalse($vars->getArgument(4));
$this->assertEquals($vars->getNetwork(), 'yes');
$this->assertEquals($vars->getNetworkScript(), 'ScriptName');
$refObject = new \ReflectionObject($vars);
$refMethod = $refObject->getMethod('getAGIVariable');
$refMethod->setAccessible(true);
Expand Down
2 changes: 2 additions & 0 deletions test/client/Test_Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@
'agi_enhanced:0.0',
'agi_accountcode:123',
'agi_threadid:1105672528',
'agi_network:yes',
'agi_network_script:ScriptName',
''
);

Expand Down

0 comments on commit c72d503

Please sign in to comment.