Skip to content
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

Update timeout elements in Dial. #24

Merged
merged 2 commits into from Feb 14, 2020
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 7 additions & 7 deletions Apidaze.SDK.Tests.Unit/ScriptBuilder/ApidazeScriptTest.cs
Expand Up @@ -73,7 +73,7 @@ public void ToXml_Ringback_ReturnsEqualToFile()
var expectedOutput = GetFileContents("ringback.xml");
_ApidazeScript.AddNode(new Answer())
.AddNode(Ringback.FromFile("http://www.mydomain.com/welcome.wav"))
.AddNode(new Dial { Sipaccount = "bob" })
.AddNode(new Dial { Sipaccount = new List<SipAccount>() { new SipAccount("bob") } })
.AddNode(new Hangup());
const bool noFormatting = true;

Expand Down Expand Up @@ -315,7 +315,7 @@ public void ToXmlWithNoFormatting_DialNumber_ReturnsEqualToFile()
{
// Arrange
var expectedOutput = GetFileContents("dial-number.xml").RemoveWhiteSpaces();
var dial = new Dial() { Number = new List<Number>() };
var dial = new Dial() { Number = new List<Number>() { new Number("1234567890") } };
_ApidazeScript.AddNode(dial).AddNode(new Hangup());
const bool noFormatting = false;

Expand All @@ -334,7 +334,7 @@ public void ToXmlWithNoFormatting_DialSipAccount_ReturnsEqualToFile()
{
// Arrange
var expectedOutput = GetFileContents("dial-sipaccount.xml").RemoveWhiteSpaces();
var dial = new Dial() { Sipaccount = "targetsipaccount" };
var dial = new Dial() { Sipaccount = new List<SipAccount>() { new SipAccount("targetsipaccount") } };
_ApidazeScript.AddNode(dial).AddNode(new Hangup());
const bool noFormatting = false;

Expand All @@ -353,7 +353,7 @@ public void ToXmlWithNoFormatting_DialSipUri_ReturnsEqualToFile()
{
// Arrange
var expectedOutput = GetFileContents("dial-sipuri.xml").RemoveWhiteSpaces();
var dial = new Dial() { SipUri = "phone_number@anysipdomain.com" };
var dial = new Dial() { SipUri = new List<SipUri>() { new SipUri("phone_number@anysipdomain.com") } };
_ApidazeScript.AddNode(dial).AddNode(new Hangup());
const bool noFormatting = false;

Expand All @@ -374,15 +374,15 @@ public void ToXmlWithNoFormatting_DialWithAllAttributesAndDestinationTypes_Retur
var expectedOutput = GetFileContents("dial-all-in-one.xml").RemoveWhiteSpaces();
var dial = new Dial()
{
SipUri = "phone_number@anysipdomain.com",
SipUri = new List<SipUri>() { new SipUri("phone_number@anysipdomain.com") },
Timeout = 60,
MaxCallDuration = 300,
Strategy = StrategyEnum.SEQUENCE,
Action = "http://action.url.com",
AnswerUrl = "http://answer-url.com",
CallerHangupUrl = "http://caller-hangup-url.com",
Number = new List<Number>(),
Sipaccount = "targetsipaccount"
Number = new List<Number>() { new Number("1234567890") },
Sipaccount = new List<SipAccount>() { new SipAccount("targetsipaccount") },
};
_ApidazeScript.AddNode(dial).AddNode(new Hangup());
const bool noFormatting = true;
Expand Down
47 changes: 22 additions & 25 deletions Apidaze.SDK/ScriptBuilder/POCO/Dial.cs
Expand Up @@ -9,19 +9,26 @@ namespace Apidaze.SDK.ScriptBuilder.POCO
/// </summary>
public class Dial
{

/// <summary>
/// Gets or sets the number.
/// </summary>
/// <value>The number.</value>
[XmlElement("number")] public List<Number> Number { get; set; }


/// <summary>
/// Gets or sets the sipaccount.
/// </summary>
/// <value>The sipaccount.</value>
[XmlElement("sipaccount")] public string Sipaccount { get; set; }
[XmlElement("sipaccount")] public List<SipAccount> Sipaccount { get; set; }


/// <summary>
/// Gets or sets the sip URI.
/// </summary>
/// <value>The sip URI.</value>
[XmlElement("sipuri")] public string SipUri { get; set; }
[XmlElement("sipuri")] public List<SipUri> SipUri { get; set; }

/// <summary>
/// Gets or sets the timeout.
Expand All @@ -34,6 +41,7 @@ public class Dial
/// </summary>
/// <value>The maximum duration of the call.</value>
[XmlAttribute("max-call-duration")] public double MaxCallDuration { get; set; }

/// <summary>
/// Gets or sets the strategy.
/// </summary>
Expand All @@ -59,47 +67,36 @@ public class Dial
[XmlAttribute("caller-hangup-url")] public string CallerHangupUrl { get; set; }

/// <summary>
/// Shoulds the serialize timeout.
/// Serialize a Timeout conditionally.
/// The result of the method determines whether the property is serialized. If the method returns true then the property will be serialized,
/// if it returns false then the property will be skipped.
/// </summary>
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
/// <returns><c>true</c> if value greater than 0, <c>false</c> otherwise.</returns>
public bool ShouldSerializeTimeout()
{
return Math.Abs(Timeout) > 0;
}

/// <summary>
/// Shoulds the duration of the serialize maximum call.
/// Serialize a MaxCallDuration conditionally.
/// The result of the method determines whether the property is serialized. If the method returns true then the property will be serialized,
/// if it returns false then the property will be skipped.
/// </summary>
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
/// <returns><c>true</c> if value greater than 0, <c>false</c> otherwise.</returns>
public bool ShouldSerializeMaxCallDuration()
{
return Math.Abs(MaxCallDuration) > 0;
}

/// <summary>
/// Shoulds the serialize strategy.
/// Serialize a Strategy conditionally.
/// The result of the method determines whether the property is serialized. If the method returns true then the property will be serialized,
/// if it returns false then the property will be skipped.
/// </summary>
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
/// <returns><c>true</c> if value not equal default, <c>false</c> otherwise.</returns>
public bool ShouldSerializeStrategy()
{
return Strategy != default;
}
}

public class Number
{
[XmlAttribute("timeout")] public string Timeout { get; set; }

[XmlText(typeof(string))] public string Value { get; set; }

public Number()
{
}

public Number(string timeout, string value)
{
Timeout = timeout;
Value = value;
}
}
}
33 changes: 33 additions & 0 deletions Apidaze.SDK/ScriptBuilder/POCO/Number.cs
@@ -0,0 +1,33 @@
using System;
using System.Xml.Serialization;

namespace Apidaze.SDK.ScriptBuilder.POCO
{
public class Number
{
[XmlAttribute("timeout")] public double Timeout { get; set; }

[XmlText(typeof(string))] public string Value { get; set; }

public Number()
{
}

public Number(string value, double timeout = default)
{
Timeout = timeout;
Value = value;
}

/// <summary>
/// Serialize a Timeout conditionally.
/// The result of the method determines whether the property is serialized. If the method returns true then the property will be serialized,
/// if it returns false then the property will be skipped.
/// </summary>
/// <returns><c>true</c> if value greater than 0, <c>false</c> otherwise.</returns>
public bool ShouldSerializeTimeout()
{
return Math.Abs(Timeout) > 0;
}
}
}
6 changes: 4 additions & 2 deletions Apidaze.SDK/ScriptBuilder/POCO/Playback.cs
Expand Up @@ -37,9 +37,11 @@ public static Playback FromFile(string file)
}

/// <summary>
/// Shoulds the serialize input timeout millis.
/// Serialize a InputTimeoutMillis conditionally.
/// The result of the method determines whether the property is serialized. If the method returns true then the property will be serialized,
/// if it returns false then the property will be skipped.
/// </summary>
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
/// <returns><c>true</c> if value greater than 0, <c>false</c> otherwise.</returns>
public bool ShouldSerializeInputTimeoutMillis()
{
return Math.Abs(InputTimeoutMillis) > 0;
Expand Down
18 changes: 12 additions & 6 deletions Apidaze.SDK/ScriptBuilder/POCO/Record.cs
Expand Up @@ -33,27 +33,33 @@ public class Record
[XmlAttribute("bleg")] public bool BLeg { get; set; } = true;

/// <summary>
/// Shoulds the serialize on answered.
/// Serialize a OnAnswered conditionally.
/// The result of the method determines whether the property is serialized. If the method returns true then the property will be serialized,
/// if it returns false then the property will be skipped.
/// </summary>
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
/// <returns><c>true</c> if value true <c>false</c> otherwise.</returns>
public bool ShouldSerializeOnAnswered()
{
return OnAnswered;
}

/// <summary>
/// Shoulds the serialize a leg.
/// Serialize a ALeg conditionally.
/// The result of the method determines whether the property is serialized. If the method returns true then the property will be serialized,
/// if it returns false then the property will be skipped.
/// </summary>
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
/// <returns><c>true</c> if value not true <c>false</c> otherwise.</returns>
public bool ShouldSerializeALeg()
{
return !ALeg;
}

/// <summary>
/// Shoulds the serialize b leg.
/// Serialize a BLeg conditionally.
/// The result of the method determines whether the property is serialized. If the method returns true then the property will be serialized,
/// if it returns false then the property will be skipped.
/// </summary>
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
/// <returns><c>true</c> if value not true <c>false</c> otherwise.</returns>
public bool ShouldSerializeBLeg()
{
return !BLeg;
Expand Down
33 changes: 33 additions & 0 deletions Apidaze.SDK/ScriptBuilder/POCO/SipAccount.cs
@@ -0,0 +1,33 @@
using System;
using System.Xml.Serialization;

namespace Apidaze.SDK.ScriptBuilder.POCO
{
public class SipAccount
{
[XmlAttribute("timeout")] public double Timeout { get; set; }

[XmlText(typeof(string))] public string Value { get; set; }

public SipAccount()
{
}

public SipAccount(string value, double timeout = default)
{
Timeout = timeout;
Value = value;
}

/// <summary>
/// Serialize a Timeout conditionally.
/// The result of the method determines whether the property is serialized. If the method returns true then the property will be serialized,
/// if it returns false then the property will be skipped.
/// </summary>
/// <returns><c>true</c> if value greater than 0, <c>false</c> otherwise.</returns>
public bool ShouldSerializeTimeout()
{
return Math.Abs(Timeout) > 0;
}
}
}
33 changes: 33 additions & 0 deletions Apidaze.SDK/ScriptBuilder/POCO/SipUri.cs
@@ -0,0 +1,33 @@
using System;
using System.Xml.Serialization;

namespace Apidaze.SDK.ScriptBuilder.POCO
{
public class SipUri
{
[XmlAttribute("timeout")] public double Timeout { get; set; }

[XmlText(typeof(string))] public string Value { get; set; }

public SipUri()
{
}

public SipUri(string value, double timeout = default)
{
Timeout = timeout;
Value = value;
}

/// <summary>
/// Serialize a Timeout conditionally.
/// The result of the method determines whether the property is serialized. If the method returns true then the property will be serialized,
/// if it returns false then the property will be skipped.
/// </summary>
/// <returns><c>true</c> if value greater than 0, <c>false</c> otherwise.</returns>
public bool ShouldSerializeTimeout()
{
return Math.Abs(Timeout) > 0;
}
}
}
24 changes: 20 additions & 4 deletions Apidaze.SDK/ScriptBuilder/POCO/Speak.cs
Expand Up @@ -48,28 +48,44 @@ public Speak()
}

/// <summary>
/// Shoulds the serialize input timeout millis.
/// Serialize a InputTimeoutMillis conditionally.
/// The result of the method determines whether the property is serialized. If the method returns true then the property will be serialized,
/// if it returns false then the property will be skipped.
/// </summary>
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
/// <returns><c>true</c> if value greater than 0, <c>false</c> otherwise.</returns>
public bool ShouldSerializeInputTimeoutMillis()
{
return Math.Abs(InputTimeoutMillis) > 0;
}

/// <summary>
/// Serialize a DigitTimeoutMillis conditionally.
/// The result of the method determines whether the property is serialized. If the method returns true then the property will be serialized,
/// if it returns false then the property will be skipped.
/// </summary>
/// <returns><c>true</c> if value greater than 0, <c>false</c> otherwise.</returns>
public bool ShouldSerializeDigitTimeoutMillis()
{
return Math.Abs(DigitTimeoutMillis) > 0;
}

/// <summary>
/// Serialize a LangEnum conditionally.
/// The result of the method determines whether the property is serialized. If the method returns true then the property will be serialized,
/// if it returns false then the property will be skipped.
/// </summary>
/// <returns><c>true</c> if value not equal default <c>false</c> otherwise.</returns>
public bool ShouldSerializeLangEnum()
{
return LangEnum != default;
}

/// <summary>
/// Shoulds the serialize voice.
/// Serialize a Voice conditionally.
/// The result of the method determines whether the property is serialized. If the method returns true then the property will be serialized,
/// if it returns false then the property will be skipped.
/// </summary>
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
/// <returns><c>true</c> if value not equal default <c>false</c> otherwise.</returns>
public bool ShouldSerializeVoice()
{
return Voice != default;
Expand Down