Beispiel #1
0
        /// <summary>
        /// Creates a new Usage Trigger resource
        /// </summary>
        /// <param name="options">A UsageTriggerOption object that defines the different trigger options</param>
        /// <returns></returns>
        public UsageTrigger CreateUsageTrigger(UsageTriggerOptions options)
        {
            Require.Argument("UsageCategory", options.UsageCategory);
            Require.Argument("TriggerValue", options.TriggerValue);
            Require.Argument("CallbackUrl", options.CallbackUrl);

            var request = new RestRequest();

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

            request.Method = Method.POST;

            request.AddParameter("UsageCategory", options.UsageCategory);
            request.AddParameter("TriggerValue", options.TriggerValue);
            request.AddParameter("CallbackUrl", options.CallbackUrl);

            if (!string.IsNullOrEmpty(options.CallbackMethod))
            {
                request.AddParameter("CallbackMethod", options.CallbackMethod);
            }
            if (!string.IsNullOrEmpty(options.FriendlyName))
            {
                request.AddParameter("FriendlyName", options.FriendlyName);
            }
            if (!string.IsNullOrEmpty(options.Recurring))
            {
                request.AddParameter("Recurring", options.Recurring);
            }
            if (!string.IsNullOrEmpty(options.TriggerBy))
            {
                request.AddParameter("TriggerBy", options.TriggerBy);
            }

            return(Execute <UsageTrigger>(request));
        }
Beispiel #2
0
        /// <summary>
        /// Creates a new Usage Trigger resource
        /// </summary>
        /// <param name="usageCategory">The usage category to trigger on</param>
        /// <param name="triggerValue">The the value to trigger on</param>
        /// <param name="callbackUrl">The URL to call once a trigger value has been met</param>
        /// <param name="callback"></param>
        /// <returns></returns>
        public virtual void CreateUsageTrigger(string usageCategory, string triggerValue, string callbackUrl, Action<UsageTrigger> callback)
        {
            var options = new UsageTriggerOptions();
            options.UsageCategory = usageCategory;
            options.TriggerValue = triggerValue;
            options.CallbackUrl = callbackUrl;

            CreateUsageTrigger(options, callback);
        }
Beispiel #3
0
        /// <summary>
        /// Creates a new Usage Trigger resource
        /// </summary>
        /// <param name="usageCategory">The usage category to trigger on</param>
        /// <param name="triggerValue">The value to trigger on</param>
        /// <param name="callbackUrl">The URL to call once a trigger value has been met</param>
        /// <returns></returns>
        public virtual UsageTrigger CreateUsageTrigger(string usageCategory, string triggerValue, string callbackUrl)
        {
            var options = new UsageTriggerOptions();
            options.UsageCategory = usageCategory;
            options.TriggerValue = triggerValue;
            options.CallbackUrl = callbackUrl;

            return CreateUsageTrigger(options);
        }
Beispiel #4
0
        /// <summary>
        /// Creates a new Usage Trigger resource
        /// </summary>
        /// <param name="usageCategory">The usage category to trigger on</param>
        /// <param name="triggerValue">The the value to trigger on</param>
        /// <param name="callbackUrl">The URL to call once a trigger value has been met</param>
        /// <returns></returns>
        public UsageTrigger CreateUsageTrigger(string usageCategory, string triggerValue, string callbackUrl)
        {
            var options = new UsageTriggerOptions();

            options.UsageCategory = usageCategory;
            options.TriggerValue  = triggerValue;
            options.CallbackUrl   = callbackUrl;

            return(CreateUsageTrigger(options));
        }
Beispiel #5
0
        /// <summary>
        /// Creates a new Usage Trigger resource
        /// </summary>
        /// <param name="usageCategory">The usage category to trigger on</param>
        /// <param name="triggerValue">The the value to trigger on</param>
        /// <param name="callbackUrl">The URL to call once a trigger value has been met</param>
        /// <param name="callback"></param>
        /// <returns></returns>
        public void CreateUsageTrigger(string usageCategory, string triggerValue, string callbackUrl, Action <UsageTrigger> callback)
        {
            var options = new UsageTriggerOptions();

            options.UsageCategory = usageCategory;
            options.TriggerValue  = triggerValue;
            options.CallbackUrl   = callbackUrl;

            CreateUsageTrigger(options, callback);
        }
