Skip to content

Commit

Permalink
Add device_tokens API support
Browse files Browse the repository at this point in the history
device_tokens is intended to accept the previous page
of results to continue paging.  limit params are included
in the next_page querystring, so the initial limit is a
fixed paging length.
  • Loading branch information
Groxx committed Jun 26, 2012
1 parent 276e35a commit 3312e44
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions lib/urbanairship.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,22 @@ def feedback(time)
do_request(:get, "/api/device_tokens/feedback/?since=#{format_time(time)}", :authenticate_with => :master_secret)
end

def device_tokens(options_or_previous_page = {})
opts = options_or_previous_page.with_indifferent_access
limit = opts[:limit] || 5000
path = if opts[:next_page]
uri = URI.parse(opts[:next_page])
"#{uri.path}?#{uri.query}"
else
"/api/device_tokens/?limit=#{limit}"
end
do_request(:get, path, :authenticate_with => :master_secret)
end

def device_tokens_count
do_request(:get, "/api/device_tokens/count/", :authenticate_with => :master_secret)
end

private

def do_request(http_method, path, options = {})
Expand Down

0 comments on commit 3312e44

Please sign in to comment.