lib/esendex4soap.rb in esendex4soap-0.4.30 vs lib/esendex4soap.rb in esendex4soap-0.5.1
- old
+ new
@@ -31,44 +31,43 @@
@message_kind = String.new
end
- def send_message(recipient, text)
- text = text.lstrip.rstrip
+ def send_message(recipient, text, originator, validityperiod)
@log.debug "TO:#{recipient} text size:#{text.size} in #{text.full_lang} language"
-
+ #TODO: handle other languages as well
unless text.full_lang == 'russian'
sms_parts = text.scan(/.{610}/mu)
sms_parts << text[sms_parts.to_s.size..text.size]
@message_kind = 'Text'
@log.debug "#{@message_kind}:#{text.scan(/./mu)} = #{text.size}. #{sms_parts.size} part/s."
- sms(recipient, sms_parts)
+ sms(recipient, sms_parts, originator, validityperiod)
else
sms_parts = text.scan(/.{70}/mu)
sms_parts << text[sms_parts.to_s.size..text.size]
@message_kind = 'Unicode'
@log.debug "#{@message_kind}:#{text.scan(/./mu)} != #{text.size}. #{sms_parts.size} part/s."
- sms(recipient, sms_parts)
+ sms(recipient, sms_parts, originator, validityperiod)
end
end
private
def connect
@client = Savon::Client.new(SEND_SERVICE_WSDL)
#http://jira.codehaus.org/browse/JRUBY-5529 - jruby-openssl in --1.9 jruby mode
@client.http.auth.ssl.verify_mode=(:none)
end
- def sms(recipient, messages)
+ def sms(recipient, messages, originator, validityperiod)
@log.debug "#{@message_kind}:#{messages.size} parts."
connect
messages.each do |message|
@log.debug "#{@message_kind}:#{message.size} bytes. Sending..."
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}
+ soap.body = {"com:recipient" => recipient, "com:body" => message, "com:type" => @message_kind, "com:originator" => originator, "com:validityperiod" => validityperiod}
end
@log.debug "Sent #{@message_kind}:#{recipient}:#{message.size} bytes"
@sent_message_ids << resp.to_hash[:send_message_full_response][:send_message_full_result]
end
@log.debug "-=| #{messages.join(' + ')} |=-"
@@ -78,7 +77,7 @@
end #module Client
end #module Esendex
-#sms = Esendex::Client.new 'username', 'password', 'account_reference'
+#sms = Esendex::Client.new 'username', 'password', 'account_reference', 'from', 'expire int hours'
#sms.send_message 'PHONENUMBER', 'message in any language'