Beispiel #6
0
        /// <summary>
        /// Creates a new Usage Trigger resource
        /// </summary>
        /// <param name="usageCategory">The usage category to trigger on</param>
        /// <param name="triggerValue">The value to trigger on</param>
        /// <param name="callbackUrl">The URL to call once a trigger value has been met</param>
        /// <returns></returns>
        public virtual async Task <UsageTrigger> CreateUsageTriggerAsync(string usageCategory, string triggerValue, string callbackUrl)
        {
            var options = new UsageTriggerOptions();

            options.UsageCategory = usageCategory;
            options.TriggerValue  = triggerValue;
            options.CallbackUrl   = callbackUrl;

            return(await CreateUsageTriggerAsync(options));
        }
Beispiel #7
0
        /// <summary>
        /// Creates a new Usage Trigger resource
        /// </summary>
        /// <param name="options">A UsageTriggerOption object that defines the different trigger options</param>
        /// <param name="callback"></param>
        /// <returns></returns>
        public virtual void CreateUsageTrigger(UsageTriggerOptions options, Action<UsageTrigger> callback)
        {
            Require.Argument("UsageCategory", options.UsageCategory);
            Require.Argument("TriggerValue", options.TriggerValue);
            Require.Argument("CallbackUrl", options.CallbackUrl);

            var request = new RestRequest();
            request.Resource = "Accounts/{AccountSid}/Usage/Triggers.json";

            request.Method = Method.POST;

            request.AddParameter("UsageCategory", options.UsageCategory);
            request.AddParameter("TriggerValue", options.TriggerValue);
            request.AddParameter("CallbackUrl", options.CallbackUrl);

            if (!string.IsNullOrEmpty(options.CallbackMethod)) { request.AddParameter("CallbackMethod", options.CallbackMethod); }
            if (!string.IsNullOrEmpty(options.FriendlyName)) { request.AddParameter("FriendlyName", options.FriendlyName); }
            if (!string.IsNullOrEmpty(options.Recurring)) { request.AddParameter("Recurring", options.Recurring); }
            if (!string.IsNullOrEmpty(options.TriggerBy)) { request.AddParameter("TriggerBy", options.TriggerBy); }

            ExecuteAsync<UsageTrigger>(request, response => callback(response));
        }
Beispiel #8
0
        private async Task <UsageTrigger> CreateUsageTriggerAsyncInternal(UsageTriggerOptions options)
        {
            Require.Argument("UsageCategory", options.UsageCategory);
            Require.Argument("TriggerValue", options.TriggerValue);
            Require.Argument("CallbackUrl", options.CallbackUrl);

            var request = new RestRequest();

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

            request.Method = Method.POST;

            request.AddParameter("UsageCategory", options.UsageCategory);
            request.AddParameter("TriggerValue", options.TriggerValue);
            request.AddParameter("CallbackUrl", options.CallbackUrl);

            if (!string.IsNullOrEmpty(options.CallbackMethod))
            {
                request.AddParameter("CallbackMethod", options.CallbackMethod);
            }
            if (!string.IsNullOrEmpty(options.FriendlyName))
            {
                request.AddParameter("FriendlyName", options.FriendlyName);
            }
            if (!string.IsNullOrEmpty(options.Recurring))
            {
                request.AddParameter("Recurring", options.Recurring);
            }
            if (!string.IsNullOrEmpty(options.TriggerBy))
            {
                request.AddParameter("TriggerBy", options.TriggerBy);
            }

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

            return((UsageTrigger)result);
        }
        /// <summary>
        /// Creates a new Usage Trigger resource
        /// </summary>
        /// <param name="options">A UsageTriggerOption object that defines the different trigger options</param>
        /// <param name="callback"></param>
        /// <returns></returns>
        public virtual void CreateUsageTrigger(UsageTriggerOptions options, Action <UsageTrigger> callback)
        {
            Require.Argument("UsageCategory", options.UsageCategory);
            Require.Argument("TriggerValue", options.TriggerValue);
            Require.Argument("CallbackUrl", options.CallbackUrl);

            var request = new RestRequest();

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

            //request.Method = Method.POST;
            request.Method = "POST";

            request.AddParameter("UsageCategory", options.UsageCategory);
            request.AddParameter("TriggerValue", options.TriggerValue);
            request.AddParameter("CallbackUrl", options.CallbackUrl);

            if (!string.IsNullOrEmpty(options.CallbackMethod))
            {
                request.AddParameter("CallbackMethod", options.CallbackMethod);
            }
            if (!string.IsNullOrEmpty(options.FriendlyName))
            {
                request.AddParameter("FriendlyName", options.FriendlyName);
            }
            if (!string.IsNullOrEmpty(options.Recurring))
            {
                request.AddParameter("Recurring", options.Recurring);
            }
            if (!string.IsNullOrEmpty(options.TriggerBy))
            {
                request.AddParameter("TriggerBy", options.TriggerBy);
            }

            ExecuteAsync <UsageTrigger>(request, response => callback(response));
        }
