Created
January 9, 2010 23:27
-
-
Save cloudvoxcode/273194 to your computer and use it in GitHub Desktop.
Cloudvox call history export to CSV sample
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
#!/usr/bin/ruby | |
require 'rubygems' | |
require 'httparty' | |
# basic Cloudvox call history to CSV example | |
# see http://help.cloudvox.com/faqs/provisioning/call-history | |
class CallDetailRecords | |
include HTTParty | |
format :json | |
base_uri 'https://your.cloudvox.com' | |
basic_auth 'my@account.com', 'password' | |
end | |
query = { | |
'start' => (Time.now-86400*365).to_i, | |
'end' => Time.now.to_i | |
} | |
cdrs = CallDetailRecords.get('/call_detail_records.json', :query => query) | |
open('cdrs.csv', 'a+') do |io| | |
io.write("Date,Seconds,Source\n") | |
cdrs.each do |cdr| | |
cdr = cdr['call_detail_record'] | |
io.write "\"#{cdr['calldate']}\",#{cdr['billsec']},#{cdr['src']},\"#{cdr['remote_location']}\"\n" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment