Class: HermesAPI::Connection

Inherits:
ActiveResource::Connection
  • Object
show all
Defined in:
lib/hermes_api/connection.rb

Instance Method Summary collapse

Instance Method Details

#request(method, path, *arguments) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/hermes_api/connection.rb', line 3

def request(method, path, *arguments)
  result = ActiveSupport::Notifications.instrument("request.active_resource") do |payload|
    payload[:method] = method
    payload[:request_uri] = "#{site.scheme}://#{site.host}:#{site.port}#{path}"
    # TODO: Figure out why the headers set in the Base class are not being set here
    arguments.last["Content-Type"] = "text/xml"
    payload[:result] = http.send(method, path, *arguments)
    payload[:result]
  end

  raise HermesAPI::CreationError, result if result.body.include?("errorMessages")

  handle_response(result)
rescue Timeout::Error => e
  raise TimeoutError, e.message
rescue OpenSSL::SSL::SSLError => e
  raise SSLError, e.message
end