コード例 #1
0
        private Response HandleBasicRoute(RouteDetails numInfo)
        {
            _logger.LogInformation($"HandleBasicRoute");

            var ret  = new Response();
            var dial = ConstructDial(numInfo);

            if (numInfo.callRecordEnabled)
            {
                TwilioSay  saying = null;
                TwilioPlay play   = null;
                bool       callRecordKeyPressRequired = (numInfo.callRecordConfirmationRequired ?? false) && (!string.IsNullOrEmpty(numInfo.callRecordNotificationText) || !string.IsNullOrEmpty(numInfo.callRecordNotificationFileId));

                if (!string.IsNullOrEmpty(numInfo.callRecordNotificationText))
                {
                    var lang = numInfo.terminationNumber.StartsWith("61")
                        ? "en-AU"
                        : "en-US";

                    saying = new TwilioSay {
                        Loop = 1, Text = numInfo.callRecordNotificationText, Voice = "alice", Language = lang
                    };
                }
                else if (!string.IsNullOrEmpty(numInfo.callRecordNotificationFileId))
                {
                    var fileLink      = $"{numInfo.callRecordNotificationFileId}-{numInfo.callRecordNotificationFileName}";
                    var mediaFileType = numInfo.callRecordNotificationFileType == 6
                        ? "CallRecordStudyFiles"
                        : "CallRecordNotificationFiles";
                    play = new TwilioPlay {
                        Loop = 1, Text = $"{_mediaFileUrl}/api/mediafile?mediaFile={Base64UrlTextEncoder.Encode(Encoding.UTF8.GetBytes(fileLink))}&mediaType={mediaFileType}&tenantId=1234"
                    };
                }
                ret.Saying = saying;
                ret.Play   = play;
            }
            ret.Dialing = dial;

            return(ret);
        }
コード例 #2
0
 public static string XmlSerialize(TwilioPlay twPlay)
 {
     return($"<Play>{twPlay.Text}</Play>");
 }