Class: ApiBanking::SoapClient

Inherits:
Object
  • Object
show all
Defined in:
lib/api_banking/soap/soap_client.rb

Constant Summary collapse

@@last_response =
nil

Class Method Summary collapse

Class Method Details

.do_remote_call(&block) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/api_banking/soap/soap_client.rb', line 10

def self.do_remote_call(&block)
  data = construct_envelope(&block)
  options = {}
  options[:method] = :post
  options[:body] = data.to_xml

  options[:headers] = {'Content-Type' => "application/xml; charset=utf-8"}

  # SOAPAction header is not allowed for Soap12
  # options[:headers][:SOAPAction] = data.doc.at_xpath('/soapenv12:Envelope/soapenv12:Body/*', 'soapenv12' => 'http://www.w3.org/2003/05/soap-envelope').name
  
  options[:proxy] = self.configuration.proxy
  options[:timeout] = self.configuration.timeout
  
  set_options_for_environment(options)
  
  options[:headers]['User-Agent'] = "Quantiguous; API Banking, Ruby Gem #{ApiBanking::VERSION}"
  
  request = Typhoeus::Request.new(self.configuration.environment.endpoints[self.name.split('::').last.to_sym], options)
  response = request.run
  
  @@last_response = response 

  parse_response(response)
end

.last_responseObject



6
7
8
# File 'lib/api_banking/soap/soap_client.rb', line 6

def self.last_response
  @@last_response
end