twilio-ruby
twilio-ruby copied to clipboard
Usage method missing from Twilio::REST::Client
Issue Summary
At some point, the usage method appears to have been removed from the REST client. The Twilio docs still reflect the apparently deprecated method. However, the alternate method of @client.api.v2010.usage.records.last_month.list(limit: 5)
still works.
https://www.twilio.com/docs/usage/api/usage-record
Steps to Reproduce
- Follow Twilio docs example
Code Snippet
# Download the helper library from https://www.twilio.com/docs/ruby/install
require 'rubygems'
require 'twilio-ruby'
# Find your Account SID and Auth Token at twilio.com/console
# and set the environment variables. See http://twil.io/secure
account_sid = ENV['TWILIO_ACCOUNT_SID']
auth_token = ENV['TWILIO_AUTH_TOKEN']
@client = Twilio::REST::Client.new(account_sid, auth_token)
last_month = @client.usage.records.last_month.list(limit: 20)
last_month.each do |record|
puts record.as_of
end
Exception/Log
NoMethodError: undefined method `usage' for #<Twilio::REST::Client:0x000055f528d91908>
Technical details:
- twilio-ruby version: 6.6.0
- ruby version: 2.6.10
I encountered the same issue
We have also encountered the same issue and are using the @client.api.v2010.usage
workaround (twilio-ruby 7.0.0, ruby 3.2.0)
This has already been informed to the doc team, the change should reflect in some time.