Exemplo n.º 1
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
        }
    static void Main(string[] args)
    {
        // Find your Account Sid and Auth Token at twilio.com/user/account
        string AccountSid = "{{ account_sid }}";
        string AuthToken  = "{{ auth_token }}";
        var    twilio     = new TwilioRestClient(AccountSid, AuthToken);


        var account = twilio.CreateSubAccount("Submarine");

        Console.WriteLine(account.Sid);
    }
Exemplo n.º 3
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
        }
Exemplo n.º 4
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
        }
Exemplo n.º 5
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
        }
Exemplo n.º 6
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
        }
Exemplo n.º 7
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
        }