Beispiel #10
0
        private async Task<UsageTrigger> CreateUsageTriggerAsyncInternal(UsageTriggerOptions options)
        {
            Require.Argument("UsageCategory", options.UsageCategory);
            Require.Argument("TriggerValue", options.TriggerValue);
            Require.Argument("CallbackUrl", options.CallbackUrl);

            var request = new RestRequest();
            request.Resource = "Accounts/{AccountSid}/Usage/Triggers.json";

            request.Method = Method.POST;

            request.AddParameter("UsageCategory", options.UsageCategory);
            request.AddParameter("TriggerValue", options.TriggerValue);
            request.AddParameter("CallbackUrl", options.CallbackUrl);

            if (!string.IsNullOrEmpty(options.CallbackMethod)) { request.AddParameter("CallbackMethod", options.CallbackMethod); }
            if (!string.IsNullOrEmpty(options.FriendlyName)) { request.AddParameter("FriendlyName", options.FriendlyName); }
            if (!string.IsNullOrEmpty(options.Recurring)) { request.AddParameter("Recurring", options.Recurring); }
            if (!string.IsNullOrEmpty(options.TriggerBy)) { request.AddParameter("TriggerBy", options.TriggerBy); }

            var result = await ExecuteAsync(request, typeof(UsageTrigger));
            return (UsageTrigger)result;
        }
Beispiel #11
0
 /// <summary>
 /// Creates a new Usage Trigger resource
 /// </summary>
 /// <param name="options">A UsageTriggerOption object that defines the different trigger options</param>
 /// <returns></returns>
 public IAsyncOperation<UsageTrigger> CreateUsageTriggerAsync(UsageTriggerOptions options)
 {
     return (IAsyncOperation<UsageTrigger>)AsyncInfo.Run((System.Threading.CancellationToken ct) => CreateUsageTriggerAsyncInternal(options));
 }
Beispiel #12
0
 /// <summary>
 /// Creates a new Usage Trigger resource
 /// </summary>
 /// <param name="options">A UsageTriggerOption object that defines the different trigger options</param>
 /// <returns></returns>
 public IAsyncOperation <UsageTrigger> CreateUsageTriggerAsync(UsageTriggerOptions options)
 {
     return((IAsyncOperation <UsageTrigger>)AsyncInfo.Run((System.Threading.CancellationToken ct) => CreateUsageTriggerAsyncInternal(options)));
 }
Beispiel #13
0
        /// <summary>
        /// Creates a new Usage Trigger resource
        /// </summary>
        /// <param name="options">A UsageTriggerOption object that defines the different trigger options</param>
        /// <returns></returns>
        public virtual async Task<UsageTrigger> CreateUsageTriggerAsync(UsageTriggerOptions options)
        {
            Require.Argument("UsageCategory", options.UsageCategory);
            Require.Argument("TriggerValue", options.TriggerValue);
            Require.Argument("CallbackUrl", options.CallbackUrl);

            var request = new RestRequest();
            request.Resource = "Accounts/{AccountSid}/Usage/Triggers.json";

            //request.Method = Method.POST;
            request.Method = "POST";

            request.AddParameter("UsageCategory", options.UsageCategory);
            request.AddParameter("TriggerValue", options.TriggerValue);
            request.AddParameter("CallbackUrl", options.CallbackUrl);

            if (!string.IsNullOrEmpty(options.CallbackMethod)) { request.AddParameter("CallbackMethod",options.CallbackMethod); }
            if (!string.IsNullOrEmpty(options.FriendlyName)) { request.AddParameter("FriendlyName",options.FriendlyName); }
            if (!string.IsNullOrEmpty(options.Recurring)) { request.AddParameter("Recurring",options.Recurring); }
            if (!string.IsNullOrEmpty(options.TriggerBy)) { request.AddParameter("TriggerBy",options.TriggerBy); }

            return await Execute<UsageTrigger>(request);
        }
Beispiel #14
0
        /// <summary>
        /// Creates a new Usage Trigger resource
        /// </summary>
        /// <param name="usageCategory">The usage category to trigger on</param>
        /// <param name="triggerValue">The value to trigger on</param>
        /// <param name="callbackUrl">The URL to call once a trigger value has been met</param>
        /// <returns></returns>
        public virtual async Task<UsageTrigger> CreateUsageTriggerAsync(string usageCategory, string triggerValue, string callbackUrl)
        {
            var options = new UsageTriggerOptions();
            options.UsageCategory = usageCategory;
            options.TriggerValue = triggerValue;
            options.CallbackUrl = callbackUrl;

            return await CreateUsageTriggerAsync(options);
        }