firetruck 0.2 → 0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/firetruck.rb +17 -6
- metadata +1 -1
data/lib/firetruck.rb
CHANGED
@@ -2,28 +2,39 @@ require "httparty"
|
|
2
2
|
require "json"
|
3
3
|
module Firetruck
|
4
4
|
class API
|
5
|
-
def self.firetruck!(key, message, priority =
|
5
|
+
def self.firetruck!(key, message, priority = 5)
|
6
6
|
#superhigh
|
7
7
|
type = "firetruck"
|
8
|
-
self.post!(key, message, priority)
|
8
|
+
@response = self.post!(key, message, priority)
|
9
|
+
return @response.code
|
9
10
|
end
|
10
11
|
|
11
12
|
def self.firetruck(key, message, priority = 3)
|
12
13
|
#standard priority
|
13
14
|
type = "firetruck"
|
14
|
-
self.post!(key, message, priority)
|
15
|
+
@response = self.post!(key, message, priority)
|
16
|
+
return @response.code
|
15
17
|
end
|
16
18
|
|
17
|
-
def self.squadcar(key, message, priority =
|
19
|
+
def self.squadcar(key, message, priority = 7)
|
18
20
|
#these are mission critical
|
19
21
|
type = "squadcar"
|
20
|
-
self.post!(key, message, priority)
|
22
|
+
@response = self.post!(key, message, priority)
|
23
|
+
return @response.code
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.ambulance(key, message, priority = 9)
|
27
|
+
#these are mission critical to the server, treat with 9
|
28
|
+
type = "ambulance"
|
29
|
+
@response = self.post!(key, message, priority)
|
30
|
+
return @response.code
|
21
31
|
end
|
22
32
|
|
23
33
|
def post!(key, message, priority)
|
24
34
|
@endpoint = "http://firetruckapp.com"
|
25
35
|
payload = JSON.generate( hpl = { :key => key, :message => message, :priority => priority, :time => Time.now.getutc.to_s } )
|
26
|
-
HTTParty.post("#{endpoint}/endpoint", { :payload => payload })
|
36
|
+
response = HTTParty.post("#{endpoint}/endpoint", { :payload => payload })
|
37
|
+
return response
|
27
38
|
end
|
28
39
|
end
|
29
40
|
end
|