Permalink
Browse files

Resolve merge conflict

  • Loading branch information...
2 parents c8d58f0 + 10c50fc commit 41e2e97267b1d15df8da3e2f5fecdcbdf907545f Kevin Burke committed Aug 6, 2012
View
@@ -1,6 +1,14 @@
twilio-php Changelog
====================
+Version 3.6.0
+-------------
+
+Released on August 5, 2012
+
+- Add support for Queues and Members. Includes tests and documentation for the
+ new functionality.
+
Version 3.5.2
-------------
View
@@ -22,7 +22,7 @@ function Services_Twilio_autoload($className) {
*/
class Services_Twilio extends Services_Twilio_Resource
{
- const USER_AGENT = 'twilio-php/3.5.2';
+ const USER_AGENT = 'twilio-php/3.6.0';
protected $http;
protected $retryAttempts;
@@ -18,11 +18,12 @@ protected function init($client, $uri)
'sms_messages',
'transcriptions',
'connect_apps',
- 'authorized_connect_apps'
+ 'authorized_connect_apps',
+ 'queues'
);
$this->sandbox = new Services_Twilio_Rest_Sandbox(
- $client, $uri . "/Sandbox"
+ $client, $uri . '/Sandbox'
);
}
}
@@ -0,0 +1,22 @@
+<?php
+
+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,
+ ));
+ }
+}
@@ -0,0 +1,22 @@
+<?php
+
+class Services_Twilio_Rest_Members
+ extends Services_Twilio_ListResource
+{
+ /**
+ * Return the member at the front of the queue. Note that any operations
+ * performed on the Member returned from this function will use the /Front
+ * Uri, not the Member's CallSid.
+ *
+ * @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');
+ }
+
+ /* Participants are identified by CallSid, not like ME123 */
+ public function getObjectFromJson($params, $idParam = 'sid') {
+ return parent::getObjectFromJson($params, 'call_sid');
+ }
+}
+
@@ -0,0 +1,10 @@
+<?php
+
+class Services_Twilio_Rest_Queue
+ extends Services_Twilio_InstanceResource {
+
+ protected function init($client, $uri) {
+ $this->setupSubresources('members');
+ }
+}
+
@@ -0,0 +1,19 @@
+<?php
+
+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);
+ }
+}
+
View
@@ -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
@@ -49,9 +49,9 @@
# built documents.
#
# The short X.Y version.
-version = '3.5'
+version = '3.6'
# The full version, including alpha/beta/rc tags.
-release = '3.5.2'
+release = '3.6.0'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
View
@@ -10,7 +10,7 @@
Status
=======
-This documentation is for version 3.5.2 of `twilio-php <https://www.github.com/twilio/twilio-php>`_.
+This documentation is for version 3.6.0 of `twilio-php <https://www.github.com/twilio/twilio-php>`_.
Quickstart
============
@@ -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
@@ -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;
+
View
@@ -35,12 +35,12 @@
require_once 'PEAR/PackageFileManager2.php';
PEAR::setErrorHandling(PEAR_ERROR_DIE);
-$api_version = '3.5.2';
+$api_version = '3.6.0';
$api_state = 'stable';
-$release_version = '3.5.2';
+$release_version = '3.6.0';
$release_state = 'stable';
-$release_notes = 'Hotfix for two errors introduced the 3.5.0 release';
+$release_notes = 'Add support for Queues and Members';
$description = <<<DESC
A SDK (or helper library, as we're calling them) for PHP developers to write
Oops, something went wrong.

0 comments on commit 41e2e97

Please sign in to comment.