Class: PushBot::Api

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

Direct Known Subclasses

Device, Push

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(token, platform) ⇒ Api

Create a new Api object with an associated token and platform

Parameters:

  • token

    the user identifier for your platform

  • platform

    one of ‘:ios` or `:android` to indicate which platform the user uses



9
10
11
12
13
# File 'lib/push_bot/api.rb', line 9

def initialize(token, platform)
  @token = token
  @platforms = Platform.parse(platform)
  @platform = platforms.first
end

Instance Attribute Details

#platformObject

Returns the value of attribute platform.



3
4
5
# File 'lib/push_bot/api.rb', line 3

def platform
  @platform
end

#platformsObject

Returns the value of attribute platforms.



3
4
5
# File 'lib/push_bot/api.rb', line 3

def platforms
  @platforms
end

#tokenObject

Returns the value of attribute token.



3
4
5
# File 'lib/push_bot/api.rb', line 3

def token
  @token
end

Instance Method Details

#batch?Boolean

Does this batch apply to a segment

Returns:

  • (Boolean)


26
27
28
# File 'lib/push_bot/api.rb', line 26

def batch?
  !token?
end

#token?Boolean

Does this request represent a tokened single user or is it a batch request

Returns:

  • (Boolean)


16
17
18
# File 'lib/push_bot/api.rb', line 16

def token?
  (defined?(@token) && @token) ? true : false
end

#user?Boolean

Does this request apply to a single user

Returns:

  • (Boolean)


21
22
23
# File 'lib/push_bot/api.rb', line 21

def user?
  token?
end