Permalink
Browse files

Initial Queue support

Initial support for the Queue verb
Adding lots of doc comments
  • Loading branch information...
devinrader committed Aug 7, 2012
1 parent 5606cc0 commit fce4b20c5a6c8ca989c32d8bbc75c25309d6f586
Showing with 1,938 additions and 757 deletions.
  1. +2 −1 Twilio.Mvc.nuspec
  2. +17 −13 Twilio.TwiML.nuspec
  3. +6 −5 Twilio.nuspec
  4. +228 −0 src/Twilio.Api.Silverlight/Queues.Async.cs
  5. +258 −242 src/Twilio.Api.Silverlight/Twilio.Api.Silverlight.csproj
  6. +280 −262 src/Twilio.Api.WindowsPhone/Twilio.Api.WindowsPhone.csproj
  7. +22 −0 src/Twilio.Api/Model/DequeueStatus.cs
  8. +45 −0 src/Twilio.Api/Model/Queue.cs
  9. +30 −0 src/Twilio.Api/Model/QueueMember.cs
  10. +15 −0 src/Twilio.Api/Model/QueueMemberResult.cs
  11. +15 −0 src/Twilio.Api/Model/QueueResult.cs
  12. +219 −0 src/Twilio.Api/Queues.cs
  13. +14 −14 src/Twilio.Api/SharedAssemblyInfo.cs
  14. +9 −0 src/Twilio.Api/Twilio.Api.csproj
  15. +7 −0 src/Twilio.Mvc/SmsRequest.cs
  16. +24 −16 src/Twilio.Mvc/TwilioController.cs
  17. +49 −0 src/Twilio.Mvc/TwilioRequest.cs
  18. +77 −3 src/Twilio.Mvc/VoiceRequest.cs
  19. +79 −77 src/Twilio.Twiml/Twilio.TwiML.csproj
  20. +269 −21 src/Twilio.Twiml/TwilioResponse.cs
  21. +4 −0 src/Twilio.Twiml/Verbs/Client.cs
  22. +13 −2 src/Twilio.Twiml/Verbs/Conference.cs
  23. +11 −1 src/Twilio.Twiml/Verbs/Dial.cs
  24. +96 −70 src/Twilio.Twiml/Verbs/ElementBase.cs
  25. +36 −0 src/Twilio.Twiml/Verbs/Enqueue.cs
  26. +4 −0 src/Twilio.Twiml/Verbs/Gather.cs
  27. +15 −12 src/Twilio.Twiml/Verbs/IDialNoun.cs
  28. +16 −13 src/Twilio.Twiml/Verbs/IVerb.cs
  29. +6 −1 src/Twilio.Twiml/Verbs/Pause.cs
  30. +11 −1 src/Twilio.Twiml/Verbs/Play.cs
  31. +38 −0 src/Twilio.Twiml/Verbs/Queue.cs
  32. +12 −2 src/Twilio.Twiml/Verbs/Say.cs
  33. +11 −1 src/Twilio.Twiml/Verbs/Sms.cs
