Class: PushesUs::Notification

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(network_key, device_identity, alert, sound = 'default') ⇒ Notification

Returns a new instance of Notification.



25
26
27
# File 'lib/pushesus.rb', line 25

def initialize(network_key, device_identity, alert, sound='default')
  @network_key, @device_identity, @alert, @sound = network_key, device_identity, alert, sound
end

Instance Attribute Details

#alertObject

Returns the value of attribute alert.



14
15
16
# File 'lib/pushesus.rb', line 14

def alert
  @alert
end

#device_identityObject

Returns the value of attribute device_identity.



14
15
16
# File 'lib/pushesus.rb', line 14

def device_identity
  @device_identity
end

#errorsObject (readonly)

Returns the value of attribute errors.



15
16
17
# File 'lib/pushesus.rb', line 15

def errors
  @errors
end

#network_keyObject

Returns the value of attribute network_key.



14
15
16
# File 'lib/pushesus.rb', line 14

def network_key
  @network_key
end

#soundObject

Returns the value of attribute sound.



14
15
16
# File 'lib/pushesus.rb', line 14

def sound
  @sound
end

Class Method Details

.send(network_key, device_identity, alert, sound = 'default') ⇒ Object



18
19
20
21
22
# File 'lib/pushesus.rb', line 18

def send(network_key, device_identity, alert, sound='default')
  p = self.new(network_key, device_identity, alert, sound)
  p.send
  return p
end

Instance Method Details

#sendObject



29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/pushesus.rb', line 29

def send
  result = PushesUs.post('/notifications.json', :query => { :notification => { 
                                              :device_identity => device_identity,
                                              :network_key => network_key,
                                              :alert => alert,
                                              :sound => sound
                                             }})
  if result['success']
    return true
  else
    @errors = result['errors']
    return false
  end
end