Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

query opts doesn't work without id #2

Open
wyefei opened this issue Sep 17, 2014 · 1 comment
Open

query opts doesn't work without id #2

wyefei opened this issue Sep 17, 2014 · 1 comment

Comments

@wyefei
Copy link

wyefei commented Sep 17, 2014

gh_client.offices(id, page: 1, per_page: 2) works but gh_client.offices(page: 1, per_page: 2) failed with error:
/Users/yefeiwang/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/uri/common.rb:176:in split': bad URI(is not URI?): /candidates/{:page=>1, :per_page=>200} (URI::InvalidURIError)`

@capablemonkey
Copy link
Contributor

Hey @wyefei,

Gee, it's been a while since you've posted this. Sorry about that, and thanks for sharing!

@adrianbautista kindly transferred this repo over to Greenhouse, so we'll be maintaining this gem from now on.

I can confirm this is an issue. It's not possible to call GreenhouseIo::Client#jobs with only an options hash, since it would set the id default parameter instead of the options parameter.

def jobs(id = nil, options = {})
      get_from_harvest_api "/jobs#{path_id(id)}", options
end

However, if you pass in nil for the id, it should work as expected.

gh_client.offices nil, per_page: 1

I do agree it's not very intuitive and the docs don't point this out. Perhaps a better solution, similar to the Job Board code, is to create a new set of methods for retrieving single objects, and then remove the id param from the current list methods, like so:

def offices(options = {})
      get_from_harvest_api "/offices", options
end

def office(id, options = {})
      get_from_harvest_api "/offices", options
end

What do you think, @wyefei?

wuz referenced this issue in getagora/greenhouse_io Feb 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants