Esempio n. 1
0
		/// <summary>
		/// Tries to update the application's properties, and returns the updated resource representation if successful.
		/// </summary>
		/// <param name="applicationSid">The Sid of the application to update</param>
		/// <param name="friendlyName">The friendly name to rename the application to (optional, null to leave as-is)</param>
		/// <param name="options">Which settings to update. Only properties with values set will be updated.</param>
        public virtual Application UpdateApplication(string applicationSid, string friendlyName, ApplicationOptions options)
		{
			Require.Argument("ApplicationSid", applicationSid);

			var request = new RestRequest(Method.POST);
			request.Resource = "Accounts/{AccountSid}/Applications/{ApplicationSid}.json";
			request.AddUrlSegment("ApplicationSid", applicationSid);
			
			if (friendlyName.HasValue()) request.AddParameter("FriendlyName", friendlyName);
			if (options != null)
			{
				if (options.VoiceUrl != null) request.AddParameter("VoiceUrl", options.VoiceUrl);
				if (options.VoiceMethod.HasValue()) request.AddParameter("VoiceMethod", options.VoiceMethod.ToString());
				if (options.VoiceFallbackUrl != null) request.AddParameter("VoiceFallbackUrl", options.VoiceFallbackUrl);
				if (options.VoiceFallbackMethod.HasValue()) request.AddParameter("VoiceFallbackMethod", options.VoiceFallbackMethod.ToString());
				if (options.VoiceCallerIdLookup.HasValue) request.AddParameter("VoiceCallerIdLookup", options.VoiceCallerIdLookup.Value);
				if (options.StatusCallback.HasValue()) request.AddParameter("StatusCallback", options.StatusCallback);
				if (options.StatusCallbackMethod.HasValue()) request.AddParameter("StatusCallbackMethod", options.StatusCallbackMethod.ToString());
				if (options.SmsUrl != null) request.AddParameter("SmsUrl", options.SmsUrl);
				if (options.SmsMethod.HasValue()) request.AddParameter("SmsMethod", options.SmsMethod.ToString());
				if (options.SmsFallbackUrl != null) request.AddParameter("SmsFallbackUrl", options.SmsFallbackUrl);
				if (options.SmsFallbackMethod.HasValue()) request.AddParameter("SmsFallbackMethod", options.SmsFallbackMethod.ToString());
			}

			return Execute<Application>(request);
		}
        /// <summary>
        /// Create a new application
        /// </summary>
        /// <param name="friendlyName">The friendly name to name the application</param>
        /// <param name="options">Optional parameters to use when purchasing number</param>
        /// <param name="callback">Method to call upon successful completion</param>
        public virtual void AddApplication(string friendlyName, ApplicationOptions options, Action<Application> callback)
        {
            var request = new RestRequest(Method.POST);
            request.Resource = "Accounts/{AccountSid}/Applications.json";
            
            Require.Argument("FriendlyName", friendlyName);
            Validate.IsValidLength(friendlyName, 64);
            request.AddParameter("FriendlyName", friendlyName);

            // some check for null. in those cases an empty string is a valid value (to remove a URL assignment)
            if (options != null)
            {
                if (options.VoiceUrl != null) request.AddParameter("VoiceUrl", options.VoiceUrl);
                if (options.VoiceMethod.HasValue()) request.AddParameter("VoiceMethod", options.VoiceMethod.ToString());
                if (options.VoiceFallbackUrl != null) request.AddParameter("VoiceFallbackUrl", options.VoiceFallbackUrl);
                if (options.VoiceFallbackMethod.HasValue()) request.AddParameter("VoiceFallbackMethod", options.VoiceFallbackMethod.ToString());
                if (options.VoiceCallerIdLookup.HasValue) request.AddParameter("VoiceCallerIdLookup", options.VoiceCallerIdLookup.Value);
                if (options.StatusCallback.HasValue()) request.AddParameter("StatusCallback", options.StatusCallback);
                if (options.StatusCallbackMethod.HasValue()) request.AddParameter("StatusCallbackMethod", options.StatusCallbackMethod.ToString());
                if (options.SmsUrl != null) request.AddParameter("SmsUrl", options.SmsUrl);
                if (options.SmsMethod.HasValue()) request.AddParameter("SmsMethod", options.SmsMethod.ToString());
                if (options.SmsFallbackUrl != null) request.AddParameter("SmsFallbackUrl", options.SmsFallbackUrl);
                if (options.SmsFallbackMethod.HasValue()) request.AddParameter("SmsFallbackMethod", options.SmsFallbackMethod.ToString());
            }

            ExecuteAsync<Application>(request, (response) => { callback(response); });
        }
