Class: AwsDeploy::Notification

Inherits:
Object
  • Object
show all
Defined in:
app/business/aws_deploy/notification.rb

Class Method Summary collapse

Class Method Details

.send(to = "all", title = "subject", message = "message") ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'app/business/aws_deploy/notification.rb', line 7

def self.send to="all", title="subject", message="message"
  @errors = []
  vals = []
  if to == "all"

    api_keys = $aws_deploy["pushbullet"]["api_key"]
    keys = api_keys.split(" ")


    begin

      keys.each_with_index do |k,i| 
        puts "-" * 100
        puts "#{i} - #{k}"
        vals = k.split("|")
        puts "-" * 100  

      AwsDeploy::Notification.sendn(vals[0], vals[1], title, message)

      end
    rescue Exception => e
      @errors << "Problem sending to: #{vals[0]}|#{vals[1]}|#{vals[2]} ... #{e}"
    end

  end

  @errors
end

.sendn(token, device_name, title = "", message = "") ⇒ Object



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'app/business/aws_deploy/notification.rb', line 41

def self.sendn token, device_name, title="", message=""
  push = MyPush.new :token => token

  # find the device...
  iden = ""
  devices = push.devices
  devices["devices"].each do |dev|
    if device_name == dev["extras"]["model"]
      puts "ID: #{dev["iden"]}"
      iden = dev["iden"]
    end
  end

  # send a message..
  push.push :type => MyPush::PUSH_TYPE_NOTE, 
        :title => "#{title}", 
        :body => "#{message}", 
        :iden => "#{iden}"

end