./lib/ews/transporter.rb in exact4r-1.4 vs ./lib/ews/transporter.rb in exact4r-1.5

- old
+ new

@@ -1,6 +1,7 @@ require 'net/https' +require 'uri' require File.dirname(__FILE__) + '/certificate_helper' module EWS # :nodoc: # A Transporter is responsible for communicating with the E-xact Web Service in @@ -53,11 +54,11 @@ transport_details = @@transport_types[transport_type] request = build_http_request(transaction, transport_type, transport_details[:suffix]) request.basic_auth(transaction.gateway_id, transaction.password) request.add_field "Accept", transport_details[:content_type] - request.add_field "User-Agent", "exact4r v1.4" + request.add_field "User-Agent", "exact4r v1.5" request.add_field "Content-type", "#{transport_details[:content_type]}; charset=UTF-8" response = get_connection.request(request) case response @@ -92,10 +93,17 @@ soapaction = (transaction.is_find_transaction?) ? "TransactionInfo" : "SendAndCommit" req.add_field "soapaction", "http://secure2.e-xact.com/vplug-in/transaction/rpc-enc/#{soapaction}" end req.body = EWS::Transaction::Mapping.send "request_to_#{transport_type.to_s}", transaction else - req = Net::HTTP::Get.new(@url.path + "/transaction/#{transaction.transaction_tag}.#{request_suffix}") + param_str = "" + escaping_regex = Regexp.new("[^#{URI::PATTERN::UNRESERVED}]") + params = [:authorization_num, :reference_no].collect do |attr_name| + value = transaction.send(attr_name) + value.blank? ? nil : "#{attr_name}=" + URI.escape(value, escaping_regex) + end.compact + param_str = "?"+params.join('&') unless params.empty? + req = Net::HTTP::Get.new(@url.path + "/transaction/#{transaction.transaction_tag}.#{request_suffix}"+param_str) end req end def get_connection