Esempio n. 3
0
        private async Task<Application> AddApplicationAsyncInternal(string friendlyName, ApplicationOptions options)
		{
			var request = new RestRequest();
            request.Method = Method.POST;
			request.Resource = "Accounts/{AccountSid}/Applications.json";
			
			Require.Argument("FriendlyName", friendlyName);
			Validate.IsValidLength(friendlyName, 64);
			request.AddParameter("FriendlyName", friendlyName);

			// some check for null. in those cases an empty string is a valid value (to remove a URL assignment)
			if (options != null)
			{
				if (options.VoiceUrl != null) request.AddParameter("VoiceUrl", options.VoiceUrl);
				if (options.VoiceMethod.HasValue()) request.AddParameter("VoiceMethod", options.VoiceMethod.ToString());
				if (options.VoiceFallbackUrl != null) request.AddParameter("VoiceFallbackUrl", options.VoiceFallbackUrl);
				if (options.VoiceFallbackMethod.HasValue()) request.AddParameter("VoiceFallbackMethod", options.VoiceFallbackMethod.ToString());
				if (options.VoiceCallerIdLookup.HasValue) request.AddParameter("VoiceCallerIdLookup", options.VoiceCallerIdLookup.Value);
				if (options.StatusCallback.HasValue()) request.AddParameter("StatusCallback", options.StatusCallback);
				if (options.StatusCallbackMethod.HasValue()) request.AddParameter("StatusCallbackMethod", options.StatusCallbackMethod.ToString());
				if (options.SmsUrl != null) request.AddParameter("SmsUrl", options.SmsUrl);
				if (options.SmsMethod.HasValue()) request.AddParameter("SmsMethod", options.SmsMethod.ToString());
				if (options.SmsFallbackUrl != null) request.AddParameter("SmsFallbackUrl", options.SmsFallbackUrl);
				if (options.SmsFallbackMethod.HasValue()) request.AddParameter("SmsFallbackMethod", options.SmsFallbackMethod.ToString());
			}

            var result = await ExecuteAsync(request, typeof(Application));
            return (Application)result;
		}
    static void Main(string[] args)
    {
        // Find your Account Sid and Auth Token at twilio.com/user/account
        string AccountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        string AuthToken = "your_auth_token";
        var twilio = new TwilioRestClient(AccountSid, AuthToken);

        var options = new ApplicationOptions();
        options.VoiceUrl = "http://demo.twilio.com/docs/voice.xml";
        options.SmsUrl = "http://demo.twilio.com/docs/sms.xml";

        twilio.UpdateApplication("AP2a0747eba6abf96b7e3c3ff0b4530f6e", null, options);
    }
    static void Main(string[] args)
    {
        // Find your Account Sid and Auth Token at twilio.com/user/account
        string AccountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        string AuthToken = "your_auth_token";
        var twilio = new TwilioRestClient(AccountSid, AuthToken);

        var options = new ApplicationOptions();
        options.VoiceUrl = "http://demo.twilio.com/docs/voice.xml";
        options.VoiceMethod = "GET";
        var app = twilio.AddApplication("Phone Me", options);

        Console.WriteLine(app.Sid);
    }
