mollie / mollie-api-ruby

Mollie API client for Ruby
http://www.mollie.com
BSD 2-Clause "Simplified" License
81 stars 42 forks source link

undefined method `api_key' for nil:NilClass #76

Closed vernondegoede closed 6 years ago

vernondegoede commented 6 years ago

I'm experiencing some issues when initializing the client. I get the following error:

undefined method `api_key' for nil:NilClass

When I'm instantiating a new client:

def available_payment_methods
  puts get_preference(:api_key) # Prints an API key
  ::Mollie::Client.with_api_key(get_preference(:api_key)) # Throws an error
end

It seems like self.instance in client.rb doesn't return anything (both Thread.current['MOLLIE_CLIENT'] and configuration.inspect return nil).

You can check out my Gemfile.lock over here (might be useful): https://gist.github.com/vernondegoede/04b11753e71d70091e8899a3318fdc79

❯ ruby -v
ruby 2.2.7p470 (2017-03-28 revision 58194) [x86_64-darwin17]

Full stack trace: https://gist.github.com/vernondegoede/517c0483a2342936a0ed9f96e6e910c4

benoist commented 6 years ago

I see the with_api_key still requires a mollie configuration in an initializer. The configuration has no default yet.

So as a work around define in config/initializers/mollie.rb

Mollie::Client.configure do
end
vernondegoede commented 6 years ago

Perfect! Thanks.

benoist commented 6 years ago

I've added the patch to fix this

vernondegoede commented 6 years ago

Works like a charm. Thanks again.

benoist commented 6 years ago

@mvdpanne @Smitsel @vernondegoede any idea why travis is not releasing the gem?

vernondegoede commented 6 years ago

Seems like a permission issue while running dpl.3 on Travis.

mvdpanne commented 6 years ago

That is strange. The encrypted api_key that is present in .travis.yml will be regenerated to make sure it is set correctly. If you want the gem released within the next few hours, you might be better off doing it manually for now.

benoist commented 6 years ago

I don't have deploy rights for rubygems, so if someone can do that for me, that would be great!

mvdpanne commented 6 years ago

Pinging @Smitsel to deploy v3.1.3 to Rubygems.

Smitsel commented 6 years ago

Deployed v3.1.3 to Rubygems. Thanks guys.