lib/libis/services/rosetta/client.rb in libis-services-0.1.11 vs lib/libis/services/rosetta/client.rb in libis-services-0.1.12

- old
+ new

@@ -1,8 +1,10 @@ # coding: utf-8 require 'awesome_print' +require 'httpclient' +require 'base64' require 'libis/tools/extend/hash' require 'libis/tools/config' require 'libis/tools/logger' @@ -24,17 +26,25 @@ def pds_handle=(handle) @pds_handle = handle end + def authenticate(user, password, institution) + @basic_auth = Base64.encode64 "#{user}-institutionCode-#{institution}:#{password}" + end + def get_heart_bit request :get_heart_bit end protected def call_raw(operation, args = {}) - data = request operation.to_s.to_sym, args + data = if @basic_auth + request operation.to_s.to_sym, args, headers: ['Authenticate', @basic_auth] + else + request operation.to_s.to_sym, args + end # remove wrapper data = data["#{operation}_response".to_sym] data.delete(:'@xmlns:ns1')