Method: SparkApi::Authentication::OAuth2#request

Defined in:
lib/spark_api/authentication/oauth2.rb

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

Perform an HTTP request (no data)



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/spark_api/authentication/oauth2.rb', line 42

def request(method, path, body, options={})
  escaped_path = URI.escape(path)
  connection = @client.connection(true)  # SSL Only!
  connection.headers.merge!(self.auth_header)
  options.merge!(:ApiUser => "#{@client.api_user}") unless @client.api_user.nil?
  parameter_string = options.size > 0 ? "?#{build_url_parameters(options)}" : ""
  request_path = "#{escaped_path}#{parameter_string}"
  SparkApi.logger.debug("Request: #{request_path}")
  if body.nil?
    response = connection.send(method, request_path)
  else
    SparkApi.logger.debug("Data: #{body}")
    response = connection.send(method, request_path, body)
  end
  response
end