lib/zeppelin.rb in zeppelin-0.7.0 vs lib/zeppelin.rb in zeppelin-0.8.1
- old
+ new
@@ -29,11 +29,11 @@
def connection
return @connection unless @connection.nil?
@connection = initialize_connection
end
- # Registers a device token.
+ # Registers an iPhone device token.
#
# @param [String] device_token
# @param [Hash] payload the payload to send during registration
#
# @return [Boolean] whether or not the registration was successful
@@ -42,62 +42,51 @@
def register_device_token(device_token, payload = {})
uri = device_token_uri(device_token)
put_request(uri, payload)
end
- # Retrieves information on a device token.
+ # Registers an Android APID.
#
- # @param [String] device_token
- # @return [Hash, nil]
+ # @param [String] apid
#
- # @raise [Zeppelin::ResourceNotFound] invalid device token provided
- def device_token(device_token)
- uri = device_token_uri(device_token)
- get_request(uri)
- end
-
- # Deletes a device token.
+ # @param [Hash] payload the payload to send during registration
#
- # @param [String] device_token
+ # @return [Boolean] whether or not the registration was successful
#
- # @return [Boolean] whether or not the deletion was successful
- #
- # @raise [Zeppelin::ResourceNotFound] invalid device token provided
- def delete_device_token(device_token)
- uri = device_token_uri(device_token)
- delete_request(uri)
+ # @raise [Zeppelin::ClientError] invalid payload format
+ def register_apid(apid, payload = {})
+ uri = apid_uri(apid)
+ put_request(uri, payload)
end
- # Retrieve a page of device tokens
+ # Registers a Blackberry PIN
#
- # @param [Integer] page (nil) Page of device tokens to retrieve
+ # @param [String] pin
#
- # @return [Hash] result set. See documentation for details
- #
- # @Note that the next page number is included in the result set instead of the
- # raw URI to request for the next page
- #
- # @raise [Zeppelin::ClientError] invalid request
- def device_tokens(page=nil)
- uri = device_token_uri(nil, :page => page)
- get_paged_request(uri)
- end
-
- # Registers an APID.
- #
- # @param [String] apid
- #
# @param [Hash] payload the payload to send during registration
#
# @return [Boolean] whether or not the registration was successful
#
# @raise [Zeppelin::ClientError] invalid payload format
- def register_apid(apid, payload = {})
- uri = apid_uri(apid)
+ #
+ # @see http://urbanairship.com/docs/blackberry.html#registration
+ def register_pin(pin, payload = {})
+ uri = pin_uri(pin)
put_request(uri, payload)
end
+ # Retrieves information on a device token.
+ #
+ # @param [String] device_token
+ # @return [Hash, nil]
+ #
+ # @raise [Zeppelin::ResourceNotFound] invalid device token provided
+ def device_token(device_token)
+ uri = device_token_uri(device_token)
+ get_request(uri)
+ end
+
# Retrieves information on an APID.
#
# @param [String] apid
#
# @return [Hash, nil]
@@ -106,10 +95,32 @@
def apid(apid)
uri = apid_uri(apid)
get_request(uri)
end
+ # @param [String] pin
+ #
+ # @return [Hash, nil]
+ #
+ # @raise [Zeppelin::ResourceNotFound] invalid PIN provided
+ def pin(pin)
+ uri = pin_uri(pin)
+ get_request(uri)
+ end
+
+ # Deletes a device token.
+ #
+ # @param [String] device_token
+ #
+ # @return [Boolean] whether or not the deletion was successful
+ #
+ # @raise [Zeppelin::ResourceNotFound] invalid device token provided
+ def delete_device_token(device_token)
+ uri = device_token_uri(device_token)
+ delete_request(uri)
+ end
+
# Deletes an APID.
#
# @param [String] apid
#
# @return [Boolean] whether or not the deletion was successful
@@ -118,10 +129,37 @@
def delete_apid(apid)
uri = apid_uri(apid)
delete_request(uri)
end
+ # Deletes a PIN
+ #
+ # @param [String] pin
+ #
+ # @return [Boolean] whether or not deletion was successful
+ #
+ # @raise [Zeppelin::ResourceNotFound] invalid PIN provided
+ def delete_pin(pin)
+ uri = pin_uri(pin)
+ delete_request(uri)
+ end
+
+ # Retrieve a page of device tokens
+ #
+ # @param [Integer] page (nil) Page of device tokens to retrieve
+ #
+ # @return [Hash] result set. See documentation for details
+ #
+ # @Note that the next page number is included in the result set instead of the
+ # raw URI to request for the next page
+ #
+ # @raise [Zeppelin::ClientError] invalid request
+ def device_tokens(page=nil)
+ uri = device_token_uri(nil, :page => page)
+ get_paged_request(uri)
+ end
+
# Retrieve a page of APIDs
#
# @param [Integer] page (nil) Page of APIDs to retrieve
#
# @return [Hash] result set. See documentation for details
@@ -336,9 +374,13 @@
"/api/tags/#{name}"
end
def device_tag_uri(device_token, tag_name)
device_token_uri(device_token) + "/tags/#{tag_name}"
+ end
+
+ def pin_uri(pin)
+ "/api/device_pins/#{pin}/"
end
end
require 'zeppelin/middleware'
require 'zeppelin/version'