lib/dirigible/device_information.rb in dirigible-1.1.0 vs lib/dirigible/device_information.rb in dirigible-1.1.1
- old
+ new
@@ -29,10 +29,22 @@
# @see http://docs.urbanairship.com/reference/api/v3/device_information.html#individual-device-lookup
def self.get_device_pin(id)
Dirigible.get("/device_pins/#{id}")
end
+ # Count iOS device tokens registered to this application
+ #
+ # @example Example request:
+ # Dirigible::DeviceInformation.count_device_tokens[:device_tokens_count]
+ # Dirigible::DeviceInformation.count_device_tokens[:active_device_tokens_count]
+ #
+ # @see http://docs.urbanairship.com/reference/api/v3/device_information.html#device-listing
+ def self.count_device_tokens
+ Dirigible.get("/device_tokens/count")
+ end
+
+
# Fetch iOS device tokens registered to this application
# and associated metadata.
#
# @example Example request:
# Dirigible::DeviceInformation.list_device_tokens
@@ -41,11 +53,11 @@
# device_tokens = Dirigible::DeviceInformation.list_device_tokens
# more_device_tokens = device_tokens.next_page
#
# @see http://docs.urbanairship.com/reference/api/v3/device_information.html#device-listing
def self.list_device_tokens(options = {})
- List.new(Dirigible.get('/device_tokens', params))
+ List.new(Dirigible.get('/device_tokens', options))
end
# Fetch Android APIDs registered to this application and
# associated metadata.
#
@@ -56,11 +68,11 @@
# apids = Dirigible::DeviceInformation.list_apids
# more_apids = apids.next_page
#
# @see http://docs.urbanairship.com/reference/api/v3/device_information.html#device-listing
def self.list_apids(options = {})
- List.new(Dirigible.get('/apids', params))
+ List.new(Dirigible.get('/apids', options))
end
# Fetch BlackBerry PINs registered to this application and
# associated metadata.
#
@@ -71,11 +83,11 @@
# device_pins = Dirigible::DeviceInformation.list_device_pins
# more_device_pins = device_pins.next_page
#
# @see http://docs.urbanairship.com/reference/api/v3/device_information.html#device-listing
def self.list_device_pins(options = {})
- List.new(Dirigible.get('/device_pins', params))
+ List.new(Dirigible.get('/device_pins', options))
end
# Fetch device tokens that can't recieve messages because
# the app has been uninstalled.
#
@@ -99,10 +111,10 @@
# Fetch the next page for this device listing. Returns
# nil if next_page is nil.
def next_page(params = {})
return nil if @response[:next_page].nil?
uri = URI.parse(@response[:next_page])
- path = "/#{uri.path.gsub(/\/api|\//, '')}"
+ path = "/#{uri.path.gsub(/\/api\/|\//, '')}"
# Shew! Need to simplify this!
params = (CGI.parse(uri.query).map{ |k,v| { k => v[0] } }.reduce({}) { |h,pairs| pairs.each { |k,v| (h[k.to_sym] = v) }; h }).merge!(params)
List.new(Dirigible.get(path, params))
end
end