chargebee / chargebee-ruby

Ruby library for the Chargebee API.
https://apidocs.chargebee.com/docs/api?lang=ruby
MIT License
32 stars 60 forks source link

NoMethodError (undefined method `encode' for URI:Module) #54

Closed bjacobson26 closed 3 years ago

bjacobson26 commented 3 years ago

Ruby version: 3.0.0

URI.encode removed in Ruby 3.

irb(main):001:0> URI.encode
Traceback (most recent call last):
        4: from /Users/bojacobson/.rbenv/versions/3.0.0/bin/irb:23:in `<main>'
        3: from /Users/bojacobson/.rbenv/versions/3.0.0/bin/irb:23:in `load'
        2: from /Users/bojacobson/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/irb-1.3.0/exe/irb:11:in `<top (required)>'
        1: from (irb):1:in `<main>'
NoMethodError (undefined method `encode' for URI:Module)
Chargebee::Subscription.retreive("subscription-id")

=> NoMethodError (undefined method `encode' for URI:Module)

here is the culprit: https://github.com/chargebee/chargebee-ruby/commit/b9b6a69d1338f7d49f730b9df65d0335822d7b05#diff-c9a289b8798c75c2b395c35fb0b44ec0a272ab762005e9bc3b259140035874f3R59

I was able to fix this by defining the URI.encode:

module URI
  def self.encode(string)
    return URI.encode_www_form_component(string)
  end
end
bjacobson26 commented 3 years ago

duplicate: https://github.com/chargebee/chargebee-ruby/pull/49