Skip to content
Open
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
31 changes: 31 additions & 0 deletions src/Bandwidth.Standard.Test/Unit/Model/Bxml/TestRefer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using System;
using System.IO;
using System.Xml.Serialization;
using Bandwidth.Standard.Model.Bxml;
using Bandwidth.Standard.Model.Bxml.Verbs;
using Xunit;

namespace Bandwidth.Standard.Test.Unit.Model.Bxml
{
public class TestRefer
{
[Fact]
public void ReferTest()
{
var expected = "<?xml version=\"1.0\" encoding=\"utf-8\"?><Response> <Refer referCompleteUrl=\"https://example.com/handleRefer\" referCompleteMethod=\"POST\" tag=\"refer-tag\"> <SipUri>sip:alice@atlanta.example.com</SipUri> </Refer></Response>";

var sipUri = new SipUri { Uri = "sip:alice@atlanta.example.com" };

var refer = new Refer
{
SipUri = sipUri,
ReferCompleteUrl = "https://example.com/handleRefer",
ReferCompleteMethod = "POST",
Tag = "refer-tag"
};

var actual = new Response(refer).ToBXML();
Assert.Equal(expected, actual.Replace("\n", "").Replace("\r", ""));
}
}
}
47 changes: 47 additions & 0 deletions src/Bandwidth.Standard/Model/Bxml/Verbs/Refer.cs

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This model got a bit over-engineered. I'm gonna make some changes on the branch to make it more closely align to our other verbs, but for reference:

  • we typically leave validation out of BXML models for simplicity, and if validation is needed it can be done on the PV side
  • no other verbs only have the WithFieldName methods, these are unnecessary for constructing the verb and add bloat to the model

Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
using Bandwidth.Standard.Model.Bxml;
using System;
using System.Collections.Generic;
using System.Xml.Serialization;

namespace Bandwidth.Standard.Model.Bxml.Verbs
{
/// <summary>
/// The Refer verb is used to hand off a call to a SIP endpoint.
/// <para><seealso href="https://dev.bandwidth.com/docs/voice/bxml/refer"/></para>
/// </summary>
public class Refer : IVerb
{

/// <summary>
/// Initializes a new instance of the Refer class with defaults.
/// </summary>
public Refer()
{
ReferCompleteMethod = "POST";
}

/// <summary>
/// URL to receive the refer complete callback.
/// </summary>
[XmlAttribute("referCompleteUrl")]
public string ReferCompleteUrl { get; set; }

/// <summary>
/// HTTP method to send the refer complete callback. GET or POST. Default value is POST.
/// </summary>
[XmlAttribute("referCompleteMethod")]
public string ReferCompleteMethod { get; set; }

/// <summary>
/// Optional custom string to include in callbacks.
/// </summary>
[XmlAttribute("tag")]
public string Tag { get; set; }

/// <summary>
/// A SIP URI specifying the refer destination
/// </summary>
[XmlElement("SipUri")]
public SipUri SipUri { get; set; }
}
}
5 changes: 2 additions & 3 deletions src/Bandwidth.Standard/Model/Bxml/Verbs/SipUri.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
namespace Bandwidth.Standard.Model.Bxml.Verbs
{
/// <summary>
/// BXML tag to represent a SIP URI for the transfer verb.
/// <para><seealso href="https://dev.bandwidth.com/docs/voice/bxml/transfer.html"/></para>
/// BXML tag to represent a SIP URI for the transfer or refer verb.
/// </summary>
public class SipUri : IVerb
{
Expand All @@ -16,7 +15,7 @@ public class SipUri : IVerb
public string Uri { get; set; }

/// <summary>
/// (optional) The value of the User-To-User header to send within the initial INVITE.
/// (optional, transfer only) The value of the User-To-User header to send within the initial INVITE.
/// </summary>
[XmlAttribute("uui")]
public string Uui { get; set; }
Expand Down
Loading