lib/mailarchiva/soap_client.rb in mailarchiva-0.0.5 vs lib/mailarchiva/soap_client.rb in mailarchiva-0.0.6

- old
+ new

@@ -1,7 +1,7 @@ require 'mailarchiva/base' -require 'mailarchiva/message' +require 'message' require 'savon' module Mailarchiva class SoapClient < Base @@ -12,12 +12,12 @@ def initialize(args) super(args) end - def search(params={}) - params.reverse_merge!({blob_category: 'email', max_results: 1000}) + def search(params) + params = {blob_category: 'email', max_results: 1000}.merge(params) params[:sent_before] = params[:sent_before].strftime("%Y-%m-%dT%T") if params.has_key?(:sent_before) && params[:sent_before].is_a?(Time) params[:sent_after] = params[:sent_after].strftime("%Y-%m-%dT%T") if params.has_key?(:sent_after) && params[:sent_after].is_a?(Time) search_response = soap_client.call(:search, message: params) search_results = search_results_from_response(search_response) logout @@ -42,10 +42,10 @@ decoded_message = Base64.decode64(encoded_message) Mail.new(decoded_message) end def wsdl - "%s://%s:%s/services/search?wsdl" % [ssl ? 'https' : 'http', host, port] + "%s://%s:%s/services/search?wsdl" % [@ssl ? 'https' : 'http', @host, @port] end def soap_client @soap_client ||= begin auth_cookies = login(Savon.client(wsdl: wsdl)) \ No newline at end of file