Esempio n. 6
0
        /// <summary>
        /// Create a new application
        /// </summary>
        /// <param name="friendlyName">The friendly name to name the application</param>
        /// <param name="options">Optional parameters to use when purchasing number</param>
        /// <param name="callback">Method to call upon successful completion</param>
        public virtual void AddApplication(string friendlyName, ApplicationOptions options, Action <Application> callback)
        {
            var request = new RestRequest(Method.POST);

            request.Resource = "Accounts/{AccountSid}/Applications.json";

            Require.Argument("FriendlyName", friendlyName);
            Validate.IsValidLength(friendlyName, 64);
            request.AddParameter("FriendlyName", friendlyName);

            // some check for null. in those cases an empty string is a valid value (to remove a URL assignment)
            if (options != null)
            {
                if (options.VoiceUrl != null)
                {
                    request.AddParameter("VoiceUrl", options.VoiceUrl);
                }
                if (options.VoiceMethod.HasValue())
                {
                    request.AddParameter("VoiceMethod", options.VoiceMethod.ToString());
                }
                if (options.VoiceFallbackUrl != null)
                {
                    request.AddParameter("VoiceFallbackUrl", options.VoiceFallbackUrl);
                }
                if (options.VoiceFallbackMethod.HasValue())
                {
                    request.AddParameter("VoiceFallbackMethod", options.VoiceFallbackMethod.ToString());
                }
                if (options.VoiceCallerIdLookup.HasValue)
                {
                    request.AddParameter("VoiceCallerIdLookup", options.VoiceCallerIdLookup.Value);
                }
                if (options.StatusCallback.HasValue())
                {
                    request.AddParameter("StatusCallback", options.StatusCallback);
                }
                if (options.StatusCallbackMethod.HasValue())
                {
                    request.AddParameter("StatusCallbackMethod", options.StatusCallbackMethod.ToString());
                }
                if (options.SmsUrl != null)
                {
                    request.AddParameter("SmsUrl", options.SmsUrl);
                }
                if (options.SmsMethod.HasValue())
                {
                    request.AddParameter("SmsMethod", options.SmsMethod.ToString());
                }
                if (options.SmsFallbackUrl != null)
                {
                    request.AddParameter("SmsFallbackUrl", options.SmsFallbackUrl);
                }
                if (options.SmsFallbackMethod.HasValue())
                {
                    request.AddParameter("SmsFallbackMethod", options.SmsFallbackMethod.ToString());
                }
            }

            ExecuteAsync <Application>(request, (response) => { callback(response); });
        }
