lib/esendex4soap.rb in esendex4soap-0.7.0 vs lib/esendex4soap.rb in esendex4soap-0.7.1
- old
+ new
@@ -1,9 +1,9 @@
# -*- encoding : utf-8 -*-
require 'savon'
require 'log4r'
-#require 'wtf_lang'
+#require 'pry'
require 'api_smith'
module LanguageTools
class DetectLanguageDotCom
include APISmith::Client
@@ -52,11 +52,11 @@
def initialize(*args)
@username = args.shift
@password = args.shift
@account_reference = args.shift
# @detectlanguage_api_key, @alchemyapi_api_key = args.shift, args.shift
- @sent_message_ids, @sent_message_statuses = [], {}
+ @sent_message_ids, @sent_message_statuses = Array.new, Hash.new
@language = LanguageTools::DetectLanguageDotCom.new(args.shift)
Savon.configure do |config|
config.raise_errors = true
@@ -65,11 +65,11 @@
HTTPI.log = false
end
@log = Logger.new "#{self.class.name}"
@log.outputters = Outputter.stdout
- @log.level = DEBUG #ERROR
+ @log.level = ERROR
@message_kind = String.new
end
@@ -112,23 +112,17 @@
end
def get_status(*message_id)
connect unless @client
- if message_id.size > 1
- message_id.each do |id|
- resp = @client.request :com, :get_message_status do |soap|
- soap.header["com:MessengerHeader"] = {"com:Username" => @username, "com:Password" => @password, "com:Account" => @account_reference}
- soap.body = {"com:id" => id.to_s}
- end
- @sent_message_statuses[id] = resp.to_hash[:get_message_status_response][:get_message_status_result]
- end
- else
+ message_id.flatten!
+ message_id.each do |id|
+ @log.debug "#{id.to_s}"
resp = @client.request :com, :get_message_status do |soap|
soap.header["com:MessengerHeader"] = {"com:Username" => @username, "com:Password" => @password, "com:Account" => @account_reference}
- soap.body = {"com:id" => message_id.first}
+ soap.body = {"com:id" => id.to_s}
end
- resp.to_hash[:get_message_status_response][:get_message_status_result]
+ @sent_message_statuses[id] = resp.to_hash[:get_message_status_response][:get_message_status_result]
end
end
private
def connect