Skip to content

Commit fa09bc4

Browse files
author
Bruno Kovacic
committed
Update example application
1 parent 31ce946 commit fa09bc4

1 file changed

Lines changed: 39 additions & 9 deletions

File tree

example/TelAPI.Example/Program.cs

Lines changed: 39 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Threading;
23

34
namespace TelAPI.Example
45
{
@@ -7,7 +8,9 @@ class Program
78
static void Main(string[] args)
89
{
910
var telApi = new TelAPIRestClient("{your-account-sid}", "{your-auth-token}");
10-
//var telApi = new TelAPIRestClient(new DefaultTelAPIConfiguration());
11+
12+
// another way of creating client with config class
13+
// var telApi = new TelAPIRestClient(new DefaultTelAPIConfiguration());
1114

1215
var account = telApi.GetAccount();
1316
Console.WriteLine("Account Balance : {0}", account.AccountBalance);
@@ -18,7 +21,7 @@ static void Main(string[] args)
1821

1922
try
2023
{
21-
var smsMessage = telApi.GetSmsMessage("fake-sid");
24+
var smsMessage = telApi.GetSmsMessage("just-fake-sid");
2225
Console.WriteLine("SMS : {0}", smsMessage.Status);
2326
}
2427
catch (TelAPIException ex)
@@ -41,7 +44,7 @@ static void Main(string[] args)
4144
Console.WriteLine("SMSMessages GET LIST - Condition");
4245
var messagesWithCondition = telApi.GetSmsMessages(new SmsMessageListOptions
4346
{
44-
To = "+12233312345",
47+
To = "++1234567899",
4548
PageSize = 3
4649
});
4750

@@ -55,7 +58,7 @@ static void Main(string[] args)
5558
Console.WriteLine("-------------------------------------------");
5659

5760
Console.WriteLine("SMSMessages SEND");
58-
var message = telApi.SendSmsMessage("+12233312344", "+12233312345", "hello world!");
61+
var message = telApi.SendSmsMessage("+1234567898", "+1234567899", "hello world from telapi-dotnet lib");
5962
Console.WriteLine(message.Status);
6063

6164
Console.WriteLine("Calls GET");
@@ -74,7 +77,7 @@ static void Main(string[] args)
7477
Console.WriteLine("Calls GET - condition");
7578
var callsCondition = telApi.GetCalls(new CallListOptions
7679
{
77-
To = "+12233312345",
80+
To = "+1234567899",
7881
PageSize = 2
7982
});
8083

@@ -88,17 +91,44 @@ static void Main(string[] args)
8891

8992
Console.WriteLine("-------------------------------------------");
9093

91-
Console.ReadKey();
94+
// wait 5 seconds and do few call actions
95+
Thread.Sleep(5000);
9296

93-
var call = telApi.MakeCall("+12233312344", "+12233312345", "http://www.fake.com/fake-fake");
97+
var call = telApi.MakeCall("+1234567899", "+1234567899", "http://www.xyz.com/fake-fake");
9498
Console.WriteLine("Call : {0} -> {1}", call.Sid, call.Status);
9599

96-
Console.ReadKey();
100+
var digits = telApi.SendDigits(call.Sid, "www12www", null);
101+
Console.WriteLine("Send digits : {0}", digits.DateUpdated);
102+
103+
var audio = telApi.PlayAudio(call.Sid, "http://www.xyz.com/sound.fake.mp3");
104+
Console.WriteLine("Play audio : {0}", audio.DateUpdated);
105+
106+
var effect = telApi.VoiceEffects(call.Sid, new VoiceEffectOptions
107+
{
108+
Pitch = 0,
109+
Rate = 1
110+
});
111+
Console.WriteLine("Voice effect : {0}", effect.DateUpdated);
112+
113+
var record = telApi.RecordCall(call.Sid, true);
114+
Console.WriteLine("Recording call [START] - {0} : {1}", record.Sid, record.Status);
115+
116+
Thread.Sleep(5000);
117+
118+
var stopRecord = telApi.RecordCall(call.Sid, false);
119+
Console.WriteLine("Recording call [STOP] - {0} : {1}", record.Sid, record.Status);
120+
121+
Thread.Sleep(5000);
122+
123+
var interrupt = telApi.InterruptLiveCall(call.Sid, "http://www.xyz.com/call", HttpMethod.Get, HangupCallStatus.Canceled);
124+
Console.WriteLine("Interrupt live call [CANCELED] : {0}", interrupt.Status);
97125

98126
var hangupCall = telApi.HangupCall(call.Sid);
99127
Console.WriteLine("Call {0} ended", hangupCall.Sid);
100128

101-
Console.ReadKey();
129+
Console.ReadKey();
130+
131+
// the end :)
102132
}
103133
}
104134
}

0 commit comments

Comments
 (0)