Esempio n. 7
0
        /// <summary>
        /// Tries to update the application's properties, and returns the updated resource representation if successful.
        /// </summary>
        /// <param name="applicationSid">The Sid of the application to update</param>
        /// <param name="friendlyName">The friendly name to rename the application to (optional, null to leave as-is)</param>
        /// <param name="options">Which settings to update. Only properties with values set will be updated.</param>
        /// <param name="callback">Method to call upon successful completion</param>
        public virtual void UpdateApplication(string applicationSid, string friendlyName, ApplicationOptions options, Action <Application> callback)
        {
            Require.Argument("ApplicationSid", applicationSid);

            var request = new RestRequest(Method.POST);

            request.Resource = "Accounts/{AccountSid}/Applications/{ApplicationSid}.json";
            request.AddUrlSegment("ApplicationSid", applicationSid);

            if (friendlyName.HasValue())
            {
                request.AddParameter("FriendlyName", friendlyName);
            }
            if (options != null)
            {
                if (options.VoiceUrl != null)
                {
                    request.AddParameter("VoiceUrl", options.VoiceUrl);
                }
                if (options.VoiceMethod.HasValue())
                {
                    request.AddParameter("VoiceMethod", options.VoiceMethod.ToString());
                }
                if (options.VoiceFallbackUrl != null)
                {
                    request.AddParameter("VoiceFallbackUrl", options.VoiceFallbackUrl);
                }
                if (options.VoiceFallbackMethod.HasValue())
                {
                    request.AddParameter("VoiceFallbackMethod", options.VoiceFallbackMethod.ToString());
                }
                if (options.VoiceCallerIdLookup.HasValue)
                {
                    request.AddParameter("VoiceCallerIdLookup", options.VoiceCallerIdLookup.Value);
                }
                if (options.StatusCallback.HasValue())
                {
                    request.AddParameter("StatusCallback", options.StatusCallback);
                }
                if (options.StatusCallbackMethod.HasValue())
                {
                    request.AddParameter("StatusCallbackMethod", options.StatusCallbackMethod.ToString());
                }
                if (options.SmsUrl != null)
                {
                    request.AddParameter("SmsUrl", options.SmsUrl);
                }
                if (options.SmsMethod.HasValue())
                {
                    request.AddParameter("SmsMethod", options.SmsMethod.ToString());
                }
                if (options.SmsFallbackUrl != null)
                {
                    request.AddParameter("SmsFallbackUrl", options.SmsFallbackUrl);
                }
                if (options.SmsFallbackMethod.HasValue())
                {
                    request.AddParameter("SmsFallbackMethod", options.SmsFallbackMethod.ToString());
                }
            }

            ExecuteAsync <Application>(request, (response) => { callback(response); });
        }
        /// <summary>
        /// Tries to update the application's properties, and returns the updated resource representation if successful.
        /// </summary>
        /// <param name="applicationSid">The Sid of the application to update</param>
        /// <param name="friendlyName">The friendly name to rename the application to (optional, null to leave as-is)</param>
        /// <param name="options">Which settings to update. Only properties with values set will be updated.</param>
        /// <param name="callback">Method to call upon successful completion</param>
        public void UpdateApplication(string applicationSid, string friendlyName, ApplicationOptions options, Action<Application> callback)
        {
            Require.Argument("ApplicationSid", applicationSid);

            var request = new RestRequest(Method.POST);
            request.Resource = "Accounts/{AccountSid}/Applications/{ApplicationSid}";
            request.AddUrlSegment("ApplicationSid", applicationSid);
            request.RootElement = "Application";

            if (friendlyName.HasValue()) request.AddParameter("FriendlyName", friendlyName);
            if (options != null)
            {
                if (options.VoiceUrl != null) request.AddParameter("VoiceUrl", options.VoiceUrl);
                if (options.VoiceMethod.HasValue()) request.AddParameter("VoiceMethod", options.VoiceMethod.ToString());
                if (options.VoiceFallbackUrl != null) request.AddParameter("VoiceFallbackUrl", options.VoiceFallbackUrl);
                if (options.VoiceFallbackMethod.HasValue()) request.AddParameter("VoiceFallbackMethod", options.VoiceFallbackMethod.ToString());
                if (options.VoiceCallerIdLookup.HasValue) request.AddParameter("VoiceCallerIdLookup", options.VoiceCallerIdLookup.Value);
                if (options.StatusCallback.HasValue()) request.AddParameter("StatusCallbackUrl", options.StatusCallback);
                if (options.StatusCallbackMethod.HasValue()) request.AddParameter("StatusCallbackMethod", options.StatusCallbackMethod.ToString());
                if (options.SmsUrl != null) request.AddParameter("SmsUrl", options.SmsUrl);
                if (options.SmsMethod.HasValue()) request.AddParameter("SmsMethod", options.SmsMethod.ToString());
                if (options.SmsFallbackUrl != null) request.AddParameter("SmsFallbackUrl", options.SmsFallbackUrl);
                if (options.SmsFallbackMethod.HasValue()) request.AddParameter("SmsFallbackMethod", options.SmsFallbackMethod.ToString());
            }

            ExecuteAsync<Application>(request, (response) => { callback(response); });
        }
