Class: Pushbots::One

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

Overview

Push class

Constant Summary

Constants inherited from Push

Push::PLATFORM_TYPE, Push::PLATFORM_TYPE_R, Push::STATUS

Instance Attribute Summary collapse

Attributes inherited from Push

#message, #platform, #response, #status, #type

Instance Method Summary collapse

Constructor Details

#initialize(platform, token, message, sound, options = {}) ⇒ One

Returns a new instance of One.



6
7
8
9
10
11
12
# File 'lib/pushbots/one.rb', line 6

def initialize(platform, token, message, sound, options = {})
  super(platform, message, :one)
  self.token = token
  self.sound = sound
  self.badge = options[:badge]
  self.payload = options[:payload]
end

Instance Attribute Details

#badgeObject

Returns the value of attribute badge.



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

def badge
  @badge
end

#payloadObject

Returns the value of attribute payload.



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

def payload
  @payload
end

#soundObject

Returns the value of attribute sound.



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

def sound
  @sound
end

#tokenObject

Returns the value of attribute token.



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

def token
  @token
end

Instance Method Details

#bodyObject



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/pushbots/one.rb', line 21

def body
  data = {
    platform: @platform,
    token: token,
    msg: message,
    sound: sound
  }
  data[:badge] if badge
  data[:payload] if payload
  data
end

#sendObject



14
15
16
17
18
19
# File 'lib/pushbots/one.rb', line 14

def send
  # request = Request.new(body, :one)
  self.response = Request.send(:one, body)
  self.status =
    response.failed? ? STATUS[:failed] : STATUS[:delivered]
end