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

Handle the "count" query parameter #15

Open
ghost opened this issue Dec 27, 2013 · 3 comments
Open

Handle the "count" query parameter #15

ghost opened this issue Dec 27, 2013 · 3 comments

Comments

@ghost
Copy link

ghost commented Dec 27, 2013

I've fiddled with the Kickstarter API a bit recently, and noticed that searches for updates/projects/comments can have a "count" parameter that defines the maximum number of results returned. If not specified, the API returns 10 results at a time. Non-numeric values or values less than 1 are treated as 1.

This functionality is easy enough to implement in Kickscraper by adding a "count" parameter to the relevant methods in client.rb, but I'm wondering if it might be better to accept a hash parameter. So we could call something like:

search_projects { q => "search term", cursor => 100000, count => 5 }

Alternatively, we could make things a little more explicit by creating something like a QueryParameters class and passing that around. I'd be happy to implement this either way, but figured I'd see how the maintainers feel before running off in an unproductive direction.

@benrugg
Copy link
Collaborator

benrugg commented Dec 28, 2013

Hey @ajkerrigan, this sounds good. I personally like the idea of the hash, because it keeps things simple and it's easy and flexible.

The one thing I would say is that any functions accepting the hash should still accept a string (or whatever they accepted before), so they can work either way. That might be a bit "railsy", but it's very convenient if they can accept a string or a hash and just work.

@jamlen
Copy link
Collaborator

jamlen commented Dec 28, 2013

I agree with @benrugg in that I prefer the hash, although I think I'd prefer to keep the required field as the string and then have a hash of the optionals, especially as the current search_projects method takes a page = nil with the required field of query. E.g.:

search_projects 'search term', { cursor => 100000, count => 5 }

@benrugg
Copy link
Collaborator

benrugg commented Dec 30, 2013

I meant to reply to this earlier, but yes, the format you just wrote out @jamlen is what I should have said. (I haven't been in the code of kickscraper for too long!)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants