lib/soaspec/basic_soap_handler.rb in soaspec-0.0.11 vs lib/soaspec/basic_soap_handler.rb in soaspec-0.0.12
- old
+ new
@@ -1,7 +1,6 @@
-require 'yaml'
require_relative 'tester'
require_relative 'hash_methods'
module Soaspec
# Wraps around Savon client defining default values dependent on the soap request
@@ -14,11 +13,11 @@
# Options to log xml request and response
def logging_options
{
log: true, # See request and response. (Put this in traffic file)
log_level: :debug,
- logger: file_logger,
+ logger: Soaspec::SpecLogger.create,
pretty_print_xml: true # Prints XML pretty
}
end
# Default Savon options. See http://savonrb.com/version2/globals.html for details
@@ -47,16 +46,15 @@
end
# Setup object to handle communicating with a particular SOAP WSDL
# @param [Hash] specific_options Options defining SOAP request. WSDL, authentication, see http://savonrb.com/version2/globals.html for list of options
def initialize(name, specific_options = {})
- super
options = default_options.merge logging_options
options.merge! savon_options
options.merge!(specific_options)
@client = Savon.client(options)
- @name = name
+ super
end
def name(name)
@test_values = {}
@test_name = name
@@ -70,22 +68,17 @@
# Used in together with Exchange request that passes such override parameters
def make_request(override_parameters)
test_values = override_parameters # Used in Erb
# Erb parses template file, executing Ruby code in `<% %>` blocks to work out final request
+ test_values = test_values.transform_keys_to_symbols # Either string or symbol
if @request_option == :template
- test_values = test_values.transform_keys_to_symbols # Either string or symbol
request_body = File.read('template/' + template_name + '.xml')
render_body = ERB.new(request_body).result(binding)
@client.call(operation, xml: render_body) # Call the SOAP operation with the request XML provided
elsif @request_option == :hash
@client.call(operation, message: @default_hash.merge(test_values), attributes: root_attributes)
end
- end
-
- def to_s
- Soaspec::Environment.api_handler = self # Sets this variable globally. This is used in 'Exchange' class
- @name
end
def default_hash=(hash)
@request_option = :hash
@default_hash = hash
\ No newline at end of file