Uh oh!
There was an error while loading. Please reload this page.
Respect Client API options - #27
Conversation
allcentury
commented
Oct 30, 2015
Hi @pat - Thanks for the PR! Can you talk to us a little more about your use case here? When we wrote the gem, we tried to take into account organizations and their sub organizations, is that the case you're trying to help with? If so, I'm curious if you considered something like: my_parent_og=Validic::Client.new(parent_org_options)my_other_org=Validic::Client.new(other_org_options) |
pat
commented
Oct 30, 2015
Hi Anthony - code like that is precisely what we're doing, but it wasn't using the options appropriately. client=Validic::Client.new(organization_id: our_org_id,access_token: our_access_token)# ignores the client's own value, uses Validic.organization_id, which is nil:client.provision_useruid: '1'# uses the specified organization id:client.provision_useruid: '1',organization_id: our_org_id |
pat
commented
Oct 30, 2015
The first |
allcentury
commented
Oct 30, 2015
Hi Pat - thank you for the quick reply, I can confirm we introduced this bug as part of PR #25 . Originally when we instantiated the client, we ran It worked as such: classClientdefinitialize(options={})@api_url=options[:api_url].nil? ? 'https://api.validic.com' : options[:api_url]@api_version=options[:api_version].nil? ? 'v1' : options[:api_version]@access_token=options[:access_token].nil? ? Validic.access_token : options[:access_token]@organization_id=options[:organization_id].nil? ? Validic.organization_id : options[:organization_id]reload_configend
...
defreload_configValidic.api_url=api_urlValidic.api_version=api_versionValidic.access_token=access_tokenValidic.organization_id=organization_idendendMoving that one line back appears to fix the problem though it does conflict with your PR since some of the code was removed. @jjlangholtz@markphelps I'm fine to do away with the @pat do you mind squashing your commits down for us? |
…eful when different client objects may be used with different credentials (thus, global defaults don't make sense). Seems this worked in 0.4.1, but has broken in more recent commits.
pat
commented
Oct 30, 2015
Squashed and force-pushed. |
markphelps
commented
Nov 1, 2015
lgtm. thanks @pat for the PR! |
allcentury
commented
Nov 2, 2015
Hi @pat - Your branch has the right ideas but unfortunately while the I've pushed up a hotfix that reenables the my_parent_og=Validic::Client.new(parent_org_options)my_other_org=Validic::Client.new(other_org_options)I would not pass the optional I'm going to leave this issue open until a more widespread fix is in place. |
This pull request rejigs the code slightly so that the options provided to a
Validic::Clientinstance (e.g. organization_id, access_token) are respected over the global defaults. If specific API requests use a custom organization_id or access_token as an option, then that takes priority over the client options.