Created
September 1, 2016 21:31
-
-
Save choppen5/d01233a2c00dbcc78fa1bb52a1deb770 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' # not necessary with ruby 1.9 but included for completeness | |
require 'twilio-ruby' | |
# put your own credentials here | |
account_sid = 'ACxx' | |
auth_token = 'xx' | |
# set up a client | |
@client = Twilio::REST::Client.new(account_sid, auth_token) | |
@account = @client.account | |
totalaccounts = 0 #total subaccoutns we go through | |
subaccounts = @client.accounts.list | |
begin | |
subaccounts.each do |subaccount| | |
friendly_name = subaccount.friendly_name | |
totalaccounts = totalaccounts +1 | |
if subaccount.status == "active" | |
#puts "getting subaccount #{friendly_name} #{subaccount.sid}, #{subaccount.auth_token}, #{subaccount.status}" | |
@subaccountclient = Twilio::REST::Client.new subaccount.sid, subaccount.auth_token | |
calls = @subaccountclient.account.calls.list( "start_time>" => '2016-08-30', "start_time<" => '2016-08-31') | |
begin | |
calls.each do |call| | |
puts call.account_sid + "," + friendly_name + "," + call.start_time + "," + call.status + "," + call.sid | |
end | |
calls = calls.next_page | |
end while not calls.empty? | |
end #if acttive | |
end | |
subaccounts = subaccounts.next_page | |
end while not subaccounts.empty? | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment