/// <summary>
        /// Adds a new validated CallerID to your account. 
        /// After making this request, Twilio will return to you a validation code and dial the phone number given to perform validation. 
        /// The code returned must be entered via the phone before the CallerID will be added to your account.
        /// Makes a POST request to an OutgoingCallerIds List resource.
        /// </summary>
        /// <param name="phoneNumber">The phone number to verify. Should be formatted with a '+' and country code e.g., +16175551212 (E.164 format). Twilio will also accept unformatted US numbers e.g., (415) 555-1212, 415-555-1212.</param>
        /// <param name="friendlyName">A human readable description for the new caller ID with maximum length 64 characters. Defaults to a nicely formatted version of the number.</param>
        /// <param name="callDelay">The number of seconds, between 0 and 60, to delay before initiating the validation call. Defaults to 0.</param>
        /// <param name="extension">Digits to dial after connecting the validation call.</param>
        public ValidationRequestResult AddOutgoingCallerId(string phoneNumber, string friendlyName, int? callDelay, string extension)
        {
            var options = new OutgoingCallerIdOptions()
            {
                FriendlyName = friendlyName,
                CallDelay = callDelay,
                Extension = extension
            };

            return AddOutgoingCallerId(phoneNumber, options);
        }
        /// <summary>
        /// Adds a new validated CallerID to your account. After making this request, Twilio will return to you a validation code and dial the phone number given to perform validation. The code returned must be entered via the phone before the CallerID will be added to your account.
        /// </summary>
        /// <param name="phoneNumber">The phone number to verify. Should be formatted with a '+' and country code e.g., +16175551212 (E.164 format). Twilio will also accept unformatted US numbers e.g., (415) 555-1212, 415-555-1212.</param>
        /// <param name="friendlyName">A human readable description for the new caller ID with maximum length 64 characters. Defaults to a nicely formatted version of the number.</param>
        /// <param name="callDelay">The number of seconds, between 0 and 60, to delay before initiating the validation call. Defaults to 0.</param>
        /// <param name="extension">Digits to dial after connecting the validation call.</param>
        /// <param name="callback">Method to call upon successful completion</param>
        public virtual void AddOutgoingCallerId(string phoneNumber, string friendlyName, int? callDelay, string extension, Action<ValidationRequestResult> callback)
        {
            var options = new OutgoingCallerIdOptions()
            {
                FriendlyName = friendlyName,
                CallDelay = callDelay,
                Extension = extension
            };

            AddOutgoingCallerId(phoneNumber, options, callback);
        }
        /// <summary>
        /// Adds a new validated CallerID to your account. 
        /// After making this request, Twilio will return to you a validation code and dial the phone number given to perform validation. 
        /// The code returned must be entered via the phone before the CallerID will be added to your account.
        /// Makes a POST request to an OutgoingCallerIds List resource.
        /// </summary>
        /// <param name="phoneNumber">The phone number to verify. Should be formatted with a '+' and country code e.g., +16175551212 (E.164 format). Twilio will also accept unformatted US numbers e.g., (415) 555-1212, 415-555-1212.</param>
        /// <param name="friendlyName">A human readable description for the new caller ID with maximum length 64 characters. Defaults to a nicely formatted version of the number.</param>
        /// <param name="callDelay">The number of seconds, between 0 and 60, to delay before initiating the validation call. Defaults to 0.</param>
        /// <param name="extension">Digits to dial after connecting the validation call.</param>
        public virtual async Task<ValidationRequestResult> AddOutgoingCallerIdAsync(string phoneNumber, string friendlyName, int? callDelay, string extension)
        {
            var options = new OutgoingCallerIdOptions()
            {
                FriendlyName = friendlyName,
                CallDelay = callDelay,
                Extension = extension
            };

            return await AddOutgoingCallerIdAsync(phoneNumber, options);
        }
        /// <summary>
        /// Adds a new validated CallerID to your account. 
        /// After making this request, Twilio will return to you a validation code and dial the phone number given to perform validation. 
        /// The code returned must be entered via the phone before the CallerID will be added to your account.
        /// Makes a POST request to an OutgoingCallerIds List resource.
        /// </summary>
        /// <param name="phoneNumber">The phone number to verify. Should be formatted with a '+' and country code e.g., +16175551212 (E.164 format). Twilio will also accept unformatted US numbers e.g., (415) 555-1212, 415-555-1212.</param>
        /// <param name="options">Optional parameters to use when purchasing number</param>
        public ValidationRequestResult AddOutgoingCallerId(string phoneNumber, OutgoingCallerIdOptions options)
        {
            Require.Argument("PhoneNumber", phoneNumber);
            if (options.CallDelay.HasValue) Validate.IsBetween(options.CallDelay.Value, 0, 60);

            var request = new RestRequest(Method.POST);
            request.Resource = "Accounts/{AccountSid}/OutgoingCallerIds.json";
            request.AddParameter("PhoneNumber", phoneNumber);

            if (options.FriendlyName.HasValue()) request.AddParameter("FriendlyName", options.FriendlyName);
            if (options.CallDelay.HasValue) request.AddParameter("CallDelay", options.CallDelay.Value);
            if (options.Extension.HasValue()) request.AddParameter("Extension", options.Extension);

            if (options.StatusCallback.HasValue()) request.AddParameter("StatusCallback", options.StatusCallback);
            if (options.StatusCallbackMethod.HasValue()) request.AddParameter("StatusCallbackMethod", options.StatusCallbackMethod);

            return Execute<ValidationRequestResult>(request);
        }
 /// <summary>
 /// Adds a new validated CallerID to your account. 
 /// After making this request, Twilio will return to you a validation code and dial the phone number given to perform validation. 
 /// The code returned must be entered via the phone before the CallerID will be added to your account.
 /// Makes a POST request to an OutgoingCallerIds List resource.
 /// </summary>
 /// <param name="phoneNumber">The phone number to verify. Should be formatted with a '+' and country code e.g., +16175551212 (E.164 format). Twilio will also accept unformatted US numbers e.g., (415) 555-1212, 415-555-1212.</param>
 /// <param name="options">Optional parameters to use when purchasing number</param>
 public IAsyncOperation<ValidationRequestResult> AddOutgoingCallerIdAsync(string phoneNumber, OutgoingCallerIdOptions options)
 {
     return (IAsyncOperation<ValidationRequestResult>)AsyncInfo.Run((System.Threading.CancellationToken ct) => AddOutgoingCallerIdAsyncInternal(phoneNumber, options));
 }
        private async Task<ValidationRequestResult> AddOutgoingCallerIdAsyncInternal(string phoneNumber, OutgoingCallerIdOptions options)
        {
            Require.Argument("PhoneNumber", phoneNumber);
            if (options.CallDelay.HasValue) Validate.IsBetween(options.CallDelay.Value, 0, 60);

            var request = new RestRequest();
            request.Method = Method.POST;
            request.Resource = "Accounts/{AccountSid}/OutgoingCallerIds.json";
            request.AddParameter("PhoneNumber", phoneNumber);

            if (options.FriendlyName.HasValue()) request.AddParameter("FriendlyName", options.FriendlyName);
            if (options.CallDelay.HasValue) request.AddParameter("CallDelay", options.CallDelay.Value);
            if (options.Extension.HasValue()) request.AddParameter("Extension", options.Extension);

            if (options.StatusCallback.HasValue()) request.AddParameter("StatusCallback", options.StatusCallback);
            if (options.StatusCallbackMethod.HasValue()) request.AddParameter("StatusCallbackMethod", options.StatusCallbackMethod);

            var result = await ExecuteAsync(request, typeof(ValidationRequestResult));
            return (ValidationRequestResult)result;
        }
        private async Task <ValidationRequestResult> AddOutgoingCallerIdAsyncInternal(string phoneNumber, OutgoingCallerIdOptions options)
        {
            Require.Argument("PhoneNumber", phoneNumber);
            if (options.CallDelay.HasValue)
            {
                Validate.IsBetween(options.CallDelay.Value, 0, 60);
            }

            var request = new RestRequest();

            request.Method   = Method.POST;
            request.Resource = "Accounts/{AccountSid}/OutgoingCallerIds.json";
            request.AddParameter("PhoneNumber", phoneNumber);

            if (options.FriendlyName.HasValue())
            {
                request.AddParameter("FriendlyName", options.FriendlyName);
            }
            if (options.CallDelay.HasValue)
            {
                request.AddParameter("CallDelay", options.CallDelay.Value);
            }
            if (options.Extension.HasValue())
            {
                request.AddParameter("Extension", options.Extension);
            }

            if (options.StatusCallback.HasValue())
            {
                request.AddParameter("StatusCallback", options.StatusCallback);
            }
            if (options.StatusCallbackMethod.HasValue())
            {
                request.AddParameter("StatusCallbackMethod", options.StatusCallbackMethod);
            }

            var result = await ExecuteAsync(request, typeof(ValidationRequestResult));

            return((ValidationRequestResult)result);
        }
 /// <summary>
 /// Adds a new validated CallerID to your account.
 /// After making this request, Twilio will return to you a validation code and dial the phone number given to perform validation.
 /// The code returned must be entered via the phone before the CallerID will be added to your account.
 /// Makes a POST request to an OutgoingCallerIds List resource.
 /// </summary>
 /// <param name="phoneNumber">The phone number to verify. Should be formatted with a '+' and country code e.g., +16175551212 (E.164 format). Twilio will also accept unformatted US numbers e.g., (415) 555-1212, 415-555-1212.</param>
 /// <param name="options">Optional parameters to use when purchasing number</param>
 public IAsyncOperation <ValidationRequestResult> AddOutgoingCallerIdAsync(string phoneNumber, OutgoingCallerIdOptions options)
 {
     return((IAsyncOperation <ValidationRequestResult>)AsyncInfo.Run((System.Threading.CancellationToken ct) => AddOutgoingCallerIdAsyncInternal(phoneNumber, options)));
 }
        /// <summary>
        /// Adds a new validated CallerID to your account.
        /// After making this request, Twilio will return to you a validation code and dial the phone number given to perform validation.
        /// The code returned must be entered via the phone before the CallerID will be added to your account.
        /// Makes a POST request to an OutgoingCallerIds List resource.
        /// </summary>
        /// <param name="phoneNumber">The phone number to verify. Should be formatted with a '+' and country code e.g., +16175551212 (E.164 format). Twilio will also accept unformatted US numbers e.g., (415) 555-1212, 415-555-1212.</param>
        /// <param name="options">Optional parameters to use when purchasing number</param>
        public virtual ValidationRequestResult AddOutgoingCallerId(string phoneNumber, OutgoingCallerIdOptions options)
        {
            Require.Argument("PhoneNumber", phoneNumber);
            if (options.CallDelay.HasValue)
            {
                Validate.IsBetween(options.CallDelay.Value, 0, 60);
            }

            var request = new RestRequest(Method.POST);

            request.Resource = "Accounts/{AccountSid}/OutgoingCallerIds.json";
            request.AddParameter("PhoneNumber", phoneNumber);

            if (options.FriendlyName.HasValue())
            {
                request.AddParameter("FriendlyName", options.FriendlyName);
            }
            if (options.CallDelay.HasValue)
            {
                request.AddParameter("CallDelay", options.CallDelay.Value);
            }
            if (options.Extension.HasValue())
            {
                request.AddParameter("Extension", options.Extension);
            }

            if (options.StatusCallback.HasValue())
            {
                request.AddParameter("StatusCallback", options.StatusCallback);
            }
            if (options.StatusCallbackMethod.HasValue())
            {
                request.AddParameter("StatusCallbackMethod", options.StatusCallbackMethod);
            }

            return(Execute <ValidationRequestResult>(request));
        }