10000 Extension methods to convert VoiceResponse and MessagingResponse to TwiMLResult by Giorgi · Pull Request #86 · twilio-labs/twilio-aspnet · GitHub
[go: up one dir, main page]

Skip to content

Extension methods to convert VoiceResponse and MessagingResponse to TwiMLResult #86

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions src/Twilio.AspNet.Core/MinimalApiTwiMLResult.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Text;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Twilio.TwiML;

// ReSharper disable once CheckNamespace
namespace Twilio.AspNet.Core.MinimalApi;
Expand Down Expand Up @@ -53,4 +54,20 @@ public Task ExecuteAsync(HttpContext httpContext)
httpContext.Response.ContentLength = Encoding.UTF8.GetByteCount(twiML);
return httpContext.Response.WriteAsync(twiML);
}
}

// ReSharper disable once InconsistentNaming
public static class TwiMLExtensions
{
// ReSharper disable once InconsistentNaming
public static TwiMLResult ToTwiMLResult(this VoiceResponse voiceResponse)
{
return new TwiMLResult(voiceResponse);
}

// ReSharper disable once InconsistentNaming
public static TwiMLResult ToTwiMLResult(this MessagingResponse messagingResponse)
{
return new TwiMLResult(messagingResponse);
}
}
20 changes: 20 additions & 0 deletions src/Twilio.AspNet.Core/TwiMLExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using Twilio.TwiML;

namespace Twilio.AspNet.Core
{
// ReSharper disable once InconsistentNaming
public static class TwiMLExtensions
{
// ReSharper disable once InconsistentNaming
public static TwiMLResult ToTwiMLResult(this VoiceResponse voiceResponse)
{
return new TwiMLResult(voiceResponse);
}

// ReSharper disable once InconsistentNaming
public static TwiMLResult ToTwiMLResult(this MessagingResponse messagingResponse)
{
return new TwiMLResult(messagingResponse);
}
}
}
0