diff --git a/src/PAMI/Message/Action/BlindTransferAction.php b/src/PAMI/Message/Action/BlindTransferAction.php new file mode 100644 index 000000000..86427bd3a --- /dev/null +++ b/src/PAMI/Message/Action/BlindTransferAction.php @@ -0,0 +1,60 @@ + + * @license http://marcelog.github.com/PAMI/ Apache License 2.0 + * @version SVN: $Id$ + * @link http://marcelog.github.com/PAMI/ + * + * Copyright 2011 Marcelo Gornstein + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +namespace PAMI\Message\Action; + +/** + * BlindTransfer action message. + * + * PHP Version 5 + * + * @category Pami + * @package Message + * @subpackage Action + * @author Marcelo Gornstein + * @license http://marcelog.github.com/PAMI/ Apache License 2.0 + * @link http://marcelog.github.com/PAMI/ + */ +class BlindTransferAction extends ActionMessage +{ + /** + * Constructor. + * + * @param string $channel Transferer's channel. + * @param string $extension Extension to transfer to. + * @param string $context Context to transfer to. + */ + public function __construct($channel, $extension, $context) + { + parent::__construct('BlindTransfer'); + $this->setKey('Channel', $channel); + $this->setKey('Exten', $extension); + $this->setKey('Context', $context); + } +} diff --git a/src/PAMI/Message/Action/ChallengeAction.php b/src/PAMI/Message/Action/ChallengeAction.php index b3d9bbc7f..e80b92b68 100644 --- a/src/PAMI/Message/Action/ChallengeAction.php +++ b/src/PAMI/Message/Action/ChallengeAction.php @@ -1 +1,56 @@ + * @license http://marcelog.github.com/PAMI/ Apache License 2.0 + * @version SVN: $Id$ + * @link http://marcelog.github.com/PAMI/ + * + * Copyright 2011 Marcelo Gornstein + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +namespace PAMI\Message\Action; + +/** + * Challenge action message. + * + * PHP Version 5 + * + * @category Pami + * @package Message + * @subpackage Action + * @author Marcelo Gornstein + * @license http://marcelog.github.com/PAMI/ Apache License 2.0 + * @link http://marcelog.github.com/PAMI/ + */ +class ChallengeAction extends ActionMessage +{ + /** + * Constructor. + * + * @param string $authType Auth type + */ + public function __construct($authType = 'MD5') + { + parent::__construct('Challenge'); + $this->setKey('AuthType', $authType); + } +} diff --git a/src/PAMI/Message/Action/DAHDITransferAction.php b/src/PAMI/Message/Action/DAHDITransferAction.php index b3d9bbc7f..9e0acc406 100644 --- a/src/PAMI/Message/Action/DAHDITransferAction.php +++ b/src/PAMI/Message/Action/DAHDITransferAction.php @@ -1 +1,56 @@ + * @license http://marcelog.github.com/PAMI/ Apache License 2.0 + * @version SVN: $Id$ + * @link http://marcelog.github.com/PAMI/ + * + * Copyright 2011 Marcelo Gornstein + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +namespace PAMI\Message\Action; + +/** + * DAHDITransfer action message. + * + * PHP Version 5 + * + * @category Pami + * @package Message + * @subpackage Action + * @author Marcelo Gornstein + * @license http://marcelog.github.com/PAMI/ Apache License 2.0 + * @link http://marcelog.github.com/PAMI/ + */ +class DAHDITransferAction extends ActionMessage +{ + /** + * Constructor. + * + * @param string $channel DAHDIChannel + */ + public function __construct($channel) + { + parent::__construct('DAHDITransfer'); + $this->setKey('DAHDIChannel', $channel); + } +} diff --git a/src/PAMI/Message/Action/MixMonitorMuteAction.php b/src/PAMI/Message/Action/MixMonitorMuteAction.php new file mode 100644 index 000000000..210f2293b --- /dev/null +++ b/src/PAMI/Message/Action/MixMonitorMuteAction.php @@ -0,0 +1,90 @@ + + * @license http://marcelog.github.com/PAMI/ Apache License 2.0 + * @version SVN: $Id$ + * @link http://marcelog.github.com/PAMI/ + * + * Copyright 2011 Marcelo Gornstein + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +namespace PAMI\Message\Action; + +/** + * MixMonitorMute action message. + * + * PHP Version 5 + * + * @category Pami + * @package Message + * @subpackage Action + * @author Matt Styles + * @license http://marcelog.github.com/PAMI/ Apache License 2.0 + * @link http://marcelog.github.com/PAMI/ + */ +class MixMonitorMuteAction extends ActionMessage +{ + const DIRECTION_READ = 'read'; + const DIRECTION_WRITE = 'write'; + const DIRECTION_BOTH = 'both'; + + /** + * Sets state key. + * + * @param bool $state Mute state + * + * @return void + */ + public function setState($state) + { + $this->setKey('State', $state ? 1 : 0); + } + + /** + * Sets state key. + * + * @param string $direction Which part of the recording to mute: + * read, write or both (from channel, to channel or both channels). + * + * @return void + */ + public function setDirection($direction) + { + $this->setKey('Direction', $direction); + } + + /** + * Constructor. + * + * @param string $channel Channel on which to act. + * @param bool $state Turn mute on or off + * @param string $direction Which part of the recording to mute: + * read, write or both (from channel, to channel or both channels). + */ + public function __construct($channel, $state = true, $direction = 'both') + { + parent::__construct('MixMonitorMute'); + $this->setKey('Channel', $channel); + $this->setState($state); + $this->setDirection($direction); + } +} diff --git a/src/PAMI/Message/Action/SetCDRUserFieldAction.php b/src/PAMI/Message/Action/SetCDRUserFieldAction.php deleted file mode 100644 index b3d9bbc7f..000000000 --- a/src/PAMI/Message/Action/SetCDRUserFieldAction.php +++ /dev/null @@ -1 +0,0 @@ - + * @license http://marcelog.github.com/PAMI/ Apache License 2.0 + * @version SVN: $Id$ + * @link http://marcelog.github.com/PAMI/ + * + * Copyright 2011 Marcelo Gornstein + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +namespace PAMI\Message\Action; + +/** + * UserEvent action message. + * + * PHP Version 5 + * + * @category Pami + * @package Message + * @subpackage Action + * @author Marcelo Gornstein + * @license http://marcelog.github.com/PAMI/ Apache License 2.0 + * @link http://marcelog.github.com/PAMI/ + */ +class UserEventAction extends ActionMessage +{ + /** + * Constructor. + * + * @param string $userEvent UserEvent + * @param array $headers + */ + public function __construct($userEvent, array $headers = []) + { + parent::__construct('UserEvent'); + $this->setKey('UserEvent', $userEvent); + foreach ($headers as $key => $value) { + $this->setKey((string)$key, (string)$value); + } + } +} diff --git a/src/PAMI/Message/Action/WaitEventAction.php b/src/PAMI/Message/Action/WaitEventAction.php index b3d9bbc7f..9d361c86e 100644 --- a/src/PAMI/Message/Action/WaitEventAction.php +++ b/src/PAMI/Message/Action/WaitEventAction.php @@ -1 +1,56 @@ + * @license http://marcelog.github.com/PAMI/ Apache License 2.0 + * @version SVN: $Id$ + * @link http://marcelog.github.com/PAMI/ + * + * Copyright 2011 Marcelo Gornstein + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +namespace PAMI\Message\Action; + +/** + * WaitEvent action message. + * + * PHP Version 5 + * + * @category Pami + * @package Message + * @subpackage Action + * @author Marcelo Gornstein + * @license http://marcelog.github.com/PAMI/ Apache License 2.0 + * @link http://marcelog.github.com/PAMI/ + */ +class WaitEventAction extends ActionMessage +{ + /** + * Constructor. + * + * @param int $timeout Timeout in seconds + */ + public function __construct($timeout) + { + parent::__construct('WaitEvent'); + $this->setKey('Timeout', (int)$timeout); + } +} diff --git a/test/actions/Test_Actions.php b/test/actions/Test_Actions.php index f84966e65..c3f20e1e1 100644 --- a/test/actions/Test_Actions.php +++ b/test/actions/Test_Actions.php @@ -153,6 +153,22 @@ public function can_atxfer() $action = new \PAMI\Message\Action\AttendedTransferAction('channel', 'exten', 'context', 'priority'); $client = $this->_start($write, $action); } + /** + * @test + */ + public function can_blindTransfer() + { + $write = array(implode("\r\n", array( + 'action: BlindTransfer', + 'actionid: 1432.123', + 'channel: channel', + 'exten: exten', + 'context: context', + '' + ))); + $action = new \PAMI\Message\Action\BlindTransferAction('channel', 'exten', 'context'); + $client = $this->_start($write, $action); + } /** * @test */ @@ -169,6 +185,20 @@ public function can_bridge() $action = new \PAMI\Message\Action\BridgeAction('channel1', 'channel2', true); $client = $this->_start($write, $action); } + /** + * @test + */ + public function can_challenge() + { + $write = array(implode("\r\n", array( + 'action: Challenge', + 'actionid: 1432.123', + 'authtype: test', + '' + ))); + $action = new \PAMI\Message\Action\ChallengeAction('test'); + $client = $this->_start($write, $action); + } /** * @test */ @@ -482,6 +512,20 @@ public function can_dahdi_show_channels() $action = new \PAMI\Message\Action\DAHDIShowChannelsAction; $client = $this->_start($write, $action); } + /** + * @test + */ + public function can_dahdi_transfer() + { + $write = array(implode("\r\n", array( + 'action: DAHDITransfer', + 'actionid: 1432.123', + 'dahdichannel: channel', + '' + ))); + $action = new \PAMI\Message\Action\DAHDITransferAction('channel'); + $client = $this->_start($write, $action); + } /** * @test */ @@ -1462,6 +1506,38 @@ public function can_logoff() $client = $this->_start($write, $action); } + /** + * @test + */ + public function can_user_event() + { + $write = array(implode("\r\n", array( + 'action: UserEvent', + 'actionid: 1432.123', + 'userevent: FooEvent', + 'foo: Bar', + 'bar: Foo', + '' + ))); + $action = new \PAMI\Message\Action\UserEventAction('FooEvent', ['Foo' => 'Bar', 'Bar' => 'Foo']); + $client = $this->_start($write, $action); + } + + /** + * @test + */ + public function can_wait_event() + { + $write = array(implode("\r\n", array( + 'action: WaitEvent', + 'actionid: 1432.123', + 'timeout: 20', + '' + ))); + $action = new \PAMI\Message\Action\WaitEventAction(20); + $client = $this->_start($write, $action); + } + /** * @test */