Browse files

Finish implementation of Queue

Add support for dequeuing members and creating new Queues. Document an existing
method.
  • Loading branch information...
1 parent 2603ab6 commit 27b6ca77402577e77219b1b8e8960144efa319ee Kevin Burke committed Aug 4, 2012
Showing with 33 additions and 1 deletion.
  1. +1 −1 Services/Twilio.php
  2. +15 −0 Services/Twilio/Rest/Member.php
  3. +5 −0 Services/Twilio/Rest/Members.php
  4. +12 −0 Services/Twilio/Rest/Queues.php
View
2 Services/Twilio.php
@@ -90,7 +90,7 @@ public function retrieveData($path, array $params = array(), $full_uri = false)
{
if (!$full_uri) {
$path = "$path.json";
- }
+ }
$query = $full_uri ? '' : '?';
return empty($params)
? $this->_processResponse($this->http->get($path))
View
15 Services/Twilio/Rest/Member.php
@@ -4,4 +4,19 @@ class Services_Twilio_Rest_Member
extends Services_Twilio_InstanceResource
{
+ /**
+ * Dequeue this member
+ *
+ * @param string $url The Twiml URL to play for this member, after
+ * dequeueing them
+ * @param string $method The HTTP method to use when fetching the Twiml
+ * URL. Defaults to POST.
+ * @return Services_Twilio_Rest_Member The dequeued member
+ */
+ public function dequeue($url, $method = 'POST') {
+ return self::update(array(
+ 'Url' => $url,
+ 'Method' => $method,
+ ));
+ }
}
View
5 Services/Twilio/Rest/Members.php
@@ -3,6 +3,11 @@
class Services_Twilio_Rest_Members
extends Services_Twilio_ListResource
{
+ /**
+ * Return the member at the front of the queue.
+ *
+ * @return Services_Twilio_Rest_Member The member at the front of the queue
+ */
public function front() {
return new $this->instance_name($this->client, $this->uri . "/Front");
}
View
12 Services/Twilio/Rest/Queues.php
@@ -3,5 +3,17 @@
class Services_Twilio_Rest_Queues
extends Services_Twilio_ListResource
{
+ /**
+ * Create a new Queue
+ *
+ * @param string $friendly_name The name of this queue
+ * @param array $params A list of optional parameters, and their values
+ * @return Services_Twilio_Rest_Queue The created Queue
+ */
+ function create($friendly_name, array $params = array()) {
+ return parent::_create(array(
+ 'FriendlyName' => $friendly_name,
+ ) + $params);
+ }
}

0 comments on commit 27b6ca7

Please sign in to comment.