Class: CnpOnline::CnpXmlMapper

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

Class Method Summary collapse

Class Method Details

.request(request_xml, config_hash) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/CnpXmlMapper.rb', line 34

def CnpXmlMapper.request(request_xml, config_hash)
  logger = initialize_logger(config_hash)

  logger.debug request_xml
  # get the Cnp Online Response from the API server over HTTP
  response_xml = Communications.http_post(request_xml,config_hash)
  logger.debug response_xml

  # create response object from xml returned form the Cnp API
  response_object = XMLObject.new(response_xml)
  
  # Check if the response xml is valid.
  if (response_object.response == "0")
    return response_object
  else
    raise("Error with http response, code: " + response_object.response + ", message: " + response_object.message)
  end
  
  return response_object
end