View
@@ -2,7 +2,7 @@
<package>
<metadata>
<id>Twilio.Mvc</id>
- <version>3.1.8</version>
+ <version>3.1.9</version>
<authors>Twilio</authors>
<description>Twilio helpers for ASP.NET MVC</description>
<language>en-US</language>
@@ -15,6 +15,7 @@
<dependency id="Twilio.TwiML" />
</dependencies>
<releaseNotes>
+ * 3.1.9 - Adding doc comments
* 3.1.8 - Added Dial Status Callback properties
* 3.1.7 - Added properties to the VoiceRequest class to support Transcription
* 3.1.6 - Fixing package fail
View
@@ -1,14 +1,18 @@
-<?xml version="1.0" encoding="utf-8"?>
-<package>
- <metadata>
- <id>Twilio.TwiML</id>
- <version>3.1.3</version>
- <authors>Twilio</authors>
- <description>Twilio TwiML generator. If using ASP.NET MVC, install Twilio.Mvc instead.</description>
- <language>en-US</language>
- <projectUrl>http://github.com/twilio/twilio-csharp</projectUrl>
- <iconUrl>http://www.twilio.com/packages/company/img/logos_downloadable_round.png</iconUrl>
- <licenseUrl>https://github.com/twilio/twilio-csharp/blob/master/LICENSE.txt</licenseUrl>
- <tags>REST SMS voice telephony phone twilio twiml</tags>
- </metadata>
+<?xml version="1.0" encoding="utf-8"?>
+<package>
+ <metadata>
+ <id>Twilio.TwiML</id>
+ <version>3.2.0</version>
+ <authors>Twilio</authors>
+ <description>Twilio TwiML generator. If using ASP.NET MVC, install Twilio.Mvc instead.</description>
+ <language>en-US</language>
+ <projectUrl>http://github.com/twilio/twilio-csharp</projectUrl>
+ <iconUrl>http://www.twilio.com/packages/company/img/logos_downloadable_round.png</iconUrl>
+ <licenseUrl>https://github.com/twilio/twilio-csharp/blob/master/LICENSE.txt</licenseUrl>
+ <tags>REST SMS voice telephony phone twilio twiml</tags>
+ <releaseNotes>
+ * 3.2.0 - Adding Queue Verb
+ Adding document comments
+ </releaseNotes>
+ </metadata>
</package>
View
@@ -2,7 +2,7 @@
<package>
<metadata>
<id>Twilio</id>
- <version>3.4.5</version>
+ <version>3.5.0</version>
<authors>Twilio</authors>
<description>Twilio REST API helper library</description>
<language>en-US</language>
@@ -15,13 +15,14 @@
<dependency id="RestSharp" />
</dependencies>
<releaseNotes>
+ * 3.5.0 - Adding Queue Capability
* 3.4.5 - Fixing package fail
* 3.4.4 - Changed SMS message length validation
* 3.4.3 - Added and updated some XML Doc Comments
- Added SmsStatusCallback property
- Fixed number transfer bug
- Fixed CallListOptions bug
- Updated to latest versions of RestSharp and Json.NET
+ Added SmsStatusCallback property
+ Fixed number transfer bug
+ Fixed CallListOptions bug
+ Updated to latest versions of RestSharp and Json.NET
* 3.4.2 - Updated references to resolve issues with RestSharp and JSON.NET
* 3.4.0 - Add CallOptions.Record to enable full-call recording
* 3.3.7 - Another package-only fix. Assembly version is still 3.3.6
@@ -0,0 +1,228 @@
+using RestSharp;
+using System;
+using RestSharp.Validation;
+namespace Twilio
+{
+ public partial class TwilioRestClient
+ {
+ /// <summary>
+ /// Return a list of all Queue resources
+ /// </summary>
+ /// <param name="callback">Method to call upon successful completion</param>
+ /// <returns></returns>
+ public void ListQueues(Action<QueueResult> callback)
+ {
+ var request = new RestRequest();
+ request.Resource = "Accounts/{AccountSid}/Queues.json";
+
+ ExecuteAsync<QueueResult>(request, (response) => callback(response) );
+ }
+
+ /// <summary>
+ /// Creates a new Queue resource
+ /// </summary>
+ /// <param name="friendlyName">The name of the Queue</param>
+ /// <param name="callback">Method to call upon successful completion</param>
+ /// <returns></returns>
+ public void CreateQueue(string friendlyName, Action<Queue> callback)
+ {
+ var request = new RestRequest(Method.POST);
+ request.Resource = "Accounts/{AccountSid}/Queues.json";
+
+ request.AddParameter("FriendlyName", friendlyName);
+
+ ExecuteAsync<Queue>(request, (response) => callback(response));
+ }
+
+ /// <summary>
+ /// Creates a new Queue resource
+ /// </summary>
+ /// <param name="friendlyName">The name of the Queue</param>
+ /// <param name="maxSize">The maximum number of calls allowed in the queue</param>
+ /// <param name="callback">Method to call upon successful completion</param>
+ /// <returns></returns>
+ public void CreateQueue(string friendlyName, int maxSize, Action<Queue> callback)
+ {
+ var request = new RestRequest(Method.POST);
+ request.Resource = "Accounts/{AccountSid}/Queues.json";
+
+ request.AddParameter("FriendlyName", friendlyName);
+ request.AddParameter("MaxSize", maxSize);
+
+ ExecuteAsync<Queue>(request, (response) => callback(response));
+ }
+
+ /// <summary>
+ /// Locates and returns a specific Queue resource
+ /// </summary>
+ /// <param name="queueSid">The Sid of the Queue to locate</param>
+ /// <param name="callback">Method to call upon successful completion</param>
+ /// <returns></returns>
+ public void GetQueue(string queueSid, Action<Queue> callback)
+ {
+ var request = new RestRequest();
+ request.Resource = "Accounts/{AccountSid}/Queues/{QueueSid}.json";
+
+ request.AddParameter("QueueSid", queueSid, ParameterType.UrlSegment);
+
+ ExecuteAsync<Queue>(request, (response) => callback(response));
+ }
+
+ /// <summary>
+ /// Updates a specific Queue resource
+ /// </summary>
+ /// <param name="queueSid">The Sid of the Queue to update</param>
+ /// <param name="friendlyName">The name of the Queue</param>
+ /// <param name="maxSize">The maximum number of calls allowed in the queue</param>
+ /// <param name="callback">Method to call upon successful completion</param>
+ /// <returns></returns>
+ public void UpdateQueue(string queueSid, string friendlyName, int maxSize, Action<Queue> callback)
+ {
+ Require.Argument("QueueSid", queueSid);
+
+ var request = new RestRequest(Method.POST);
+ request.Resource = "Accounts/{AccountSid}/Queues/{QueueSid}.json";
+
+ request.AddParameter("QueueSid", queueSid, ParameterType.UrlSegment);
+ request.AddParameter("FriendlyName", friendlyName);
+ request.AddParameter("MaxSize", maxSize);
+
+ ExecuteAsync<Queue>(request, (response) => callback(response));
+ }
+
+ /// <summary>
+ /// Deletes a Queue resource
+ /// </summary>
+ /// <param name="queueSid">The Sid of the Queue to delete</param>
+ /// <param name="callback">Method to call upon successful completion</param>
+ /// <returns></returns>
+ public void DeleteQueue(string queueSid, Action<DeleteStatus> callback)
+ {
+ Require.Argument("QueueSid", queueSid);
+ var request = new RestRequest(Method.DELETE);
+ request.Resource = "Accounts/{AccountSid}/Queues/{QueueSid}.json";
+
+ request.AddParameter("QueueSid", queueSid, ParameterType.UrlSegment);
+
+ ExecuteAsync(request, (response) => { callback(response.StatusCode == System.Net.HttpStatusCode.NoContent ? DeleteStatus.Success : DeleteStatus.Failed); });
+ }
+
+ /// <summary>
+ /// Return a List of all Calls currently in the the specified Queue
+ /// </summary>
+ /// <param name="queueSid">The Sid of the Queue to locate</param>
+ /// <param name="callback">Method to call upon successful completion</param>
+ /// <returns></returns>
+ public void ListQueueMembers(string queueSid, Action<QueueMemberResult> callback)
+ {
+ var request = new RestRequest();
+ request.Resource = "Accounts/{AccountSid}/Queues/{QueueSid}/Members.json";
+
+ request.AddParameter("QueueSid", queueSid, ParameterType.UrlSegment);
+
+ ExecuteAsync<QueueMemberResult>(request, (response) => callback(response));
+ }
+
+ /// <summary>
+ /// Returns the Call in the first position of the wait Queue for the specified Queue
+ /// </summary>
+ /// <param name="queueSid">The Sid of the Queue to locate</param>
+ /// <param name="callback">Method to call upon successful completion</param>
+ /// <returns></returns>
+ public void GetFirstQueueMember(string queueSid, Action<QueueMember> callback)
+ {
+ var request = new RestRequest();
+ request.Resource = "Accounts/{AccountSid}/Queues/{QueueSid}/Members/Front.json";
+
+ request.AddParameter("QueueSid", queueSid, ParameterType.UrlSegment);
+
+ ExecuteAsync<QueueMember>(request, (response) => callback(response));
+ }
+
+ /// <summary>
+ /// Locate and return a specific Call in the specified Queue
+ /// </summary>
+ /// <param name="queueSid">The Sid of the Queue to search</param>
+ /// <param name="callSid">The Sid of the Call to locate</param>
+ /// <param name="callback">Method to call upon successful completion</param>
+ /// <returns></returns>
+ public void GetQueueMember(string queueSid, string callSid, Action<QueueMember> callback)
+ {
+ var request = new RestRequest();
+ request.Resource = "Accounts/{AccountSid}/Queues/{QueueSid}/Members/{CallSid}.json";
+
+ request.AddParameter("QueueSid", queueSid, ParameterType.UrlSegment);
+ request.AddParameter("CallSid", callSid, ParameterType.UrlSegment);
+
+ ExecuteAsync<QueueMember>(request, (response) => callback(response));
+ }
+
+ /// <summary>
+ /// Dequeues the Caller in the first wait position for the specified Queue
+ /// </summary>
+ /// <param name="queueSid">The Sid of the Queue to locate</param>
+ /// <param name="url">A Url containing TwiML intructions to execute when the call is dequeued</param>
+ /// <param name="callback">Method to call upon successful completion</param>
+ /// <returns></returns>
+ public void DequeueFirstQueueMember(string queueSid, string url, Action<DequeueStatus> callback)
+ {
+ DequeueFirstQueueMember(queueSid, url, string.Empty, callback);
+ }
+
+ /// <summary>
+ /// Dequeues the Caller in the first wait position for the specified Queue
+ /// </summary>
+ /// <param name="queueSid">The Sid of the Queue to locate</param>
+ /// <param name="url">A Url containing TwiML intructions to execute when the call is dequeued</param>
+ /// <param name="method">The method to use to request the Url</param>
+ /// <param name="callback">Method to call upon successful completion</param>
+ /// <returns></returns>
+ public void DequeueFirstQueueMember(string queueSid, string url, string method, Action<DequeueStatus> callback)
+ {
+ var request = new RestRequest(Method.POST);
+ request.Resource = "Accounts/{AccountSid}/Queues/{QueueSid}/Members/Front.json";
+
+ request.AddParameter("QueueSid", queueSid, ParameterType.UrlSegment);
+ request.AddParameter("Url", url);
+ if (!string.IsNullOrEmpty(method)) { request.AddParameter("Method", method); }
+
+ ExecuteAsync(request, (response) => { callback(response.StatusCode == System.Net.HttpStatusCode.NoContent ? DequeueStatus.Success : DequeueStatus.Failed); });
+ }
+
+ /// <summary>
+ /// Dequeues a specific Caller in the specified Queue
+ /// </summary>
+ /// <param name="queueSid">The Sid of the Queue to locate</param>
+ /// <param name="callSid">The Sid of the Caller to dequeue</param>
+ /// <param name="url">A Url containing TwiML intructions to execute when the call is dequeued</param>
+ /// <param name="callback">Method to call upon successful completion</param>
+ /// <returns></returns>
+ public void DequeueQueueMember(string queueSid, string callSid, string url, Action<DequeueStatus> callback)
+ {
+ DequeueQueueMember(queueSid, callSid, url, string.Empty, callback);
+ }
+
+ /// <summary>
+ /// Dequeues a specific Caller in the specified Queue
+ /// </summary>
+ /// <param name="queueSid">The Sid of the Queue to locate</param>
+ /// <param name="callSid">The Sid of the Caller to dequeue</param>
+ /// <param name="url">A Url containing TwiML intructions to execute when the call is dequeued</param>
+ /// <param name="method">The method to use to request the Url</param>
+ /// <param name="callback">Method to call upon successful completion</param>
+ /// <returns></returns>
+ public void DequeueQueueMember(string queueSid, string callSid, string url, string method, Action<DequeueStatus> callback)
+ {
+ var request = new RestRequest(Method.POST);
+ request.Resource = "Accounts/{AccountSid}/Queues/{QueueSid}/Members/{CallSid}.json";
+
+ request.AddParameter("QueueSid", queueSid, ParameterType.UrlSegment);
+ request.AddParameter("CallSid", callSid, ParameterType.UrlSegment);
+
+ request.AddParameter("Url", url);
+ if (!string.IsNullOrEmpty(method)) { request.AddParameter("Method", method); }
+
+ ExecuteAsync(request, (response) => { callback(response.StatusCode == System.Net.HttpStatusCode.NoContent ? DequeueStatus.Success : DequeueStatus.Failed); });
+ }
+ }
+}
Oops, something went wrong.

0 comments on commit fce4b20

Please sign in to comment.