Пример #1
0
        public void ShouldChangeSubAccountStatus()
        {
            var client  = new TwilioRestClient(Credentials.AccountSid, Credentials.AuthToken);
            var account = client.CreateSubAccount(Utilities.MakeRandomFriendlyName());
            var result  = client.ChangeSubAccountStatus(account.Sid, AccountStatus.Suspended);

            Assert.IsNotNull(result);
            Assert.IsNull(result.RestException);
            Assert.AreEqual(AccountStatus.Suspended.ToString().ToLower(), result.Status);

            client.ChangeSubAccountStatus(account.Sid, AccountStatus.Closed); //cleanup
        }
 static void Main(string[] args)
 {
     // Find your Account Sid and Auth Token at twilio.com/user/account
     string  AccountSid           = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
     string  AccountSidToActivate = "ACxxxxxxxxxxxxxxxxxxx";
     string  AuthToken            = "your_auth_token";
     var     twilio  = new TwilioRestClient(AccountSid, AuthToken);
     Account account = twilio.ChangeSubAccountStatus(AccountSidToActivate, Twilio.AccountStatus.Active);
 }
Пример #3
0
 static void Main(string[] args)
 {
     // Find your Account Sid and Auth Token at twilio.com/user/account
     string  AccountSid        = "{{ account_sid }}";
     string  AccountSidToClose = "ACxxxxxxxxxxxxxxxxxxx";
     string  AuthToken         = "{{ auth_token }}";
     var     twilio            = new TwilioRestClient(AccountSid, AuthToken);
     Account account           = twilio.ChangeSubAccountStatus(AccountSidToClose, Twilio.AccountStatus.Closed);
 }
Пример #4
0
        public void ShouldCreateSubAccount()
        {
            var client = new TwilioRestClient(Credentials.AccountSid, Credentials.AuthToken);
            var result = client.CreateSubAccount(Utilities.MakeRandomFriendlyName());

            Assert.IsNotNull(result);
            Assert.IsNull(result.RestException);
            Assert.IsNotNull(result.Sid);

            client.ChangeSubAccountStatus(result.Sid, AccountStatus.Closed); //cleanup
        }
Пример #5
0
        public void ShouldGetSubAccount()
        {
            var client = new TwilioRestClient(Credentials.AccountSid, Credentials.AuthToken);
            var account = client.CreateSubAccount(Utilities.MakeRandomFriendlyName());

            var result = client.GetAccount(account.Sid);

            Assert.IsNotNull(result);
            Assert.IsNull(result.RestException);
            Assert.AreEqual(account.Sid, result.Sid);

            client.ChangeSubAccountStatus(account.Sid, AccountStatus.Closed); //cleanup
        }
Пример #6
0
        public void ShouldChangeSubAccountStatusAsynchronously()
        {
            manualResetEvent = new ManualResetEvent(false);

            var client          = new TwilioRestClient(Credentials.AccountSid, Credentials.AuthToken);
            var originalAccount = client.CreateSubAccount(Utilities.MakeRandomFriendlyName());

            Account result = null;

            client.ChangeSubAccountStatus(originalAccount.Sid, AccountStatus.Suspended, account =>
            {
                result = account;
                manualResetEvent.Set();
            });

            manualResetEvent.WaitOne();

            Assert.IsNotNull(result);
            Assert.IsNull(result.RestException);
            Assert.AreEqual(AccountStatus.Suspended.ToString().ToLower(), result.Status);

            client.ChangeSubAccountStatus(originalAccount.Sid, AccountStatus.Closed); //cleanup
        }
Пример #7
0
        public void ShouldCreateSubAccountAsynchronously()
        {
            manualResetEvent = new ManualResetEvent(false);

            var client = new TwilioRestClient(Credentials.AccountSid, Credentials.AuthToken);

            Account result = null;

            client.CreateSubAccount(Utilities.MakeRandomFriendlyName(), account =>
            {
                result = account;
                manualResetEvent.Set();
            });

            manualResetEvent.WaitOne();

            Assert.IsNotNull(result);
            Assert.IsNull(result.RestException);
            Assert.IsNotNull(result.Sid);

            client.ChangeSubAccountStatus(result.Sid, AccountStatus.Closed); //cleanup
        }
Пример #8
0
        public void ShouldGetSubAccountAsynchronously()
        {
            manualResetEvent = new ManualResetEvent(false);

            var client = new TwilioRestClient(Credentials.AccountSid, Credentials.AuthToken);
            var originalAccount = client.CreateSubAccount(Utilities.MakeRandomFriendlyName());

            Account result = null;
            client.GetAccount(originalAccount.Sid, account =>
            {
                result = account;
                manualResetEvent.Set();
            });

            manualResetEvent.WaitOne();

            Assert.IsNotNull(result);
            Assert.IsNull(result.RestException);
            Assert.AreEqual(originalAccount.Sid, result.Sid);

            client.ChangeSubAccountStatus(result.Sid, AccountStatus.Closed); //cleanup
        }