Skip to content

Instantly share code, notes, and snippets.

@cloudvoxcode
Created January 9, 2010 23:27
Show Gist options
  • Save cloudvoxcode/273194 to your computer and use it in GitHub Desktop.
Save cloudvoxcode/273194 to your computer and use it in GitHub Desktop.
Cloudvox call history export to CSV sample
#!/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