anthonator / dirigible

Ruby wrapper for the Urban Airship v3 API
MIT License
11 stars 10 forks source link

Parse and provide next page params for device listing, add device count API method #16

Closed johnnaegle closed 10 years ago

johnnaegle commented 10 years ago

All the device listing API calls take an optional start and limit parameter and will return a next_page field in the response if there is more than one page of data. I added options ={} to all the device listing methods and parse the next_page out of the response (if present) and inject the start/limit parameters into the root of the response hash. I also found that the device token count method was missing and added that.

johnnaegle commented 10 years ago

thoughts on merging this in?

anthonator commented 10 years ago

Sorry for not getting to this.

I'm good with the count_device_tokens endpoint and adding params to the list endpoints but I'm not sure about how you're handling next page. I don't think it's clear what's going on without digging into the code. Ideally we could do something like Dirigible::DeviceInformation.list_apids.next_page. This should be possible without monkey patching Hash. Possibly creating a Dirigible::DeviceInformation::List object that overrides [] for returning response hash data and then implementing a next_page method.

What are your thoughts?

anthonator commented 10 years ago

https://github.com/anthonator/dirigible/blob/next_page/lib/dirigible/device_information.rb

See the List class within DeviceInformation. This provides the ability to call Dirigible::DeviceInformation.list_apids.next_page.

Note this is in the next_page branch.

anthonator commented 10 years ago

I pushed my changes for supporting Dirigible::DeviceInformation.list_apids.next_page to master. Please submit a new PR for the devices_count endpoint.