Class: Houdini::Base

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

Class Method Summary collapse

Class Method Details

.request(api, params) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/houdini_rails/base.rb', line 7

def self.request(api, params)
  validate_constants
  return ["200", '{success:"true"}'] if HOST == 'test'
  url = URI.parse("http://#{HOST}/api/v0/#{api}/tasks/")
  response, body = Net::HTTP.post_form(url, params)

  raise(AuthenticationError, "invalid api key") if response.code == '403'
  if response.code != "200"
    raise RequestError, "The request to houdini failed with code #{response.code}: #{body}"
  end

  [response, body]
end