Class: PushBot::Device

Inherits:
Api
  • Object
show all
Defined in:
lib/push_bot/device.rb

Instance Attribute Summary

Attributes inherited from Api

#platform, #platforms, #token

Instance Method Summary collapse

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

Parameters:

Returns:

Raises:

  • (ArgumentError)


7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/push_bot/device.rb', line 7

def add(registration_options={})
  raise(ArgumentError, 'Batch device add should only be to a single platform') if Array === token && platforms.size != 1

  options, type = registration_options.merge(
    :platform => platform
  ), :batch

  if user? && !(Array === token)
    type = nil
    options[:token] = token
  else
    options[:tokens] = token
  end

  Request.new(:deviceToken).put(type, options)
end

#infoPushBot::Response

Retrieve information about the device with this token

Returns:



27
28
29
# File 'lib/push_bot/device.rb', line 27

def info
  Request.new(:deviceToken).get(:one, :token => token)
end

#removePushBot::Response

Remove a specific user from PushBots

Returns:

Raises:

  • (ArgumentError)


34
35
36
37
38
# File 'lib/push_bot/device.rb', line 34

def remove
  raise(ArgumentError, 'A token and platform is required for removal') unless token && token

  Request.new(:deviceToken).put(:del, :token => token, :platform => platform)
end