Skip to content

Commit

Permalink
TROPO-12171
Browse files Browse the repository at this point in the history
Add answer to TROPO JSON helper library with support for RPID parameters - WebAPI Csharp
  • Loading branch information
frankmeten committed Aug 23, 2017
1 parent 9aa27e4 commit 93b1069
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 0 deletions.
14 changes: 14 additions & 0 deletions TropoCSharp/Tropo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,20 @@ public void Ask(Ask ask)
Serialize(ask, "ask");
}


/// <summary>
/// answer
/// </summary>
/// <param name="headers">This contains the Session Initiation Protocol (SIP) Headers for the current session.</param>
public void Answer(IDictionary<String, String> headers)
{
Answer answer = new Answer();
answer.Headers = headers;

Serialize(answer, "answer");
}


/// <summary>
/// Places a call or sends an an IM, Twitter, or SMS message. To start a call, use the Session API to tell Tropo to launch your code.
/// </summary>
Expand Down
15 changes: 15 additions & 0 deletions TropoCSharp/TropoClasses.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,21 @@ public Ask(Choices choices, string name, Say say)
}
}


/// <summary>
/// answer verb.
/// </summary>
public class Answer : TropoBase
{
[JsonProperty(PropertyName = "headers")]
public IDictionary<String, String> Headers { get; set; }

public Answer()
{
}
}


/// <summary>
/// Initiates an outbound call or a text conversation. Note that this action is only valid when there is no active WebAPI call.
/// </summary>
Expand Down
2 changes: 2 additions & 0 deletions TropoSample/AnswerTest.aspx
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="AnswerTest.aspx.cs" Inherits="TropoSample.AnswerTest" %>

33 changes: 33 additions & 0 deletions TropoSample/AnswerTest.aspx.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.Web.UI;
using TropoCSharp.Structs;
using TropoCSharp.Tropo;

namespace TropoSample
{
/// <summary>
/// A simple example demonstrating how to use the Ask method.
/// </summary>
public partial class AnswerTest : Page
{
public void Page_Load(object sender, EventArgs args)
{
// Create a new instance of the Tropo object.
Tropo tropo = new Tropo();

Say say1 = new Say("Are you frank on windows. thanks to jerry");

IDictionary<string, string> headers = new Dictionary<String, String>();
headers.Add("P-Header", "value goes here");
headers.Add("Remote-Party-ID", "\"John Doe\"<sip:jdoe@foo.com>;party=calling;id-type=subscriber;privacy=full;screen=yes");

//Answer answer = new Answer();
//answer.Headers = headers;

tropo.Answer(headers);
tropo.Say(say1);
tropo.RenderJSON(Response);
}
}
}
5 changes: 5 additions & 0 deletions TropoSample/TropoSamples.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
<Content Include="StartRecordingTest.aspx" />
<Content Include="TransferOnTest.aspx" />
<Content Include="TransferTest.aspx" />
<Content Include="TropoInboundSMS.aspx" />
<Content Include="TropoReject.aspx" />
<Content Include="WelcomeToBeijing.aspx" />
<Content Include="WelcomeToNewYork.aspx" />
Expand Down Expand Up @@ -125,6 +126,10 @@
<DependentUpon>TransferTest.aspx</DependentUpon>
<SubType>ASPXCodeBehind</SubType>
</Compile>
<Compile Include="TropoInboundSMS.aspx.cs">
<DependentUpon>TropoInboundSMS.aspx</DependentUpon>
<SubType>ASPXCodeBehind</SubType>
</Compile>
<Compile Include="TropoReject.aspx.cs">
<DependentUpon>TropoReject.aspx</DependentUpon>
<SubType>ASPXCodeBehind</SubType>
Expand Down

0 comments on commit 93b1069

Please sign in to comment.