/// <summary> /// Initiate outbound call with options. Make POST request /// </summary> /// <param name="callOptions">Call options</param> /// <returns></returns> public async Task<Call> MakeCall(CallOptions callOptions) { Require.Argument("To", callOptions.To); Require.Argument("From", callOptions.From); Require.Argument("Url", callOptions.Url); var request = new RestRequest(System.Net.Http.HttpMethod.Post); request.Resource = RequestUri.MakeCallUri; CreateCallOptions(callOptions, request); return await Execute<Call>(request); }
/// <summary> /// Initiate outbound call with options. Make POST request /// </summary> /// <param name="callOptions">Call options</param> /// <returns></returns> public Call MakeCall(CallOptions callOptions) { Require.Argument("To", callOptions.To); Require.Argument("From", callOptions.From); Require.Argument("Url", callOptions.Url); var request = new RestRequest(Method.POST); request.Resource = RequestUri.MakeCallUri; CreateCallOptions(callOptions, request); return Execute<Call>(request); }
/// <summary> /// Helper method to populate Rest params /// </summary> /// <param name="callOptions">Call options</param> /// <param name="request">Rest Request</param> private void CreateCallOptions(CallOptions callOptions, RestRequest request) { request.AddParameter("To", callOptions.To); request.AddParameter("From", callOptions.From); request.AddParameter("Url", callOptions.Url); if (callOptions.ForwardedFrom != null) request.AddParameter("ForwardedFrom", callOptions.ForwardedFrom); if (callOptions.Method != null) request.AddParameter("Method", callOptions.Method.ToString().ToUpper()); if (callOptions.FallbackUrl != null) request.AddParameter("FallbackUrl", callOptions.FallbackUrl); if (callOptions.FallbackMethod != null) request.AddParameter("FallbackMethod", callOptions.FallbackMethod.ToString().ToUpper()); if (callOptions.StatusCallback != null) request.AddParameter("StatusCallback", callOptions.StatusCallback); if (callOptions.StatusCallbackMethod != null) request.AddParameter("StatusCallbackMethod", callOptions.StatusCallbackMethod.ToString().ToUpper()); if (callOptions.SendDigits != null) request.AddParameter("PlayDtmf", callOptions.SendDigits); if (callOptions.Timeout.HasValue) request.AddParameter("Timeout", callOptions.Timeout); if (callOptions.HideCallerId.HasValue) request.AddParameter("HideCallerId", callOptions.HideCallerId); if (callOptions.HeartbeatUrl != null) request.AddParameter("HeartbeartUrl", callOptions.HeartbeatUrl); if (callOptions.HeartbeatMethod.HasValue) request.AddParameter("HeartbeatMethod", callOptions.HeartbeatMethod.ToString().ToUpper()); if (callOptions.Record.HasValue) request.AddParameter("Record", callOptions.Record); if (callOptions.RecordCallback != null) request.AddParameter("RecordCallback", callOptions.RecordCallback); if (callOptions.RecordCallbackMethod.HasValue) request.AddParameter("RecordCallbackMethod", callOptions.RecordCallbackMethod.ToString().ToUpper()); if (callOptions.Transcribe.HasValue) request.AddParameter("Transcribe", callOptions.Transcribe); if (callOptions.TranscribeCallback != null) request.AddParameter("TranscribeCallback", callOptions.TranscribeCallback); }