Skip to content

Commit 93b1069

Browse files
committed
TROPO-12171
Add answer to TROPO JSON helper library with support for RPID parameters - WebAPI Csharp
1 parent 9aa27e4 commit 93b1069

5 files changed

Lines changed: 69 additions & 0 deletions

File tree

TropoCSharp/Tropo.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,20 @@ public void Ask(Ask ask)
257257
Serialize(ask, "ask");
258258
}
259259

260+
261+
/// <summary>
262+
/// answer
263+
/// </summary>
264+
/// <param name="headers">This contains the Session Initiation Protocol (SIP) Headers for the current session.</param>
265+
public void Answer(IDictionary<String, String> headers)
266+
{
267+
Answer answer = new Answer();
268+
answer.Headers = headers;
269+
270+
Serialize(answer, "answer");
271+
}
272+
273+
260274
/// <summary>
261275
/// 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.
262276
/// </summary>

TropoCSharp/TropoClasses.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,21 @@ public Ask(Choices choices, string name, Say say)
8888
}
8989
}
9090

91+
92+
/// <summary>
93+
/// answer verb.
94+
/// </summary>
95+
public class Answer : TropoBase
96+
{
97+
[JsonProperty(PropertyName = "headers")]
98+
public IDictionary<String, String> Headers { get; set; }
99+
100+
public Answer()
101+
{
102+
}
103+
}
104+
105+
91106
/// <summary>
92107
/// Initiates an outbound call or a text conversation. Note that this action is only valid when there is no active WebAPI call.
93108
/// </summary>

TropoSample/AnswerTest.aspx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="AnswerTest.aspx.cs" Inherits="TropoSample.AnswerTest" %>
2+

TropoSample/AnswerTest.aspx.cs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Web.UI;
4+
using TropoCSharp.Structs;
5+
using TropoCSharp.Tropo;
6+
7+
namespace TropoSample
8+
{
9+
/// <summary>
10+
/// A simple example demonstrating how to use the Ask method.
11+
/// </summary>
12+
public partial class AnswerTest : Page
13+
{
14+
public void Page_Load(object sender, EventArgs args)
15+
{
16+
// Create a new instance of the Tropo object.
17+
Tropo tropo = new Tropo();
18+
19+
Say say1 = new Say("Are you frank on windows. thanks to jerry");
20+
21+
IDictionary<string, string> headers = new Dictionary<String, String>();
22+
headers.Add("P-Header", "value goes here");
23+
headers.Add("Remote-Party-ID", "\"John Doe\"<sip:jdoe@foo.com>;party=calling;id-type=subscriber;privacy=full;screen=yes");
24+
25+
//Answer answer = new Answer();
26+
//answer.Headers = headers;
27+
28+
tropo.Answer(headers);
29+
tropo.Say(say1);
30+
tropo.RenderJSON(Response);
31+
}
32+
}
33+
}

TropoSample/TropoSamples.csproj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474
<Content Include="StartRecordingTest.aspx" />
7575
<Content Include="TransferOnTest.aspx" />
7676
<Content Include="TransferTest.aspx" />
77+
<Content Include="TropoInboundSMS.aspx" />
7778
<Content Include="TropoReject.aspx" />
7879
<Content Include="WelcomeToBeijing.aspx" />
7980
<Content Include="WelcomeToNewYork.aspx" />
@@ -125,6 +126,10 @@
125126
<DependentUpon>TransferTest.aspx</DependentUpon>
126127
<SubType>ASPXCodeBehind</SubType>
127128
</Compile>
129+
<Compile Include="TropoInboundSMS.aspx.cs">
130+
<DependentUpon>TropoInboundSMS.aspx</DependentUpon>
131+
<SubType>ASPXCodeBehind</SubType>
132+
</Compile>
128133
<Compile Include="TropoReject.aspx.cs">
129134
<DependentUpon>TropoReject.aspx</DependentUpon>
130135
<SubType>ASPXCodeBehind</SubType>

0 commit comments

Comments
 (0)