Class: Firetruck::API

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.ambulance(key, message, priority = 9) ⇒ Object



26
27
28
29
30
31
# File 'lib/firetruck.rb', line 26

def self.ambulance(key, message, priority = 9)
  #these are mission critical to the server, treat with 9
  type = "ambulance"
  @response = self.post!(key, message, priority)
  return @response.code
end

.firetruck(key, message, priority = 3) ⇒ Object



12
13
14
15
16
17
# File 'lib/firetruck.rb', line 12

def self.firetruck(key, message, priority = 3)
  #standard priority
  type = "firetruck"
  @response = self.post!(key, message, priority)
  return @response.code
end

.firetruck!(key, message, priority = 5) ⇒ Object



5
6
7
8
9
10
# File 'lib/firetruck.rb', line 5

def self.firetruck!(key, message, priority = 5)
  #superhigh
  type = "firetruck"
  @response = self.post!(key, message, priority)
  return @response.code
end

.squadcar(key, message, priority = 7) ⇒ Object



19
20
21
22
23
24
# File 'lib/firetruck.rb', line 19

def self.squadcar(key, message, priority = 7)
  #these are mission critical
  type = "squadcar"
  @response = self.post!(key, message, priority)
  return @response.code
end

Instance Method Details

#post!(key, message, priority) ⇒ Object



33
34
35
36
37
38
# File 'lib/firetruck.rb', line 33

def post!(key, message, priority)
  @endpoint = "http://firetruckapp.com"
  payload = JSON.generate( hpl = { :key => key, :message => message, :priority => priority, :time => Time.now.getutc.to_s } )
  response = HTTParty.post("#{endpoint}/endpoint", { :payload => payload })
  return response
end