Permalink
Browse files

Adding TwiMLResult after renaming from TwilioResult

  • Loading branch information...
1 parent cf20b2c commit 0542cf4a0ddad56aa5bd2c7123abd5eceb337af2 @jgable committed Apr 25, 2011
Showing with 54 additions and 2 deletions.
  1. +54 −0 TwilioSharp.MVC3/Results/TwiMLResult.cs
  2. +0 −2 TwilioSharp/Request/Requests.cs
View
54 TwilioSharp.MVC3/Results/TwiMLResult.cs
@@ -0,0 +1,54 @@
+using System.Web.Mvc;
+using System.Xml.Linq;
+using System.Xml.Serialization;
+using TwilioSharp.TwiML;
+
+namespace TwilioSharp.MVC3.Results
+{
+ public class TwiMLResult : ActionResult
+ {
+ private XElement _response;
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="TwiMLResult"/> class with a blank TwiML Response.
+ /// </summary>
+ public TwiMLResult()
+ : this(TwiMLBuilder.Build())
+ { }
+
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="TwiMLResult"/> class.
+ /// </summary>
+ /// <param name="builder">The builder that contains the response elements.</param>
+ public TwiMLResult(TwiMLBuilder builder)
+ : this((builder ?? TwiMLBuilder.Build()).ToXmlResponse())
+ { }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="TwiMLResult"/> class.
+ /// </summary>
+ /// <param name="response">The response elements.</param>
+ private TwiMLResult(XElement response)
+ {
+ this._response = response;
+ }
+
+ /// <summary>
+ /// Generates an Empty TwiML Response.
+ /// </summary>
+ /// <returns></returns>
+ public static TwiMLResult Empty()
+ {
+ return new TwiMLResult();
+ }
+
+ public override void ExecuteResult(ControllerContext context)
+ {
+ var xs = new XmlSerializer(_response.GetType());
+ context.HttpContext.Response.ContentType = "text/xml";
+
+ xs.Serialize(context.HttpContext.Response.Output, _response);
+ }
+ }
+}
View
2 TwilioSharp/Request/Requests.cs
@@ -30,8 +30,6 @@ public class TextRequest : RequestBase
public class CallRequest : RequestBase
{
- public string CallStatus { get; set; }
- public string ApiVersion { get; set; }
public string Direction { get; set; }
public string ForwardedFrom { get; set; }
}

0 comments on commit 0542cf4

Please sign in to comment.