Esempio n. 9
0
        private async Task <Application> AddApplicationAsyncInternal(string friendlyName, ApplicationOptions options)
        {
            var request = new RestRequest();

            request.Method   = Method.POST;
            request.Resource = "Accounts/{AccountSid}/Applications.json";

            Require.Argument("FriendlyName", friendlyName);
            Validate.IsValidLength(friendlyName, 64);
            request.AddParameter("FriendlyName", friendlyName);

            // some check for null. in those cases an empty string is a valid value (to remove a URL assignment)
            if (options != null)
            {
                if (options.VoiceUrl != null)
                {
                    request.AddParameter("VoiceUrl", options.VoiceUrl);
                }
                if (options.VoiceMethod.HasValue())
                {
                    request.AddParameter("VoiceMethod", options.VoiceMethod.ToString());
                }
                if (options.VoiceFallbackUrl != null)
                {
                    request.AddParameter("VoiceFallbackUrl", options.VoiceFallbackUrl);
                }
                if (options.VoiceFallbackMethod.HasValue())
                {
                    request.AddParameter("VoiceFallbackMethod", options.VoiceFallbackMethod.ToString());
                }
                if (options.VoiceCallerIdLookup.HasValue)
                {
                    request.AddParameter("VoiceCallerIdLookup", options.VoiceCallerIdLookup.Value);
                }
                if (options.StatusCallback.HasValue())
                {
                    request.AddParameter("StatusCallback", options.StatusCallback);
                }
                if (options.StatusCallbackMethod.HasValue())
                {
                    request.AddParameter("StatusCallbackMethod", options.StatusCallbackMethod.ToString());
                }
                if (options.SmsUrl != null)
                {
                    request.AddParameter("SmsUrl", options.SmsUrl);
                }
                if (options.SmsMethod.HasValue())
                {
                    request.AddParameter("SmsMethod", options.SmsMethod.ToString());
                }
                if (options.SmsFallbackUrl != null)
                {
                    request.AddParameter("SmsFallbackUrl", options.SmsFallbackUrl);
                }
                if (options.SmsFallbackMethod.HasValue())
                {
                    request.AddParameter("SmsFallbackMethod", options.SmsFallbackMethod.ToString());
                }
            }

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

            return((Application)result);
        }
Esempio n. 10
0
 /// <summary>
 /// Create a new application
 /// </summary>
 /// <param name="friendlyName">The friendly name to name the application</param>
 /// <param name="options">Optional parameters to use when purchasing number</param>
 public IAsyncOperation <Application> AddApplicationAsync(string friendlyName, ApplicationOptions options)
 {
     return((IAsyncOperation <Application>)AsyncInfo.Run((System.Threading.CancellationToken ct) => AddApplicationAsyncInternal(friendlyName, options)));
 }
