Class: Zeppelin
- Inherits:
-
Object
- Object
- Zeppelin
- Defined in:
- lib/zeppelin.rb,
lib/zeppelin/version.rb,
lib/zeppelin/middleware.rb,
lib/zeppelin/middleware/response_raise_error.rb
Overview
A very tiny Urban Airship Push Notification API client.
Provides thin wrappers around API calls to the most common API tasks. For more information on how the requests and responses are formatted, visit the Urban Airship Push Notification API docs.
Defined Under Namespace
Modules: Middleware, Middlware Classes: ClientError, ResourceNotFound
Constant Summary collapse
- BASE_URI =
'https://go.urbanairship.com'
- PUSH_URI =
'/api/push/'
- BATCH_PUSH_URI =
'/api/push/batch/'
- BROADCAST_URI =
'/api/push/broadcast/'
- JSON_HEADERS =
{ 'Content-Type' => 'application/json' }
- VERSION =
'0.8.4'
Instance Attribute Summary collapse
-
#application_key
readonly
Returns the value of attribute application_key.
-
#application_master_secret
readonly
Returns the value of attribute application_master_secret.
-
#options
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#add_tag(name) ⇒ Boolean
Creates a tag that is not associated with any device.
-
#add_tag_to_device(device_token, tag_name) ⇒ Boolean
Whether or not a tag was successfully associated with a device.
-
#apid(apid) ⇒ Hash?
Retrieves information on an APID.
-
#apids(page = nil) ⇒ Hash
Retrieve a page of APIDs.
-
#batch_push(*payload) ⇒ Boolean
Batch pushes multiple messages.
-
#broadcast(payload) ⇒ Boolean
Broadcasts a message.
-
#connection
The connection to UrbanAirship.
-
#delete_apid(apid) ⇒ Boolean
Deletes an APID.
-
#delete_device_token(device_token) ⇒ Boolean
Deletes a device token.
-
#delete_pin(pin) ⇒ Boolean
Deletes a PIN.
- #device_tags(device_token) ⇒ Hash?
-
#device_token(device_token) ⇒ Hash?
Retrieves information on a device token.
-
#device_tokens(page = nil) ⇒ Hash
Retrieve a page of device tokens.
-
#feedback(since) ⇒ Hash?
Retrieves feedback on device tokens.
-
#initialize(application_key, application_master_secret, options = {}) ⇒ Zeppelin
constructor
A new instance of Zeppelin.
-
#modify_device_tokens_on_tag(tag_name, payload = {})
Modifies device tokens associated with a tag.
- #pin(pin) ⇒ Hash?
-
#push(payload) ⇒ Boolean
Pushes a message.
-
#register_apid(apid, payload = {}) ⇒ Boolean
Registers an Android APID.
-
#register_device_token(device_token, payload = {}) ⇒ Boolean
Registers an iPhone device token.
-
#register_pin(pin, payload = {}) ⇒ Boolean
Registers a Blackberry PIN.
-
#remove_tag(name) ⇒ Boolean
Removes a tag from the service.
-
#remove_tag_from_device(device_token, tag_name) ⇒ Boolean
Whether or not a tag was successfully dissociated from a device.
-
#tags ⇒ Hash?
Retrieve all tags on the service.
Constructor Details
#initialize(application_key, application_master_secret, options = {}) ⇒ Zeppelin
Returns a new instance of Zeppelin.
23 24 25 26 27 |
# File 'lib/zeppelin.rb', line 23 def initialize(application_key, application_master_secret, = {}) @application_key = application_key @application_master_secret = application_master_secret @options = end |
Instance Attribute Details
#application_key (readonly)
Returns the value of attribute application_key.
17 18 19 |
# File 'lib/zeppelin.rb', line 17 def application_key @application_key end |
#application_master_secret (readonly)
Returns the value of attribute application_master_secret.
17 18 19 |
# File 'lib/zeppelin.rb', line 17 def application_master_secret @application_master_secret end |
#options (readonly)
Returns the value of attribute options.
17 18 19 |
# File 'lib/zeppelin.rb', line 17 def @options end |
Instance Method Details
#add_tag(name) ⇒ Boolean
Creates a tag that is not associated with any device
249 250 251 252 |
# File 'lib/zeppelin.rb', line 249 def add_tag(name) uri = tag_uri(name) put_request(uri) end |
#add_tag_to_device(device_token, tag_name) ⇒ Boolean
Returns whether or not a tag was successfully associated with a device.
285 286 287 288 |
# File 'lib/zeppelin.rb', line 285 def add_tag_to_device(device_token, tag_name) uri = device_tag_uri(device_token, tag_name) put_request(uri) end |
#apid(apid) ⇒ Hash?
Retrieves information on an APID.
96 97 98 99 |
# File 'lib/zeppelin.rb', line 96 def apid(apid) uri = apid_uri(apid) get_request(uri) end |
#apids(page = nil) ⇒ Hash
Retrieve a page of APIDs
172 173 174 175 |
# File 'lib/zeppelin.rb', line 172 def apids(page=nil) uri = apid_uri(nil, :page => page) get_paged_request(uri) end |
#batch_push(*payload) ⇒ Boolean
Batch pushes multiple messages.
195 196 197 |
# File 'lib/zeppelin.rb', line 195 def batch_push(*payload) post_request(BATCH_PUSH_URI, payload) end |
#broadcast(payload) ⇒ Boolean
Broadcasts a message.
206 207 208 |
# File 'lib/zeppelin.rb', line 206 def broadcast(payload) post_request(BROADCAST_URI, payload) end |
#connection
The connection to UrbanAirship
30 31 32 33 |
# File 'lib/zeppelin.rb', line 30 def connection return @connection if defined?(@connection) @connection = initialize_connection end |
#delete_apid(apid) ⇒ Boolean
Deletes an APID.
130 131 132 133 |
# File 'lib/zeppelin.rb', line 130 def delete_apid(apid) uri = apid_uri(apid) delete_request(uri) end |
#delete_device_token(device_token) ⇒ Boolean
Deletes a device token.
118 119 120 121 |
# File 'lib/zeppelin.rb', line 118 def delete_device_token(device_token) uri = device_token_uri(device_token) delete_request(uri) end |
#delete_pin(pin) ⇒ Boolean
Deletes a PIN
142 143 144 145 |
# File 'lib/zeppelin.rb', line 142 def delete_pin(pin) uri = pin_uri(pin) delete_request(uri) end |
#device_tags(device_token) ⇒ Hash?
272 273 274 275 |
# File 'lib/zeppelin.rb', line 272 def (device_token) uri = device_tag_uri(device_token, nil) get_request(uri) end |
#device_token(device_token) ⇒ Hash?
Retrieves information on a device token.
84 85 86 87 |
# File 'lib/zeppelin.rb', line 84 def device_token(device_token) uri = device_token_uri(device_token) get_request(uri) end |
#device_tokens(page = nil) ⇒ Hash
Retrieve a page of device tokens
157 158 159 160 |
# File 'lib/zeppelin.rb', line 157 def device_tokens(page=nil) uri = device_token_uri(nil, :page => page) get_paged_request(uri) end |
#feedback(since) ⇒ Hash?
Retrieves feedback on device tokens.
This is useful for removing inactive device tokens for the database.
219 220 221 222 |
# File 'lib/zeppelin.rb', line 219 def feedback(since) uri = feedback_uri(since) get_request(uri) end |
#modify_device_tokens_on_tag(tag_name, payload = {})
Modifies device tokens associated with a tag.
239 240 241 242 |
# File 'lib/zeppelin.rb', line 239 def modify_device_tokens_on_tag(tag_name, payload = {}) uri = tag_uri(tag_name) post_request(uri, payload) end |
#pin(pin) ⇒ Hash?
106 107 108 109 |
# File 'lib/zeppelin.rb', line 106 def pin(pin) uri = pin_uri(pin) get_request(uri) end |
#push(payload) ⇒ Boolean
Pushes a message.
184 185 186 |
# File 'lib/zeppelin.rb', line 184 def push(payload) post_request(PUSH_URI, payload) end |
#register_apid(apid, payload = {}) ⇒ Boolean
Registers an Android APID.
57 58 59 60 |
# File 'lib/zeppelin.rb', line 57 def register_apid(apid, payload = {}) uri = apid_uri(apid) put_request(uri, payload) end |
#register_device_token(device_token, payload = {}) ⇒ Boolean
Registers an iPhone device token.
43 44 45 46 |
# File 'lib/zeppelin.rb', line 43 def register_device_token(device_token, payload = {}) uri = device_token_uri(device_token) put_request(uri, payload) end |
#register_pin(pin, payload = {}) ⇒ Boolean
Registers a Blackberry PIN
73 74 75 76 |
# File 'lib/zeppelin.rb', line 73 def register_pin(pin, payload = {}) uri = pin_uri(pin) put_request(uri, payload) end |
#remove_tag(name) ⇒ Boolean
Removes a tag from the service
262 263 264 265 |
# File 'lib/zeppelin.rb', line 262 def remove_tag(name) uri = tag_uri(name) delete_request(uri) end |
#remove_tag_from_device(device_token, tag_name) ⇒ Boolean
Returns whether or not a tag was successfully dissociated from a device.
298 299 300 301 |
# File 'lib/zeppelin.rb', line 298 def remove_tag_from_device(device_token, tag_name) uri = device_tag_uri(device_token, tag_name) delete_request(uri) end |
#tags ⇒ Hash?
Retrieve all tags on the service
227 228 229 230 |
# File 'lib/zeppelin.rb', line 227 def uri = tag_uri(nil) get_request(uri) end |