lib/libis/services/rosetta/client.rb in libis-services-0.1.13 vs lib/libis/services/rosetta/client.rb in libis-services-0.1.14
- old
+ new
@@ -17,32 +17,40 @@
class Client
include ::Libis::Services::SoapClient
include ::Libis::Tools::Logger
def initialize(section, service, options = {})
+ basic_auth = options.delete(:basic_auth)
+ if basic_auth
+ options[:basic_auth] = [
+ "#{basic_auth[:user]}-institutionCode-#{basic_auth[:institution]}",
+ basic_auth[:password]
+ ]
+ end
opts = {strip_namespaces: true, logger: ::Libis::Tools::Config.logger}.merge options
base_url = opts.delete(:url) || 'http://depot.lias.be'
configure "#{base_url}/dpsws/#{section}/#{service}?wsdl", opts
end
def pds_handle=(handle)
@pds_handle = handle
end
def authenticate(user, password, institution)
- @basic_auth = Base64.encode64 "#{user}-institutionCode-#{institution}:#{password}"
+ code = Base64.encode64("#{user}-institutionCode-#{institution}:#{password}").gsub("\n", '')
+ @auth = "Basic #{code}"
end
def get_heart_bit
request :get_heart_bit
end
protected
def call_raw(operation, args = {})
- data = if @basic_auth
- request operation.to_s.to_sym, args, headers: ['Authenticate', @basic_auth]
+ data = if @auth
+ request operation.to_s.to_sym, args, headers: {'Authorization' => @auth}
else
request operation.to_s.to_sym, args
end
# remove wrapper
@@ -63,11 +71,11 @@
if data.is_a?(String)
xml_data = Libis::Tools::XmlDocument.parse(data).to_hash(
empty_tag_value: nil,
delete_namespace_attributes: true,
strip_namespaces: true,
- convert_tags_to: lambda { |tag| tag.to_sym }
+ convert_tags_to: lambda {|tag| tag.to_sym}
)
data = xml_data unless xml_data.empty?
end
return data unless data.is_a?(Hash)
@@ -106,10 +114,10 @@
data.is_a?(Array) ? data : []
end
def request_object_array(method, klass, args = {})
data = request_array(method, args)
- data.map { |x| klass.new(x) }
+ data.map {|x| klass.new(x)}
end
end
end