Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@ public class TestConnect
[Fact]
public void ConnectTest()
{
var expected = "<?xml version=\"1.0\" encoding=\"utf-8\"?><Response> <Connect eventCallbackUrl=\"https://example.com/callback\"> <Endpoint>e-abc123</Endpoint> </Connect></Response>";
var expected = "<?xml version=\"1.0\" encoding=\"utf-8\"?><Response> <Connect eventCallbackUrl=\"https://example.com/callback\" eventFallbackUrl=\"https://fallback.example.com/callback\"> <Endpoint>e-abc123</Endpoint> </Connect></Response>";

var endpoint = new Endpoint();
endpoint.EndpointId = "e-abc123";

var connect = new Connect();
connect.EventCallbackUrl = "https://example.com/callback";
connect.EventFallbackUrl = "https://fallback.example.com/callback";
connect.Destination = endpoint;

var response = new Response(connect);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class TestForward
[Fact]
public void ForwardTest()
{
var expected = "<?xml version=\"1.0\" encoding=\"utf-8\"?><Response> <Forward to=\"+15551234567\" from=\"+15557654321\" callTimeout=\"10\" diversionTreatment=\"propagate\" diversionReason=\"away\" uui=\"93d6f3c0be5845960b744fa28015d8ede84bd1a4;encoding=base64,asdf;encoding=jwt\" /></Response>";
var expected = "<?xml version=\"1.0\" encoding=\"utf-8\"?><Response> <Forward to=\"+15551234567\" from=\"+15557654321\" callTimeout=\"10\" diversionTreatment=\"propagate\" diversionReason=\"away\" uui=\"93d6f3c0be5845960b744fa28015d8ede84bd1a4;encoding=base64,asdf;encoding=jwt\" privacy=\"true\" callerDisplayName=\"Anonymous\" /></Response>";

var forward = new Forward();
forward.To = "+15551234567";
Expand All @@ -19,6 +19,8 @@ public void ForwardTest()
forward.DiversionTreatment = "propagate";
forward.DiversionReason = "away";
forward.Uui = "93d6f3c0be5845960b744fa28015d8ede84bd1a4;encoding=base64,asdf;encoding=jwt";
forward.Privacy = true;
forward.CallerDisplayName = "Anonymous";

var response = new Response(forward);
var actual = response.ToBXML();
Expand Down
10 changes: 9 additions & 1 deletion src/Bandwidth.Standard.Test/Unit/Model/Bxml/TestGather.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class TestGather
[Fact]
public void GatherTest()
{
var expected = "<?xml version=\"1.0\" encoding=\"utf-8\"?><Response> <Gather gatherUrl=\"https://test.url/\" gatherMethod=\"POST\" gatherFallbackUrl=\"https://fallbackTest.url/\" gatherFallbackMethod=\"POST\" username=\"username\" password=\"password\" fallbackUsername=\"fallbackUsername\" fallbackPassword=\"fallbackPassword\" tag=\"test\" terminatingDigits=\"#\" maxDigits=\"50\" interDigitTimeout=\"5\" firstDigitTimeout=\"5\" repeatCount=\"1\"> <SpeakSentence>test</SpeakSentence> <PlayAudio>https://test.url/test.mp3</PlayAudio> </Gather></Response>";
var expected = "<?xml version=\"1.0\" encoding=\"utf-8\"?><Response> <Gather gatherUrl=\"https://test.url/\" gatherMethod=\"POST\" gatherFallbackUrl=\"https://fallbackTest.url/\" gatherFallbackMethod=\"POST\" username=\"username\" password=\"password\" fallbackUsername=\"fallbackUsername\" fallbackPassword=\"fallbackPassword\" tag=\"test\" terminatingDigits=\"#\" maxDigits=\"50\" interDigitTimeout=\"5\" firstDigitTimeout=\"5\" repeatCount=\"1\" input=\"dtmf speech\" hints=\"sales,support\" language=\"en-US\" partialResultCallback=\"https://partialTest.url/\" partialResultCallbackMethod=\"POST\" profanityFilter=\"false\" speechModel=\"default\" speechTimeout=\"10\"> <SpeakSentence>test</SpeakSentence> <PlayAudio>https://test.url/test.mp3</PlayAudio> </Gather></Response>";

var speakSentence = new SpeakSentence();
speakSentence.Text = "test";
Expand All @@ -34,6 +34,14 @@ public void GatherTest()
gather.InterDigitTimeout = 5;
gather.FirstDigitTimeout = 5;
gather.RepeatCount = 1;
gather.Input = "dtmf speech";
gather.Hints = "sales,support";
gather.Language = "en-US";
gather.PartialResultCallback = "https://partialTest.url/";
gather.PartialResultCallbackMethod = "POST";
gather.ProfanityFilter = false;
gather.SpeechModel = "default";
gather.SpeechTimeout = 10;
gather.SpeakSentence = new List<SpeakSentence> { speakSentence };
gather.PlayAudio = new List<PlayAudio> { playAudio };

Expand Down
3 changes: 2 additions & 1 deletion src/Bandwidth.Standard.Test/Unit/Model/Bxml/TestRecord.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class TestRecord
[Fact]
public void RecordTest()
{
var expected = "<?xml version=\"1.0\" encoding=\"utf-8\"?><Response> <Record recordCompleteUrl=\"https://test.url/\" recordCompleteMethod=\"POST\" recordCompleteFallbackUrl=\"https://fallbackTest.url/\" recordCompleteFallbackMethod=\"POST\" recordingAvailableUrl=\"https://recordingTest.url/\" recordingAvailableMethod=\"POST\" transcribe=\"true\" detectLanguage=\"true\" transcriptionAvailableUrl=\"https://transcriptionTest.url/\" transcriptionAvailableMethod=\"POST\" username=\"username\" password=\"password\" fallbackUsername=\"fallbackUsername\" fallbackPassword=\"fallbackPassword\" tag=\"test\" terminatingDigits=\"#\" maxDuration=\"60\" silenceTimeout=\"0\" fileFormat=\"wav\" /></Response>";
var expected = "<?xml version=\"1.0\" encoding=\"utf-8\"?><Response> <Record recordCompleteUrl=\"https://test.url/\" recordCompleteMethod=\"POST\" recordCompleteFallbackUrl=\"https://fallbackTest.url/\" recordCompleteFallbackMethod=\"POST\" recordingAvailableUrl=\"https://recordingTest.url/\" recordingAvailableMethod=\"POST\" transcribe=\"true\" detectLanguage=\"true\" transcriptionAvailableUrl=\"https://transcriptionTest.url/\" transcriptionAvailableMethod=\"POST\" username=\"username\" password=\"password\" fallbackUsername=\"fallbackUsername\" fallbackPassword=\"fallbackPassword\" tag=\"test\" terminatingDigits=\"#\" maxDuration=\"60\" silenceTimeout=\"0\" fileFormat=\"wav\" recordingName=\"test-recording\" /></Response>";

var record = new Bandwidth.Standard.Model.Bxml.Verbs.Record();
record.RecordCompleteUrl = "https://test.url/";
Expand All @@ -31,6 +31,7 @@ public void RecordTest()
record.MaxDuration = 60;
record.SilenceTimeout = 0;
record.FileFormat = "wav";
record.RecordingName = "test-recording";

var response = new Response(record);
var actual = response.ToBXML();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class TestStartRecording
[Fact]
public void StartRecordingTest()
{
var expected = "<?xml version=\"1.0\" encoding=\"utf-8\"?><Response> <StartRecording recordingAvailableUrl=\"https://test.url/\" recordingAvailableMethod=\"POST\" transcribe=\"true\" detectLanguage=\"true\" transcriptionAvailableUrl=\"https://transcriptionTest.url/\" transcriptionAvailableMethod=\"POST\" username=\"username\" password=\"password\" tag=\"test\" fileFormat=\"mp3\" multiChannel=\"true\" /></Response>";
var expected = "<?xml version=\"1.0\" encoding=\"utf-8\"?><Response> <StartRecording recordingAvailableUrl=\"https://test.url/\" recordingAvailableMethod=\"POST\" transcribe=\"true\" detectLanguage=\"true\" transcriptionAvailableUrl=\"https://transcriptionTest.url/\" transcriptionAvailableMethod=\"POST\" username=\"username\" password=\"password\" tag=\"test\" fileFormat=\"mp3\" multiChannel=\"true\" recordingName=\"test-recording\" /></Response>";

var startRecording = new StartRecording();
startRecording.RecordingAvailableUrl = "https://test.url/";
Expand All @@ -24,6 +24,7 @@ public void StartRecordingTest()
startRecording.Tag = "test";
startRecording.FileFormat = "mp3";
startRecording.MultiChannel = true;
startRecording.RecordingName = "test-recording";

var response = new Response(startRecording);
var actual = response.ToBXML();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class TestStartTranscription
[Fact]
public void StartTranscriptionTest()
{
var expected = "<?xml version=\"1.0\" encoding=\"utf-8\"?><Response> <StartTranscription name=\"test\" tracks=\"inbound\" transcriptionEventUrl=\"https://test.url/\" transcriptionEventMethod=\"POST\" username=\"username\" password=\"password\" destination=\"wss://test.url/\" stabilized=\"true\"> <CustomParam name=\"testName\" value=\"testValue\" /> </StartTranscription></Response>";
var expected = "<?xml version=\"1.0\" encoding=\"utf-8\"?><Response> <StartTranscription name=\"test\" tracks=\"inbound\" transcriptionEventUrl=\"https://test.url/\" transcriptionEventMethod=\"POST\" username=\"username\" password=\"password\" destination=\"wss://test.url/\" stabilized=\"true\" detectLanguage=\"false\" preferredLanguages=\"en-US,es-US\"> <CustomParam name=\"testName\" value=\"testValue\" /> </StartTranscription></Response>";

var customParam = new CustomParam();
customParam.Name = "testName";
Expand All @@ -27,6 +27,8 @@ public void StartTranscriptionTest()
startTranscription.Password = "password";
startTranscription.Destination = "wss://test.url/";
startTranscription.Stabilized = true;
startTranscription.DetectLanguage = false;
startTranscription.PreferredLanguages = "en-US,es-US";
startTranscription.CustomParams = new List<CustomParam> { customParam };

var response = new Response(startTranscription);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class TestTransfer
[Fact]
public void TransferTest()
{
var expected = "<?xml version=\"1.0\" encoding=\"utf-8\"?><Response> <Transfer transferCallerId=\"Anonymous\" transferCallerDisplayName=\"test\" callTimeout=\"30\" transferCompleteUrl=\"http://test.com\" transferCompleteMethod=\"POST\" transferCompleteFallbackUrl=\"http://fallbackTest.com\" transferCompleteFallbackMethod=\"POST\" username=\"username\" password=\"password\" fallbackUsername=\"fallbackUsername\" fallbackPassword=\"fallbackPassword\" tag=\"test\" diversionTreatment=\"none\" diversionReason=\"user-busy\"> <PhoneNumber>+15551234567</PhoneNumber> <SipUri uui=\"abc123\">sip:1-999-123-4567@voip-provider.example.net</SipUri> </Transfer></Response>";
var expected = "<?xml version=\"1.0\" encoding=\"utf-8\"?><Response> <Transfer transferCallerId=\"Anonymous\" transferCallerDisplayName=\"test\" callTimeout=\"30\" transferCompleteUrl=\"http://test.com\" transferCompleteMethod=\"POST\" transferCompleteFallbackUrl=\"http://fallbackTest.com\" transferCompleteFallbackMethod=\"POST\" username=\"username\" password=\"password\" fallbackUsername=\"fallbackUsername\" fallbackPassword=\"fallbackPassword\" tag=\"test\" diversionTreatment=\"none\" diversionReason=\"user-busy\" privacy=\"true\"> <PhoneNumber>+15551234567</PhoneNumber> <SipUri uui=\"abc123\">sip:1-999-123-4567@voip-provider.example.net</SipUri> </Transfer></Response>";

var phoneNumber = new PhoneNumber();
phoneNumber.Number = "+15551234567";
Expand All @@ -34,6 +34,7 @@ public void TransferTest()
transfer.Tag = "test";
transfer.DiversionTreatment = "none";
transfer.DiversionReason = "user-busy";
transfer.Privacy = true;
transfer.PhoneNumbers = new PhoneNumber[] { phoneNumber };
transfer.SipUris = new SipUri[] { sipUri };

Expand Down
6 changes: 6 additions & 0 deletions src/Bandwidth.Standard/Model/Bxml/Verbs/Connect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ public class Connect : IVerb
[XmlAttribute("eventCallbackUrl")]
public string EventCallbackUrl { get; set; }

/// <summary>
/// (optional) A fallback url which, if provided, will be used to retry the event callback delivery in case eventCallbackUrl fails to respond.
/// </summary>
[XmlAttribute("eventFallbackUrl")]
public string EventFallbackUrl { get; set; }

/// <summary>
/// The endpoint destination to connect to.
/// </summary>
Expand Down
25 changes: 23 additions & 2 deletions src/Bandwidth.Standard/Model/Bxml/Verbs/Forward.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Bandwidth.Standard.Model.Bxml;
using System;
using System.Xml.Serialization;

namespace Bandwidth.Standard.Model.Bxml.Verbs
Expand Down Expand Up @@ -34,7 +33,7 @@ public Forward()
/// The number of seconds to wait before timing out the call
/// </summary>
[XmlIgnore]
public Nullable<int> CallTimeout { get; set; }
public int? CallTimeout { get; set; }

/// <summary>
/// The setter does nothing! This is just a surrogate field for nullable xml attribute serialization.
Expand Down Expand Up @@ -63,5 +62,27 @@ public string CallTimeoutAsText
/// </summary>
[XmlAttribute("uui")]
public string Uui { get; set; }

/// <summary>
/// (optional) Whether to hide the calling number. Use callerDisplayName to customize the displayed name.
/// </summary>
[XmlIgnore]
public bool? Privacy { get; set; }

/// <summary>
/// The setter does nothing! This is just a surrogate field for nullable xml attribute serialization.
/// </summary>
[XmlAttribute("privacy")]
public string PrivacyAsText
{
get { return (Privacy.HasValue) ? Privacy.ToString().ToLower() : null; }
set { }
}

/// <summary>
/// (optional) The caller display name to use when the call is created, up to 256 characters. If privacy is true, only Restricted, Anonymous, Private, or Unavailable are valid.
/// </summary>
[XmlAttribute("callerDisplayName")]
public string CallerDisplayName { get; set; }
}
}
73 changes: 70 additions & 3 deletions src/Bandwidth.Standard/Model/Bxml/Verbs/Gather.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Bandwidth.Standard.Model.Bxml;
using System;
using System.Collections.Generic;
using System.Xml.Serialization;

Expand Down Expand Up @@ -86,7 +85,7 @@ public Gather()
/// Quantity of digits to collect.
/// </summary>
[XmlIgnore]
public Nullable<int> MaxDigits { get; set; }
public int? MaxDigits { get; set; }

/// <summary>
/// The setter does nothing! This is just a surrogate field for nullable xml attribute serialization.
Expand Down Expand Up @@ -134,7 +133,7 @@ public string FirstDigitTimeoutAsText
/// Integer between 1 and 30 that specifies how many times to play the audio. This parameter will be honored both inside and outside of a Gather verb.
/// </summary>
[XmlIgnore]
public Nullable<int> RepeatCount { get; set; }
public int? RepeatCount { get; set; }

/// <summary>
/// The setter does nothing! This is just a surrogate field for nullable xml attribute serialization.
Expand All @@ -146,6 +145,74 @@ public string RepeatCountAsText
set { }
}

/// <summary>
/// (optional) The input mode - dtmf, speech, or both. Defaults to dtmf.
/// </summary>
[XmlAttribute("input")]
public string Input { get; set; }

/// <summary>
/// (optional) Words or phrases that improve speech recognition. Only used when input includes speech.
/// </summary>
[XmlAttribute("hints")]
public string Hints { get; set; }

/// <summary>
/// (optional) Language code for speech recognition. Only used when input includes speech.
/// </summary>
[XmlAttribute("language")]
public string Language { get; set; }

/// <summary>
/// (optional) Relative or absolute URL to send the Partial Result event to. Only used when input includes speech.
/// </summary>
[XmlAttribute("partialResultCallback")]
public string PartialResultCallback { get; set; }

/// <summary>
/// (optional) The HTTP method to use for the request to partialResultCallback. Defaults to POST.
/// </summary>
[XmlAttribute("partialResultCallbackMethod")]
public string PartialResultCallbackMethod { get; set; }

/// <summary>
/// (optional) Whether profane words are filtered out of the speech recognition result. Defaults to true. Only used when input includes speech.
/// </summary>
[XmlIgnore]
public bool? ProfanityFilter { get; set; }

/// <summary>
/// The setter does nothing! This is just a surrogate field for nullable xml attribute serialization.
/// </summary>
[XmlAttribute("profanityFilter")]
public string ProfanityFilterAsText
{
get { return (ProfanityFilter.HasValue) ? ProfanityFilter.ToString().ToLower() : null; }
set { }
}

/// <summary>
/// (optional) The speech recognition model to use. Only used when input includes speech.
/// </summary>
[XmlAttribute("speechModel")]
public string SpeechModel { get; set; }

/// <summary>
/// (optional) Seconds to wait for speech input before timing out. Defaults to 5.
/// </summary>
[XmlIgnore]
public int? SpeechTimeout { get; set; }

/// <summary>
/// The setter does nothing! This is just a surrogate field for nullable xml attribute serialization.
/// </summary>
[XmlAttribute("speechTimeout")]
public string SpeechTimeoutAsText
{
get { return (SpeechTimeout.HasValue) ? SpeechTimeout.ToString() : null; }
set { }
}

/// <summary>
/// Using the SpeakSentence inside the Gather verb will speak the text to the callee.
/// </summary>
Expand Down
11 changes: 8 additions & 3 deletions src/Bandwidth.Standard/Model/Bxml/Verbs/Record.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Bandwidth.Standard.Model.Bxml;
using System;
using System.Xml.Serialization;

namespace Bandwidth.Standard.Model.Bxml.Verbs
Expand Down Expand Up @@ -111,7 +110,7 @@ public class Record : IVerb
/// (optional) Maximum length of recording (in seconds).
/// </summary>
[XmlIgnore]
public Nullable<int> MaxDuration { get; set; }
public int? MaxDuration { get; set; }

/// <summary>
/// The setter does nothing! This is just a surrogate field for nullable xml attribute serialization.
Expand All @@ -127,7 +126,7 @@ public string MaxDurationAsText
/// (optional) Length of silence after which to end the recording (in seconds). Max is equivalent to the maximum maxDuration value.
/// </summary>
[XmlIgnore]
public Nullable<int> SilenceTimeout { get; set; }
public int? SilenceTimeout { get; set; }

/// <summary>
/// The setter does nothing! This is just a surrogate field for nullable xml attribute serialization.
Expand All @@ -144,5 +143,11 @@ public string SilenceTimeoutAsText
/// </summary>
[XmlAttribute("fileFormat")]
public string FileFormat { get; set; }

/// <summary>
/// (optional) A name identifying this recording, returned in the Recording Available event.
/// </summary>
[XmlAttribute("recordingName")]
public string RecordingName { get; set; }
}
}
6 changes: 6 additions & 0 deletions src/Bandwidth.Standard/Model/Bxml/Verbs/StartRecording.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,5 +75,11 @@ public class StartRecording : IVerb
/// </summary>
[XmlAttribute("multiChannel")]
public bool MultiChannel { get; set; }

/// <summary>
/// (optional) A name identifying this recording, returned in the Recording Available event.
/// </summary>
[XmlAttribute("recordingName")]
public string RecordingName { get; set; }
}
}
22 changes: 22 additions & 0 deletions src/Bandwidth.Standard/Model/Bxml/Verbs/StartTranscription.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,28 @@ public StartTranscription()
[XmlAttribute("stabilized")]
public bool Stabilized { get; set; }

/// <summary>
/// (optional) Whether to detect the dominant language of the call rather than assuming English. Defaults to false.
/// </summary>
[XmlIgnore]
public bool? DetectLanguage { get; set; }

/// <summary>
/// The setter does nothing! This is just a surrogate field for nullable xml attribute serialization.
/// </summary>
[XmlAttribute("detectLanguage")]
public string DetectLanguageAsText
{
get { return (DetectLanguage.HasValue) ? DetectLanguage.ToString().ToLower() : null; }
set { }
}

/// <summary>
/// (optional) Comma-separated list of language locales to transcribe in, defaulting to en-US. Requires detectLanguage to be false, and supports one dialect per language.
/// </summary>
[XmlAttribute("preferredLanguages")]
public string PreferredLanguages { get; set; }


/// <summary>
/// You may specify up to 12 CustomParam elements nested within a StartTranscription tag.
Expand Down
Loading
Loading