twilio-ruby icon indicating copy to clipboard operation
twilio-ruby copied to clipboard

Usage method missing from Twilio::REST::Client

Open willdebernardi opened this issue 1 year ago • 1 comments

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

  1. 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

willdebernardi avatar Sep 15 '23 19:09 willdebernardi

I encountered the same issue

jgadbois avatar Oct 04 '23 19:10 jgadbois

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)

jamesr2323 avatar Apr 03 '24 13:04 jamesr2323

This has already been informed to the doc team, the change should reflect in some time.

manisha1997 avatar Apr 04 '24 09:04 manisha1997