Permalink
Browse files

Added the wait method

  • Loading branch information...
1 parent 8e76a18 commit e14c48d4530dfe2f720c47bc0423479143c9d533 Kevin Bond committed Nov 16, 2012
Showing with 49 additions and 0 deletions.
  1. +49 −0 tropo.class.php
View
49 tropo.class.php
@@ -396,6 +396,23 @@ public function transfer($transfer, Array $params=NULL) {
}
$this->transfer = sprintf('%s', $transfer);
}
+
+ /**
+ * Makes the Tropo sleep an active call in milliseconds
+ *
+ * @param Interger $milliseconds
+ * @param String or Array $allowSignals
+ * @see https://www.tropo.com/docs/webapi/wait.htm
+ */
+ public function wait($wait) {
+ if (!is_object($wait) && is_array($wait)){
+ $params = $wait;
+ $signal = isset($params['allowSignals']) ? $params['allowSignals'] : null;
+ $wait = new Wait($params["milliseconds"], $signal);
+ }
+ $this->wait = sprintf('%s', $wait);
+
+ }
/**
* Launches a new session with the Tropo Session API.
@@ -1702,6 +1719,38 @@ public function __toString() {
}
/**
+* Defines a time period to sleep in milliseconds
+* @package TropoPHP_Support
+*
+*/
+class Wait extends BaseClass {
+
+ private $_milliseconds;
+ private $_allowSignals;
+
+ /**
+ * Class constructor
+ *
+ * @param integer $milliseconds
+ * @param string|array $allowSignals
+ */
+ public function __construct($milliseconds, $allowSignals=NULL) {
+ $this->_milliseconds = $milliseconds;
+ $this->_allowSignals = $allowSignals;
+ }
+
+ /**
+ * Renders object in JSON format.
+ *
+ */
+ public function __toString() {
+ $this->milliseconds = $this->_milliseconds;
+ if(isset($this->_allowSignals)) { $this->allowSignals = $this->_allowSignals; }
+ return $this->unescapeJSON(json_encode($this));
+ }
+}
+
+/**
* Defnies an endoint for transfer and redirects.
* @package TropoPHP_Support
*

0 comments on commit e14c48d

Please sign in to comment.