Class: Intacct::Gateway

Inherits:
Object
  • Object
show all
Defined in:
lib/intacct/gateway.rb

Constant Summary collapse

URI_STRING =
"https://api.intacct.com/ia/xml/xmlgw.phtml"

Instance Method Summary collapse

Constructor Details

#initialize(control_config) ⇒ Gateway

Returns a new instance of Gateway.



9
10
11
12
13
# File 'lib/intacct/gateway.rb', line 9

def initialize(control_config)
  @control_config = control_config
  @http_gateway = Net::HTTP.new(uri.host, uri.port)
  @http_gateway.use_ssl = true
end

Instance Method Details

#execute_request(api_request) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/intacct/gateway.rb', line 15

def execute_request(api_request)
  post_request ||= Net::HTTP::Post.new(uri.request_uri)
  post_request["Content-Type"] = "x-intacct-xml-request"
  post_request.body = api_request.to_xml(@control_config)
  Intacct.logger.debug("Request Body: #{post_request.body}")
  http_response = @http_gateway.request(post_request)
  Intacct.logger.debug("Response Body: #{http_response.body}")

  Intacct::Response.new(http_response)
end