lib/rews/util.rb in rews-0.2.12 vs lib/rews/util.rb in rews-0.5.0

- old
+ new

@@ -61,10 +61,20 @@ # camel-case the keys of a +Hash+ def camel_keys(h) Hash[h.map{|k,v| [camelize(k.to_s), v]}] end + # convert rsxml to xml, transforming tags to CamelCase and prefixing with + # the t: namespace prefix + def rsxml_to_xml(sexp) + Rsxml.to_xml(sexp) do |tag, attrs| + ttag = "t:#{camelize(tag.to_s)}" + tattrs = Hash[attrs.map{|k,v| [camelize(k.to_s), v]}] + [ttag, tattrs] + end + end + # check the response codes of an Exchange Web Services request. # the supplied block makes a SOAP request, and the response is parsed # out and checked def with_error_check(client, *response_msg_keys) raise "no block" if !block_given? @@ -80,11 +90,11 @@ all_statuses = [statuses] end errors = all_statuses.map{|s| single_error_check(client, s)}.compact rescue Exception=>e - client.log{|logger| logger.warn(e)} + Rews.log{|logger| logger.warn(e)} tag_exception(e, :savon_response=>response) raise e end raise Error.new(errors.join("\n")) if !errors.empty? @@ -100,10 +110,10 @@ end if status[:response_class] == "Error" return "#{status[:response_code]} - #{status[:message_text]}" elsif status[:response_class] == "Warning" - client.log{|logger| logger.warn("#{status[:response_code]} - #{status[:message_text]}")} + Rews.log{|logger| logger.warn("#{status[:response_code]} - #{status[:message_text]}")} end end end end