Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Document new Queue behavior

  • Loading branch information...
commit f11ed3ed75c6e700b3c92e9ea9eddf63a6c5361d 1 parent ff6ad93
Kevin Burke authored
View
54 docs/api/rest.rst
@@ -374,11 +374,11 @@ Notification
.. php:attr:: error_code
- A unique error code for the error condition. You can lookup errors, with possible causes and solutions, in our `Error Dictionary <http://www.twilio.com/docs/errors/reference>`.
+ A unique error code for the error condition. You can lookup errors, with possible causes and solutions, in our `Error Dictionary <http://www.twilio.com/docs/errors/reference>`_.
.. php:attr:: more_info
- A URL for more information about the error condition. The URL is a page in our `Error Dictionary <http://www.twilio.com/docs/errors/reference>`.
+ A URL for more information about the error condition. The URL is a page in our `Error Dictionary <http://www.twilio.com/docs/errors/reference>`_.
.. php:attr:: message_text
@@ -778,4 +778,54 @@ Transcription
The URI for this resource, relative to https://api.twilio.com
+Queues
+===========
+
+.. php:class:: Services_Twilio_Rest_Queues
+
+ For more information, including a list of filter parameters, see the
+ `Queues List Resource <http://www.twilio.com/docs/api/rest/queues#list>`_
+ documentation.
+
+ .. php:method:: create($friendly_name, $params = array())
+
+ Create a new :php:class:`Services_Twilio_Rest_Queue`.
+
+ :param string $friendly_name: The name of the new Queue.
+ :param array $params: An array of optional parameters and their values,
+ like ``MaxSize``.
+ :returns: A new :php:class:`Services_Twilio_Rest_Queue`
+
+.. php:class:: Services_Twilio_Rest_Queue
+
+ For more information about available properties of a queue, see the `Queue
+ Instance Resource <http://www.twilio.com/docs/api/rest/queue#instance>`_
+ documentation. A Queue has one subresource, a list of
+ :php:class:`Services_Twilio_Rest_Members`.
+
+
+Members
+===========
+
+.. php:class:: Services_Twilio_Rest_Members
+
+ For more information, including a list of filter parameters, see the `Member List Resource <http://www.twilio.com/docs/api/rest/member#list>`_ documentation.
+
+
+ .. php:method:: front()
+
+ Return the :php:class:`Services_Twilio_Rest_Member` at the front of the
+ queue.
+
+.. php:class:: Services_Twilio_Rest_Member
+
+ For more information about available properties, see the `Member Instance Resource <http://www.twilio.com/docs/api/rest/member#instance>`_ documentation.
+
+ .. php:method:: dequeue($url, $method = 'POST')
+
+ Dequeue this member and immediately play the Twiml at the given ``$url``.
+
+ :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.
+ :returns: :php:class:`Services_Twilio_Rest_Member` The dequeued member
View
46 docs/usage/rest/members.rst
@@ -0,0 +1,46 @@
+=============
+Members
+=============
+
+List All Members in a Queue
+============================
+
+Each queue instance resource has a list of members.
+
+.. code-block:: php
+
+ $client = new Services_Twilio('AC123', '123');
+ $queue_sid = 'QQ123';
+ $queue = $client->account->queues->get('QQ123');
+ foreach ($queue->members as $member) {
+ echo "Call Sid: {$member->call_sid}\nWait Time: {$member->wait_time}\n";
+ }
+
+Dequeue a Member
+=================
+
+.. code-block:: php
+
+ $client = new Services_Twilio('AC123', '123');
+ $queue = $client->account->queues->get('QQ123');
+ foreach ($queue->members as $member) {
+ // Dequeue the first member and fetch the Forward twimlet for that
+ // member.
+ $member->dequeue('http://twimlets.com/forward', 'GET');
+ break;
+ }
+
+Retrieve the Member at the Front of a Queue
+===========================================
+
+The Members class has a method called ``front`` which can be used to retrieve
+the member at the front of the queue.
+
+.. code-block:: php
+
+ $client = new Services_Twilio('AC123', '123');
+ $queue = $client->account->queues->get('QQ123');
+ $firstMember = $queue->members->front();
+ echo $firstMember->position;
+ echo $firstMember->call_sid;
+
View
56 docs/usage/rest/queues.rst
@@ -0,0 +1,56 @@
+=============
+Queues
+=============
+
+Create a New Queue
+=====================
+
+To create a new queue, make an HTTP POST request to the Queues resource.
+
+.. code-block:: php
+
+ require('/path/to/twilio-php/Services/Twilio.php');
+
+ $client = new Services_Twilio('AC123', '123');
+ // Default MaxSize is 100. Or change it by adding a parameter, like so
+ $queue = $client->account->queues->create('First Queue',
+ array('MaxSize' => 10));
+
+ print $queue->sid;
+ print $queue->friendly_name;
+
+Listing Queues
+====================
+
+It's easy to iterate over your list of queues.
+
+.. code-block:: php
+
+ $client = new Services_Twilio('AC123', '123');
+ foreach ($client->account->queues as $queue) {
+ echo $queue->sid;
+ }
+
+Deleting Queues
+====================
+
+.. code-block:: php
+
+ $client = new Services_Twilio('AC123', '123');
+ $queue_sid = 'QQ123';
+ $client->account->queues->delete('QQ123');
+
+Retrieve the Member at the Front of a Queue
+===========================================
+
+The Members class has a method called ``front`` which can be used to retrieve
+the member at the front of the queue.
+
+.. code-block:: php
+
+ $client = new Services_Twilio('AC123', '123');
+ $queue = $client->account->queues->get('QQ123');
+ $firstMember = $queue->members->front();
+ echo $firstMember->position;
+ echo $firstMember->call_sid;
+
Please sign in to comment.
Something went wrong with that request. Please try again.