Validic / validic

API Wrapper for Validic
https://validic.com
MIT License
0 stars 2 forks source link

api_url and api_version are not recognized when using configure #46

Closed jonaldomo closed 7 years ago

jonaldomo commented 7 years ago

api_url and api_version are not recognized when using configure.

they are however when passing options into the client constructor. i am writing a mock validic service for testing and would like to override the api_url with the configure method in an initializer.

so this would override the api_url and api_version:

options = {
  api_url:         'https://api.myurl.com',
  api_version:     'v3',
  access_token:    'ORGANIZATION_ACCESS_TOKEN',
  organization_id: 'ORGANIZATION_ID'
}
client = Validic::Client.new(options)

but this would not, even though the docs would imply it would. additionally, it is how i would prefer to configure it.

Validic.configure do |config|
  config.api_url          = 'https://api.myurl.com'
  config.api_version      = 'v3'
  config.access_token     = 'ORGANIZATION_ACCESS_TOKEN'
  config.organization_id  = 'ORGANIZATION_ID'
end
allcentury commented 7 years ago

@jonaldomo Thanks for reporting this. I can confirm that using a block does not allow you override either of those values:

[1] pry(main)> require 'validic'
=> true
[2] pry(main)> Validic.configure { |c| c.access_token = 'abc'; c.organization_id = '123'; c.api_url = 'https://something.org' }
=> true
[3] pry(main)> Validic::Client.new
=> #<Validic::Client:0x007fa4fa874be0 @access_token="abc", @api_url="https://api.validic.com", @api_version="v1", @organization_id="123">

We made the .configure method for convenience but thinking through this more and seeing other issues (like PR #27), I think we have confused users of the gem more than helped.