lib/esendex4soap.rb in esendex4soap-0.4.2 vs lib/esendex4soap.rb in esendex4soap-0.4.3

- old
+ new

@@ -1,12 +1,10 @@ # -*- encoding : utf-8 -*- require 'savon' -require 'log4r' module Esendex class Client - include Log4r INBOX_SERVICE_WSDL = 'https://www.esendex.com/secure/messenger/soap/InboxService.asmx?wsdl' SEND_SERVICE_WSDL = 'https://www.esendex.com/secure/messenger/soap/SendService.asmx?wsdl' attr_accessor :username, :password, :account_reference attr_reader :sent_message_ids @@ -22,31 +20,23 @@ config.log = false config.log_level = :error HTTPI.log = false end - @log = Logger.new "#{self.class.name}" - @log.outputters = Outputter.stdout - @log.level = ERROR - @message_kind = String.new end def send_message(recipient, text) - @log.debug "------- Going to deliver #{text.size} bytes long message" if text.size < 140 - @log.debug "#{text.size} is < 140" sms(recipient, text.to_a) elsif text.scan(/./mu).size == text.size - @log.debug "Processing non-UTF8 message" sms_parts = text.scan(/.{610}/mu) sms_parts << text[sms_parts.to_s.size..text.size] @message_kind = 'Text' sms(recipient, sms_parts) else - @log.debug "Processing UTF-8 message" sms_parts = text.scan(/.{70}/mu) sms_parts << text[sms_parts.to_s.size..text.size] @message_kind = 'Unicode' sms(recipient, sms_parts) end @@ -58,17 +48,14 @@ @client.http.auth.ssl.verify_mode=(:none) end def sms(recipient, messages) connect - @log.debug "*#{@message_kind}*" # message: #{messages.join('|<->|')}" messages.each do |message| - @log.debug "Sending message _ #{message.size} bytes long" resp = @client.request :com, :send_message_full do |soap| soap.header["com:MessengerHeader"] = {"com:Username" => @username, "com:Password" => @password, "com:Account" => @account_reference} soap.body = {"com:recipient" => recipient, "com:body" => message, "com:type" => @message_kind} end - @log.debug "Message sent" @sent_message_ids << resp.to_hash[:send_message_full_response][:send_message_full_result] end end end #module Client