Esempio n. 11
0
        private async Task <Application> UpdateApplicationAsyncInternal(string applicationSid, string friendlyName, ApplicationOptions options)
        {
            Require.Argument("ApplicationSid", applicationSid);

            var request = new RestRequest();

            request.Method   = Method.POST;
            request.Resource = "Accounts/{AccountSid}/Applications/{ApplicationSid}.json";
            request.AddUrlSegment("ApplicationSid", applicationSid);

            if (friendlyName.HasValue())
            {
                request.AddParameter("FriendlyName", friendlyName);
            }
            if (options != null)
            {
                if (options.VoiceUrl != null)
                {
                    request.AddParameter("VoiceUrl", options.VoiceUrl);
                }
                if (options.VoiceMethod.HasValue())
                {
                    request.AddParameter("VoiceMethod", options.VoiceMethod.ToString());
                }
                if (options.VoiceFallbackUrl != null)
                {
                    request.AddParameter("VoiceFallbackUrl", options.VoiceFallbackUrl);
                }
                if (options.VoiceFallbackMethod.HasValue())
                {
                    request.AddParameter("VoiceFallbackMethod", options.VoiceFallbackMethod.ToString());
                }
                if (options.VoiceCallerIdLookup.HasValue)
                {
                    request.AddParameter("VoiceCallerIdLookup", options.VoiceCallerIdLookup.Value);
                }
                if (options.StatusCallback.HasValue())
                {
                    request.AddParameter("StatusCallback", options.StatusCallback);
                }
                if (options.StatusCallbackMethod.HasValue())
                {
                    request.AddParameter("StatusCallbackMethod", options.StatusCallbackMethod.ToString());
                }
                if (options.SmsUrl != null)
                {
                    request.AddParameter("SmsUrl", options.SmsUrl);
                }
                if (options.SmsMethod.HasValue())
                {
                    request.AddParameter("SmsMethod", options.SmsMethod.ToString());
                }
                if (options.SmsFallbackUrl != null)
                {
                    request.AddParameter("SmsFallbackUrl", options.SmsFallbackUrl);
                }
                if (options.SmsFallbackMethod.HasValue())
                {
                    request.AddParameter("SmsFallbackMethod", options.SmsFallbackMethod.ToString());
                }
            }

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

            return((Application)result);
        }
Esempio n. 12
0
		/// <summary>
		/// Create a new application
		/// </summary>
		/// <param name="friendlyName">The friendly name to name the application</param>
		/// <param name="options">Optional parameters to use when purchasing number</param>
        public IAsyncOperation<Application> AddApplicationAsync(string friendlyName, ApplicationOptions options)
        {
            return (IAsyncOperation<Application>)AsyncInfo.Run((System.Threading.CancellationToken ct) => AddApplicationAsyncInternal(friendlyName, options));
        }
Esempio n. 13
0
        private async Task<Application> UpdateApplicationAsyncInternal(string applicationSid, string friendlyName, ApplicationOptions options)
		{
			Require.Argument("ApplicationSid", applicationSid);

			var request = new RestRequest();
            request.Method = Method.POST;
			request.Resource = "Accounts/{AccountSid}/Applications/{ApplicationSid}.json";
			request.AddUrlSegment("ApplicationSid", applicationSid);
			
			if (friendlyName.HasValue()) request.AddParameter("FriendlyName", friendlyName);
			if (options != null)
			{
				if (options.VoiceUrl != null) request.AddParameter("VoiceUrl", options.VoiceUrl);
				if (options.VoiceMethod.HasValue()) request.AddParameter("VoiceMethod", options.VoiceMethod.ToString());
				if (options.VoiceFallbackUrl != null) request.AddParameter("VoiceFallbackUrl", options.VoiceFallbackUrl);
				if (options.VoiceFallbackMethod.HasValue()) request.AddParameter("VoiceFallbackMethod", options.VoiceFallbackMethod.ToString());
				if (options.VoiceCallerIdLookup.HasValue) request.AddParameter("VoiceCallerIdLookup", options.VoiceCallerIdLookup.Value);
				if (options.StatusCallback.HasValue()) request.AddParameter("StatusCallback", options.StatusCallback);
				if (options.StatusCallbackMethod.HasValue()) request.AddParameter("StatusCallbackMethod", options.StatusCallbackMethod.ToString());
				if (options.SmsUrl != null) request.AddParameter("SmsUrl", options.SmsUrl);
				if (options.SmsMethod.HasValue()) request.AddParameter("SmsMethod", options.SmsMethod.ToString());
				if (options.SmsFallbackUrl != null) request.AddParameter("SmsFallbackUrl", options.SmsFallbackUrl);
				if (options.SmsFallbackMethod.HasValue()) request.AddParameter("SmsFallbackMethod", options.SmsFallbackMethod.ToString());
			}

            var result = await ExecuteAsync(request, typeof(Application));
            return (Application)result;
		}