0

I'm using the following example given in the api docs for twilio-ruby.

http://www.twilio.com/docs/api/rest/usage-records#list-get-example-3

# twilio-ruby install docs at twilio.com/docs/ruby/install
require 'rubygems'          # This line not needed for ruby > 1.8
require 'twilio-ruby'

# Get your Account Sid and Auth Token from twilio.com/user/account 
account_sid = 'AC32a3c49700934481addd5ce1659f04d2'
auth_token = '{{ auth_token }}'
@client = Twilio::REST::Client.new account_sid, auth_token

# Loop over records and print out a property for each one
@client.account.usage.records.list({
  :category => "calls-inbound",
  :start_date => "2012-09-01",
  :end_date => "2012-09-30"}).each do |record|
  puts record.sid
end

(I am swapping out the proper credentials, and have set dates to those where I have inbound calls).

I am getting

NoMethodError: undefined method `sid' for #<Twilio::REST::Record:0x007f8f2c94c948>

If I remove the call to .sid and inspect the response I get the following

[<Twilio::REST::Record @uri=/2010-04-01/Accounts/ACxxxxxxxxxxxxxxxxxxxx/Usage/Records/>]

So basically an array with one member with a uri property.

So. why is the initial example not working and what can I do with the response if not call .sid on it?

Thanks in advance.

1 Answer 1

2

The API documentation is wrong on the site.

# twilio-ruby install docs at twilio.com/docs/ruby/install
require 'rubygems'          # This line not needed for ruby > 1.8
require 'twilio-ruby'

# Get your Account Sid and Auth Token from twilio.com/user/account 
account_sid = 'AC32a3c49700934481addd5ce1659f04d2'
auth_token = '{{ auth_token }}'
@client = Twilio::REST::Client.new account_sid, auth_token


# Loop over records and print out a property for each one
@client.account.usage.records.today.list.each do |record|
    puts record.category + ' : ' + record.usage
end

For reference: https://github.com/twilio/twilio-ruby/issues/52

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.