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 trigger = twilio.CreateUsageTrigger("sms", "1000", "http://www.example.com/"); Console.WriteLine(trigger.Sid); }
public void ShouldCreateNewUsageTrigger() { var client = new TwilioRestClient(Credentials.AccountSid, Credentials.AuthToken); UsageTriggerOptions options = new UsageTriggerOptions() { FriendlyName = "ShouldCreateNewUsageTrigger" }; var result = client.CreateUsageTrigger(options); Assert.IsNotNull(result); Assert.IsNull(result.RestException); Assert.IsNotNull(result.Sid); client.DeleteQueue(result.Sid); //cleanup }
public void ShouldDeleteUsageTrigger() { var client = new TwilioRestClient(Credentials.AccountSid, Credentials.AuthToken); UsageTriggerOptions options = new UsageTriggerOptions() { FriendlyName = "ShouldDeleteUsageTrigger" }; var originalUsageTrigger = client.CreateUsageTrigger(options); var status = client.DeleteQueue(originalUsageTrigger.Sid); Assert.AreEqual(DeleteStatus.Success, status); }
public void ShouldUpdateUsageTrigger() { var client = new TwilioRestClient(Credentials.AccountSid, Credentials.AuthToken); UsageTriggerOptions options = new UsageTriggerOptions() { FriendlyName = "ShouldUpdateUsageTrigger" }; var originalUsageTrigger = client.CreateUsageTrigger(options); var usagetriggersid = originalUsageTrigger.Sid; var result = client.UpdateUsageTrigger(usagetriggersid, "ShouldUpdateUsageTriggerUpdated", null, null); Assert.IsNotNull(result); Assert.IsNull(result.RestException); Assert.AreEqual("ShouldUpdateUsageTriggerUpdated", result.FriendlyName); client.DeleteQueue(usagetriggersid); //cleanup }
private void CreateTrigger() { var client = new TwilioRestClient(Credentials.AccountSid, Credentials.AuthToken); var trigger = client.CreateUsageTrigger(new UsageTriggerOptions() { UsageCategory = "sms-inbound", FriendlyName = "Chapter13Trigger", TriggerBy = "usage", TriggerValue = "+3", CallbackUrl = Url.ActionAbsolute("TriggerCallbackHandler") }); if (trigger.RestException != null) { Console.WriteLine(trigger.RestException.Message); } }