Ejemplo n.º 1
0
        public Account CreateSubAccount(String friendlyName)
        {
            _parameters.Clear();
            _parameters.Add("FriendlyName", friendlyName);

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

            var twilioAccount = new Account {
                sid = data.sid,
                friendly_name = data.friendly_name,
                status = data.status,
                auth_token = data.auth_token,
                date_created = Convert.ToDateTime(data.date_created),
                date_updated = Convert.ToDateTime(data.date_updated),
                type = data.type,
                uri = data.uri
            };

            var subresourceUri = new SubresourceUri {
                available_phone_numbers = data.subresource_uris.available_phone_numbers,
                calls = data.subresource_uris.calls,
                conferences = data.subresource_uris.conferences,
                incoming_phone_numbers = data.subresource_uris.incoming_phone_numbers,
                notifications = data.subresource_uris.notifications,
                outgoing_caller_ids = data.subresource_uris.outgoing_caller_ids,
                recordings = data.subresource_uris.recordings,
                sandbox = data.subresource_uris.sandbox,
                sms_messages = data.subresource_uris.sms_messages,
                transcriptions = data.subresource_uris.transcriptions
            };

            twilioAccount.subresource_uris = subresourceUri;

            return twilioAccount;
        }
Ejemplo n.º 2
0
        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;
        }