Example #1
0
        private TwilioDial ConstructDial(RouteDetails route)
        {
            var dial = new TwilioDial
            {
                TimeLimit = "60"
            };

            dial.Text   = route.terminationNumber;
            dial.Action = $"{_postCallUrl}/api/postcall?cd={route.callServiceUrlParameter}";

            return(dial);
        }
        public static string XmlSerialize(TwilioDial twDial)
        {
            StringBuilder result = new StringBuilder();

            result.Append("<Dial");

            if (!string.IsNullOrEmpty(twDial.Record))
            {
                result.Append($" record=\"{twDial.Record}\"");
            }

            if (!string.IsNullOrEmpty(twDial.RecordingStatusCallback))
            {
                result.Append($" recordingStatusCallback=\"{twDial.RecordingStatusCallback}\"");
            }

            if (!string.IsNullOrEmpty(twDial.Action))
            {
                result.Append($" action=\"{twDial.Action}\"");
            }

            if (!string.IsNullOrEmpty(twDial.TimeLimit))
            {
                result.Append($" timeLimit=\"{twDial.TimeLimit}\"");
            }

            if (!string.IsNullOrEmpty(twDial.Timeout))
            {
                result.Append($" timeout=\"{twDial.Timeout}\"");
            }

            result.Append(">");
            if (!string.IsNullOrEmpty(twDial.Text))
            {
                result.Append($"{twDial.Text}");
            }
            else if (twDial.Number != null)
            {
                result.Append(XmlSerialize(twDial.Number));
            }

            result.AppendLine("</Dial>");
            return(result.ToString());
        }