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
# 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?
    type = nil
    options[:token] = token
  end

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

#infoObject



22
23
24
# File 'lib/push_bot/device.rb', line 22

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

#removePushBot::Response

Remove a specific user from PushBots

Returns:

Raises:

  • (ArgumentError)


29
30
31
32
33
# File 'lib/push_bot/device.rb', line 29

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