Class: IntuitOAuth::Transport

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/intuit-oauth/transport.rb

Class Method Summary collapse

Class Method Details

.request(method, url, headers = nil, body = nil, isBuildResponse = true) ⇒ Object


25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/intuit-oauth/transport.rb', line 25

def self.request(method, url, headers=nil, body=nil, isBuildResponse=true)
  uri = URI(url)

  user_agent_header = {
    'User-Agent': IntuitOAuth::Version::USER_AGENT
  }
  req_headers = headers.nil? ? user_agent_header : user_agent_header.merge!(headers)

  if method == 'GET'
    response = get(url,
      headers: req_headers
    )

  elsif method == 'POST'
    response = post(url,
      headers: req_headers,
      body: body
    )
  end

  if isBuildResponse == true
    IntuitOAuth::Utils.build_response_object(response)
  else
    response
  end
end