/// <summary>
        /// Purchase a phone-number for the account
        /// </summary>
        ///
        /// <param name="options"> Create IncomingPhoneNumber parameters </param>
        /// <param name="client"> Client to make requests to Twilio </param>
        /// <returns> A single instance of IncomingPhoneNumber </returns>
        public static IncomingPhoneNumberResource Create(CreateIncomingPhoneNumberOptions options, ITwilioRestClient client = null)
        {
            client = client ?? TwilioClient.GetRestClient();
            var response = client.Request(BuildCreateRequest(options, client));

            return(FromJson(response.Content));
        }
        /// <summary>
        /// Purchase a phone-number for the account
        /// </summary>
        ///
        /// <param name="pathAccountSid"> The account_sid </param>
        /// <param name="phoneNumber"> The phone number </param>
        /// <param name="areaCode"> The desired area code for the new number </param>
        /// <param name="apiVersion"> The Twilio Rest API version to use </param>
        /// <param name="friendlyName"> A human readable description of this resource </param>
        /// <param name="smsApplicationSid"> Unique string that identifies the application </param>
        /// <param name="smsFallbackMethod"> HTTP method used with sms fallback url </param>
        /// <param name="smsFallbackUrl"> URL Twilio will request if an error occurs in executing TwiML </param>
        /// <param name="smsMethod"> HTTP method to use with sms url </param>
        /// <param name="smsUrl"> URL Twilio will request when receiving an SMS </param>
        /// <param name="statusCallback"> URL Twilio will use to pass status parameters </param>
        /// <param name="statusCallbackMethod"> HTTP method twilio will use with status callback </param>
        /// <param name="voiceApplicationSid"> The unique sid of the application to handle this number </param>
        /// <param name="voiceCallerIdLookup"> Look up the caller's caller-ID </param>
        /// <param name="voiceFallbackMethod"> HTTP method used with fallback_url </param>
        /// <param name="voiceFallbackUrl"> URL Twilio will request when an error occurs in TwiML </param>
        /// <param name="voiceMethod"> HTTP method used with the voice url </param>
        /// <param name="voiceUrl"> URL Twilio will request when receiving a call </param>
        /// <param name="emergencyStatus"> The emergency_status </param>
        /// <param name="emergencyAddressSid"> The emergency_address_sid </param>
        /// <param name="trunkSid"> Unique string to identify the trunk </param>
        /// <param name="client"> Client to make requests to Twilio </param>
        /// <returns> Task that resolves to A single instance of IncomingPhoneNumber </returns>
        public static async System.Threading.Tasks.Task <IncomingPhoneNumberResource> CreateAsync(string pathAccountSid = null, Types.PhoneNumber phoneNumber = null, string areaCode = null, string apiVersion = null, string friendlyName = null, string smsApplicationSid = null, Twilio.Http.HttpMethod smsFallbackMethod = null, Uri smsFallbackUrl = null, Twilio.Http.HttpMethod smsMethod = null, Uri smsUrl = null, Uri statusCallback = null, Twilio.Http.HttpMethod statusCallbackMethod = null, string voiceApplicationSid = null, bool?voiceCallerIdLookup = null, Twilio.Http.HttpMethod voiceFallbackMethod = null, Uri voiceFallbackUrl = null, Twilio.Http.HttpMethod voiceMethod = null, Uri voiceUrl = null, IncomingPhoneNumberResource.EmergencyStatusEnum emergencyStatus = null, string emergencyAddressSid = null, string trunkSid = null, ITwilioRestClient client = null)
        {
            var options = new CreateIncomingPhoneNumberOptions {
                PathAccountSid = pathAccountSid, PhoneNumber = phoneNumber, AreaCode = areaCode, ApiVersion = apiVersion, FriendlyName = friendlyName, SmsApplicationSid = smsApplicationSid, SmsFallbackMethod = smsFallbackMethod, SmsFallbackUrl = smsFallbackUrl, SmsMethod = smsMethod, SmsUrl = smsUrl, StatusCallback = statusCallback, StatusCallbackMethod = statusCallbackMethod, VoiceApplicationSid = voiceApplicationSid, VoiceCallerIdLookup = voiceCallerIdLookup, VoiceFallbackMethod = voiceFallbackMethod, VoiceFallbackUrl = voiceFallbackUrl, VoiceMethod = voiceMethod, VoiceUrl = voiceUrl, EmergencyStatus = emergencyStatus, EmergencyAddressSid = emergencyAddressSid, TrunkSid = trunkSid
            };

            return(await CreateAsync(options, client));
        }
 private static Request BuildCreateRequest(CreateIncomingPhoneNumberOptions options, ITwilioRestClient client)
 {
     return(new Request(
                HttpMethod.Post,
                Rest.Domain.Api,
                "/2010-04-01/Accounts/" + (options.PathAccountSid ?? client.AccountSid) + "/IncomingPhoneNumbers.json",
                client.Region,
                postParams: options.GetParams()
                ));
 }
        /// <summary>
        /// Purchase a phone-number for the account
        /// </summary>
        ///
        /// <param name="options"> Create IncomingPhoneNumber parameters </param>
        /// <param name="client"> Client to make requests to Twilio </param>
        /// <returns> Task that resolves to A single instance of IncomingPhoneNumber </returns>
        public static async System.Threading.Tasks.Task <IncomingPhoneNumberResource> CreateAsync(CreateIncomingPhoneNumberOptions options, ITwilioRestClient client = null)
        {
            client = client ?? TwilioClient.GetRestClient();
            var response = await client.RequestAsync(BuildCreateRequest(options, client));

            return(FromJson(response.Content));
        }