twilio / twilio-ruby

A Ruby gem for communicating with the Twilio API and generating TwiML
MIT License
1.35k stars 463 forks source link

Usage method missing from Twilio::REST::Client #677

Closed willdebernardi closed 3 months ago

willdebernardi commented 10 months ago

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:

jgadbois commented 9 months ago

I encountered the same issue

jamesr2323 commented 3 months ago

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)

manisha1997 commented 3 months ago

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