jm / we_the_people

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

Requests with Dates #6

Open jcasimir opened 11 years ago

jcasimir commented 11 years ago

It would be slick if the library could automatically convert outgoing dates to the API, like this:

start_time = Date.today.beginning_of_day - 60*60*24
recent_petitions = WeThePeople::Resources::Petition.all(nil, :createdAfter => start_time)

Would generate a correct URL with scoping query. It'll use a string representation of time, however. To work, you currently need to remember to convert to epoch time manually:

start_time = Date.today.beginning_of_day - 60*60*24
recent_petitions = WeThePeople::Resources::Petition.all(nil, :createdAfter => start_time.to_i)