/// <summary>
        /// Records a call
        /// </summary>
        /// <param name="accountSid">The account sid.</param>
        /// <param name="callSid">Call SID.</param>
        /// <param name="record">Specifies if a call recording should start or end. Allowed values are "true" to start recording and "false" to end recording. Any number of simultaneous, separate recordings can be initiated.</param>
        /// <param name="direction">Specifies which audio stream to record. Allowed values are "in" to record the incoming caller's audio, "out" to record the outgoing caller's audio, and "both" to record both.</param>
        /// <param name="timeLimit">The maximum duration of the recording.Allowed value is an integer greater than 0.</param>
        /// <param name="callbackUrl">A URL that will be requested when the recording ends, sending information about the recording. The longer the recording, the longer the delay in processing the recording and requesting the CallbackUrl. Url length is limited to 200 characters.</param>
        /// <param name="fileFormat">Specifies the file format of the recording. Allowed values are "mp3" or "wav" - any other value will default to "mp3".</param>
        /// <param name="trimSilence">Trims all silence from the beginning of the recording. Allowed values are "true" or "false" - any other value will default to "false".</param>
        /// <param name="transcribe">Specifies if this recording should be transcribed. Allowed values are "true" and "false" - all other values will default to "false".</param>
        /// <param name="transcribeQuality">Specifies the quality of the transcription. Allowed values are "auto" for automated transcriptions and "hybrid" for human-reviewed transcriptions - all other values will default to "auto".</param>
        /// <param name="transcribeCallback">A URL that will be requested when the call ends, sending information about the transcription. The longer the recording, the longer the delay in processing the transcription and requesting the TranscribeCallback. URL length is limited to 200 characters.</param>
        /// <returns>Returns created recording</returns>
        public Recording RecordCall(string accountSid, string callSid, bool record,
                                    RecordingAudioDirection direction = RecordingAudioDirection.BOTH, int?timeLimit = null,
                                    string callbackUrl = null, RecordingFileFormat fileFormat = RecordingFileFormat.MP3,
                                    bool trimSilence   = false, bool transcribe = false,
                                    TranscribeQuality transcribeQuality = TranscribeQuality.AUTO,
                                    string transcribeCallback           = null)
        {
            // Get client to make request
            var client = HttpProvider.GetHttpClient();

            // Create POST request
            var request = RestRequestHelper.CreateRestRequest(Method.POST,
                                                              $"Accounts/{accountSid}/Calls/{callSid}/Recordings.json");

            // Mark obligatory parameters
            Require.Argument("Record", record);

            // Add RecordCall query and body parameters
            this.SetParamsForRecordCall(request, record, direction, timeLimit, callbackUrl, fileFormat, trimSilence,
                                        transcribe, transcribeQuality, transcribeCallback);

            // Send request
            var response = client.Execute(request);

            return(this.ReturnOrThrowException <Recording>(response));
        }
        /// <summary>
        /// Transcribes an audio file on some URL
        /// </summary>
        /// <param name="audioUrl">URL where the audio to be transcribed is located.</param>
        /// <param name="transcribeCallback">URL that will be requested when the transcription has finished processing.</param>
        /// <param name="callbackMethod">Specifies the HTTP method to use when requesting the TranscribeCallback URL. Allowed values are "POST" and "GET".</param>
        /// <param name="sliceStart">Start point for slice transcription (in seconds).</param>
        /// <param name="sliceDuration">Duration of slice transcription (in seconds).</param>
        /// <param name="quality">Specifies the transcription quality. Transcription price differs for each quality tier. See pricing page for details. Allowed values are "auto", "hybrid" and "keywords", where "auto" is a machine-generated transcription, "hybrid" is reviewed by a human for accuracy and "keywords" returns topics and keywords for given audio file.</param>
        /// <returns>Returns created transcription</returns>
        public Transcription TranscribeAudioUrl(string audioUrl, string transcribeCallback = null,
                                                HttpMethod callbackMethod = HttpMethod.POST, int?sliceStart = null,
                                                int?sliceDuration         = null, TranscribeQuality quality = TranscribeQuality.AUTO)
        {
            // Get account sid from configuration
            var accountSid = HttpProvider.GetConfiguration().AccountSid;

            return(this.TranscribeAudioUrl(accountSid, audioUrl, transcribeCallback, callbackMethod, sliceStart,
                                           sliceDuration, quality));
        }
        /// <summary>
        /// Records a call. Uses {accountSid} from configuration in HttpProvider
        /// </summary>
        /// <param name="callSid">Call SID.</param>
        /// <param name="record">Specifies if a call recording should start or end. Allowed values are "true" to start recording and "false" to end recording. Any number of simultaneous, separate recordings can be initiated.</param>
        /// <param name="direction">Specifies which audio stream to record. Allowed values are "in" to record the incoming caller's audio, "out" to record the outgoing caller's audio, and "both" to record both.</param>
        /// <param name="timeLimit">The maximum duration of the recording.Allowed value is an integer greater than 0.</param>
        /// <param name="callbackUrl">A URL that will be requested when the recording ends, sending information about the recording. The longer the recording, the longer the delay in processing the recording and requesting the CallbackUrl. Url length is limited to 200 characters.</param>
        /// <param name="fileFormat">Specifies the file format of the recording. Allowed values are "mp3" or "wav" - any other value will default to "mp3".</param>
        /// <param name="trimSilence">Trims all silence from the beginning of the recording. Allowed values are "true" or "false" - any other value will default to "false".</param>
        /// <param name="transcribe">Specifies if this recording should be transcribed. Allowed values are "true" and "false" - all other values will default to "false".</param>
        /// <param name="transcribeQuality">Specifies the quality of the transcription. Allowed values are "auto" for automated transcriptions and "hybrid" for human-reviewed transcriptions - all other values will default to "auto".</param>
        /// <param name="transcribeCallback">A URL that will be requested when the call ends, sending information about the transcription. The longer the recording, the longer the delay in processing the transcription and requesting the TranscribeCallback. URL length is limited to 200 characters.</param>
        /// <returns>Returns created recording</returns>
        public Recording RecordCall(string callSid, bool record,
                                    RecordingAudioDirection direction = RecordingAudioDirection.BOTH, int?timeLimit = null,
                                    string callbackUrl = null, RecordingFileFormat fileFormat = RecordingFileFormat.MP3,
                                    bool trimSilence   = false, bool transcribe = false,
                                    TranscribeQuality transcribeQuality = TranscribeQuality.AUTO,
                                    string transcribeCallback           = null)
        {
            // Get account sid from configuration
            var accountSid = HttpProvider.GetConfiguration().AccountSid;

            return(this.RecordCall(accountSid, callSid, record, direction, timeLimit, callbackUrl, fileFormat,
                                   trimSilence,
                                   transcribe, transcribeQuality, transcribeCallback));
        }
 /// <summary>
 /// Sets the parameters for transcribe recording.
 /// </summary>
 /// <param name="request">The request.</param>
 /// <param name="transcribeCallback">The transcribe callback.</param>
 /// <param name="callbackMethod">The callback method.</param>
 /// <param name="sliceStart">The slice start.</param>
 /// <param name="sliceDuration">Duration of the slice.</param>
 /// <param name="quality">The quality.</param>
 private void SetParamsForTranscribeRecordingOrAudioUrl(IRestRequest request, string transcribeCallback,
                                                        HttpMethod callbackMethod, int?sliceStart,
                                                        int?sliceDuration, TranscribeQuality quality)
 {
     if (transcribeCallback.HasValue())
     {
         request.AddParameter("TranscribeCallback", transcribeCallback);
     }
     request.AddParameter("CallbackMethod", callbackMethod);
     if (sliceStart != null)
     {
         request.AddParameter("SliceStart", sliceStart.ToString());
     }
     if (sliceDuration != null)
     {
         request.AddParameter("SliceDuration", sliceDuration);
     }
     request.AddParameter("Quality", EnumHelper.GetEnumValue(quality));
 }
        /// <summary>
        /// Transcribes some recording
        /// </summary>
        /// <param name="accountSid">The account sid.</param>
        /// <param name="recordingSid">Recording SID.</param>
        /// <param name="transcribeCallback">The URL some parameters regarding the transcription will be passed to once it is completed. The longer the recording time, the longer the process delay in returning the transcription information. If no TranscribeCallback is given, the recording will still be saved to the system and available either in your Transcriptions Logs or via a REST List Transcriptions (ADD URL LINK) request. URL length is limited to 200 characters.</param>
        /// <param name="callbackMethod">The HTTP method used to request the TranscribeCallback. Valid parameters are GET and POST - any other value will default to POST.</param>
        /// <param name="sliceStart">Start point for slice transcription(in seconds).</param>
        /// <param name="sliceDuration">Duration of slice transcription (in seconds).</param>
        /// <param name="quality">Specifies the transcription quality.Transcription price differs for each quality tier.See pricing page for details.Allowed values are "auto", "hybrid" and "keywords", where "auto" is a machine-generated transcription, "hybrid" is reviewed by a human for accuracy and "keywords" returns topics and keywords for given audio file.</param>
        /// <returns>Returns created transcription</returns>
        public Transcription TranscribeRecording(string accountSid, string recordingSid,
                                                 string transcribeCallback = null, HttpMethod callbackMethod = HttpMethod.POST, int?sliceStart = null,
                                                 int?sliceDuration         = null, TranscribeQuality quality = TranscribeQuality.AUTO)
        {
            // Get client to make request
            var client = HttpProvider.GetHttpClient();

            // Create POST request
            var request = RestRequestHelper.CreateRestRequest(Method.POST, $"Accounts/{accountSid}/Transcriptions.json");

            // Add TranscribeRecording query and body parameters
            this.SetParamsForTranscribeRecordingOrAudioUrl(request, transcribeCallback, callbackMethod, sliceStart,
                                                           sliceDuration, quality);

            // Send request
            var response = client.Execute(request);

            return(this.ReturnOrThrowException <Transcription>(response));
        }
 /// <summary>
 /// Sets the parameters for record call.
 /// </summary>
 /// <param name="request">The request.</param>
 /// <param name="record">if set to <c>true</c> [record].</param>
 /// <param name="direction">The direction.</param>
 /// <param name="timeLimit">The time limit.</param>
 /// <param name="callbackUrl">The callback URL.</param>
 /// <param name="fileFormat">The file format.</param>
 /// <param name="trimSilence">if set to <c>true</c> [trim silence].</param>
 /// <param name="transcribe">if set to <c>true</c> [transcribe].</param>
 /// <param name="transcribeQuality">The transcribe quality.</param>
 /// <param name="transcribeCallback">The transcribe callback.</param>
 private void SetParamsForRecordCall(IRestRequest request, bool record, RecordingAudioDirection direction,
                                     int?timeLimit, string callbackUrl, RecordingFileFormat fileFormat, bool trimSilence, bool transcribe,
                                     TranscribeQuality transcribeQuality, string transcribeCallback)
 {
     request.AddParameter("Record", record);
     request.AddParameter("Direction", EnumHelper.GetEnumValue(direction));
     if (timeLimit != null)
     {
         request.AddParameter("TimeLimit", timeLimit);
     }
     if (callbackUrl.HasValue())
     {
         request.AddParameter("CallbackUrl", callbackUrl);
     }
     request.AddParameter("FileFormat", EnumHelper.GetEnumValue(fileFormat));
     request.AddParameter("TrimSilence", trimSilence);
     request.AddParameter("Transcribe", transcribe);
     request.AddParameter("TranscribeQuality", EnumHelper.GetEnumValue(transcribeQuality));
     if (transcribeCallback.HasValue())
     {
         request.AddParameter("TranscribeCallback", transcribeCallback);
     }
 }