Module: Restool::Service::RemoteConnector

Defined in:
lib/restool/service/remote_connector.rb

Class Method Summary collapse

Class Method Details

.execute(remote_client, operation, path, params, headers, response_handler, representations, basic_auth) ⇒ Object

The RemoteConnector module makes the requests using the RemoteClient, calls the response_handler with the response, and finally executes the object traversal



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/restool/service/remote_connector.rb', line 10

def self.execute(remote_client, operation, path, params, headers,
                response_handler, representations, basic_auth)
  remote_response = remote_client.make_request(path, operation.method, params, headers,
                                               basic_auth)

  # Enumerable class does not have to_h in Ruby 1.9
  header = header_to_hash(remote_response.each_header)

  response = response_handler.call(remote_response.body, remote_response.code,
                                   header)

  return response if operation.response.nil?

  Restool::Traversal::Converter.convert(response, operation.response, representations)
end