Class: Pushbots::Devices

Inherits:
Object
  • Object
show all
Defined in:
lib/pushbots/devices.rb

Overview

Devices class

Constant Summary collapse

PLATFORM_TYPE =
{ ios: 0, android: 1 }.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(tokens, platform, tags = nil) ⇒ Devices

Returns a new instance of Devices.



7
8
9
10
11
# File 'lib/pushbots/devices.rb', line 7

def initialize(tokens, platform, tags = nil)
  self.tokens = tokens
  self.platform = platform
  self.tags = tags if tags
end

Instance Attribute Details

#platformObject

Returns the value of attribute platform.



4
5
6
# File 'lib/pushbots/devices.rb', line 4

def platform
  @platform
end

#tagsObject

Returns the value of attribute tags.



4
5
6
# File 'lib/pushbots/devices.rb', line 4

def tags
  @tags
end

#tokensObject

Returns the value of attribute tokens.



4
5
6
# File 'lib/pushbots/devices.rb', line 4

def tokens
  @tokens
end

Instance Method Details

#registerObject



13
14
15
16
17
18
# File 'lib/pushbots/devices.rb', line 13

def register
  body = { tokens: tokens, platform: PLATFORM_TYPE[platform] }
  body[:tags] = tags if tags
  response = Request.register_batch(body)
  response.code == 201
end