Beispiel #1
0
        /// <summary>
        /// TelAPI allows you to play an audio file during a call. This is useful for playing hold music, providing IVR prompts, etc.
        /// </summary>
        /// <param name="callSid">An alphanumeric string used for identification of calls</param>
        /// <param name="audioOptions">Audio options</param>
        /// <returns></returns>
        public async Task<Call> PlayAudio(string callSid, PlayAudioOptions audioOptions)
        {
            Require.Argument("CallSid", callSid);
            Require.Argument("AudioUrl", audioOptions.AudioUrl);

            var request = new RestRequest(System.Net.Http.HttpMethod.Post);
            request.Resource = RequestUri.PlayAudioUri;
            request.AddUrlSegment(RequestUriParams.CallSid, callSid);

            CreatePlayAudioOptions(audioOptions, request);

            return await Execute<Call>(request);
        }
Beispiel #2
0
        /// <summary>
        /// Helper method to populate Rest params
        /// </summary>
        /// <param name="audioOptions">Audio options</param>
        /// <param name="request">Rest Request</param>
        private void CreatePlayAudioOptions(PlayAudioOptions audioOptions, RestRequest request)
        {
            request.AddParameter("AudioUrl", audioOptions.AudioUrl);

            if (audioOptions.Length.HasValue) request.AddParameter("Length", audioOptions.Length);
            if (audioOptions.Leg.HasValue) request.AddParameter("Legs", audioOptions.Leg.ToString().ToLower());
            if (audioOptions.Loop.HasValue) request.AddParameter("Loop", audioOptions.Loop);
            if (audioOptions.Mix.HasValue) request.AddParameter("Mix", audioOptions.Mix);
        }
Beispiel #3
0
        /// <summary>
        /// TelAPI allows you to play an audio file during a call. This is useful for playing hold music, providing IVR prompts, etc.
        /// </summary>
        /// <param name="callSid">An alphanumeric string used for identification of calls</param>
        /// <param name="audioOptions">Audio options</param>
        /// <returns></returns>
        public Call PlayAudio(string callSid, PlayAudioOptions audioOptions)
        {
            Require.Argument("CallSid", callSid);
            Require.Argument("AudioUrl", audioOptions.AudioUrl);

            var request = new RestRequest(Method.POST);
            request.Resource = RequestUri.PlayAudioUri;
            request.AddUrlSegment(RequestUriParams.CallSid, callSid);
            
            CreatePlayAudioOptions(audioOptions, request);

            return Execute<Call>(request);
        }