-
Notifications
You must be signed in to change notification settings - Fork 2
Respect Client API options #27
base: master
Are you sure you want to change the base?
Conversation
|
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) |
|
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_user uid: '1'
# uses the specified organization id:
client.provision_user uid: '1', organization_id: our_org_id |
|
The first |
|
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: class Client
def initialize(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_config
end
...
def reload_config
Validic.api_url = api_url
Validic.api_version = api_version
Validic.access_token = access_token
Validic.organization_id = organization_id
end
endMoving 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.
|
Squashed and force-pushed. |
|
lgtm. thanks @pat for the PR! |
|
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.