Method: LabClient::HTTP#request

Defined in:
lib/labclient/http.rb

#request(method, path, body = {}, dump_json = true) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/labclient/http.rb', line 20

def request(method, path, body = {}, dump_json = true)
  options = { method: method, headers: headers(dump_json) }

  if body && !body.empty?
    case method
    when :get
      options[:params] = body
    else
      # File Upload shouldn't be jsonfied
      options[:body] = dump_json ? Oj.dump(body, mode: :compat) : body
    end
  end

  options.merge!(disable_ssl) unless settings[:ssl_verify]

  Typhoeus::Request.new(url(path), options).run
end