twilio.sugar.Model.PhoneAutomation.GetSubAccounts C# (CSharp) Method

GetSubAccounts() public method

public GetSubAccounts ( ) : IList
return IList
        public IList<Account> GetSubAccounts()
        {
            _parameters.Clear();

            _twilioResponse = _account.request("Accounts.json", "GET", _parameters);
            dynamic data = ParseResponseData(_twilioResponse);

            IList<Account> accounts = new List<Account>();

            foreach (dynamic item in data.accounts)
            {
                var acct = new Account
                {
                    sid = item.sid,
                    friendly_name = item.friendly_name,
                    status = item.status,
                    auth_token = item.auth_token,
                    date_created = Convert.ToDateTime(item.date_created),
                    date_updated = Convert.ToDateTime(item.date_updated),
                    type = item.type,
                    uri = item.uri
                };
                var subresourceUri = new SubresourceUri
                {
                    available_phone_numbers = item.subresource_uris.available_phone_numbers,
                    calls = item.subresource_uris.calls,
                    conferences = item.subresource_uris.conferences,
                    incoming_phone_numbers = item.subresource_uris.incoming_phone_numbers,
                    notifications = item.subresource_uris.notifications,
                    outgoing_caller_ids = item.subresource_uris.outgoing_caller_ids,
                    recordings = item.subresource_uris.recordings,
                    sandbox = item.subresource_uris.sandbox,
                    sms_messages = item.subresource_uris.sms_messages,
                    transcriptions = item.subresource_uris.transcriptions
                };

                acct.subresource_uris = subresourceUri;

                accounts.Add(acct);
            }

            return accounts;
        }

Usage Example

コード例 #1
0
        public void GetSubAccountsReturnsAccountListResource()
        {
            var account = new TwilioAccountMock();
            var phoneAutomation = new PhoneAutomation(account);
            var accounts = phoneAutomation.GetSubAccounts();

            Assert.IsNotNull(accounts);
        }