jm / we_the_people

API client for the White House's We The People petition application
MIT License
13 stars 4 forks source link

Add a method for retrieving all petitions #4

Open yoni opened 11 years ago

yoni commented 11 years ago

I noticed that the all method on a resource returns a paginator. Additionally, the get_all method on that paginator only returns all values on the current page. There doesn't seem to be any support for iterating over all values. Seems like that'd be a pretty useful feature. I'm looking into how to implement it, but wanted to ping you first to see if it's already on your radar.

On a related note, it looks like the pagination isn't working correctly. Retrieving all petitions returns only 10 at a time:

> WeThePeople::Resources::Petition.all.all.length
http://petitions.whitehouse.gov/api/v1/petitions.json
 => 10 
jm commented 11 years ago

One of the first tweaks I'm going to make is to tweak that class a bit to be less paginatery and keep track of all the resources you download in @all rather than just treating that like a bucket to put the current page. Hoping to make that change tomorrow or Monday.

yoni commented 11 years ago

Thanks for the details. Sounds good.