Class: PushBot::Device
Instance Attribute Summary
Attributes inherited from Api
Instance Method Summary collapse
-
#add(registration_options = {}) ⇒ PushBot::Response
Add a specific user or batch of users to PushBots.
-
#alias(alias_options = {}) ⇒ PushBot::Response
Alias one user identifier to another.
-
#all ⇒ PushBot::Response
Request a list of your registered devices.
-
#at_location(*location) ⇒ Object
Set the users location to the specified latitude and longitude.
-
#info ⇒ PushBot::Response
Retrieve information about the device with this token.
-
#remove ⇒ PushBot::Response
Remove a specific user from PushBots.
- #removed ⇒ Object
Methods inherited from Api
#batch?, #initialize, #token?, #user?
Constructor Details
This class inherits a constructor from PushBot::Api
Instance Method Details
#add(registration_options = {}) ⇒ PushBot::Response
Add a specific user or batch of users to PushBots
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/push_bot/device.rb', line 14 def add(={}) raise(ArgumentError, 'Batch device add should only be to a single platform') if Array === token && platforms.size != 1 , type = .merge( :platform => platform ), :batch if user? && !(Array === token) type = nil [:token] = token else [:tokens] = token end request.put(type, ) end |
#alias(alias_options = {}) ⇒ PushBot::Response
Alias one user identifier to another
35 36 37 |
# File 'lib/push_bot/device.rb', line 35 def alias(={}) Request.new(:alias).put(nil, .merge(:token => token, :platform => platform)) end |
#all ⇒ PushBot::Response
Request a list of your registered devices
6 7 8 |
# File 'lib/push_bot/device.rb', line 6 def all request.get(:all) end |
#at_location(*location) ⇒ Object
Set the users location to the specified latitude and longitude
52 53 54 55 56 57 58 |
# File 'lib/push_bot/device.rb', line 52 def at_location(*location) lat, lng = PushBot::Location.parse(*location) raise ArgumentError, 'latitude and longitude are required' unless lat && lng Request.new(:geo).put(nil, :token => token, :platform => platform, :lat => lat, :lng => lng) end |
#info ⇒ PushBot::Response
Retrieve information about the device with this token
42 43 44 |
# File 'lib/push_bot/device.rb', line 42 def info request.get(:one, :token => token) end |
#remove ⇒ PushBot::Response
Remove a specific user from PushBots
67 68 69 70 71 |
# File 'lib/push_bot/device.rb', line 67 def remove raise(ArgumentError, 'A token and platform is required for removal') unless token && token request.put(:del, :token => token, :platform => platform) end |