Class: ApiBanking::SoapClient

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

Direct Known Subclasses

Soap11Client, Soap12Client

Class Method Summary collapse

Class Method Details

.do_remote_call(env, callbacks = nil, soapAction = nil, &block) ⇒ Object



9
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
35
36
# File 'lib/api_banking/soap/soap_client.rb', line 9

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

  # add soap11/12 specific headers
  add_soap_headers(options, soapAction)

  # TODO: configuration removed for thread-safety, the assumption that one app at one time will connect to one environment
  # isn't valid anymore (starkit)
  # options[:proxy] = self.configuration.proxy
  # options[:timeout] = self.configuration.timeout

  set_options_for_environment(env, options)

  options[:headers]['User-Agent'] = "Quantiguous; API Banking, Ruby Gem #{ApiBanking::VERSION}"

  request = Typhoeus::Request.new(env.endpoints[self.name.split('::').last.to_sym], options)

  callbacks.before_send.call(request) if (callbacks && callbacks.before_send.respond_to?(:call))
  response = request.run
  callbacks.on_complete.call(request.response) if (callbacks && callbacks.on_complete.respond_to?(:call))

  Thread.current[:last_response] = response

  parse_response(response)
end

.last_responseObject



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

def self.last_response
  Thread.current[:last_response]
end