esendex4soap 0.4.2 → 0.4.3
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/esendex4soap.gemspec +1 -1
- data/lib/esendex4soap.rb +0 -13
- metadata +1 -1
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.4.
|
1
|
+
0.4.3
|
data/esendex4soap.gemspec
CHANGED
data/lib/esendex4soap.rb
CHANGED
@@ -1,10 +1,8 @@
|
|
1
1
|
# -*- encoding : utf-8 -*-
|
2
2
|
require 'savon'
|
3
|
-
require 'log4r'
|
4
3
|
|
5
4
|
module Esendex
|
6
5
|
class Client
|
7
|
-
include Log4r
|
8
6
|
INBOX_SERVICE_WSDL = 'https://www.esendex.com/secure/messenger/soap/InboxService.asmx?wsdl'
|
9
7
|
SEND_SERVICE_WSDL = 'https://www.esendex.com/secure/messenger/soap/SendService.asmx?wsdl'
|
10
8
|
|
@@ -24,27 +22,19 @@ module Esendex
|
|
24
22
|
HTTPI.log = false
|
25
23
|
end
|
26
24
|
|
27
|
-
@log = Logger.new "#{self.class.name}"
|
28
|
-
@log.outputters = Outputter.stdout
|
29
|
-
@log.level = ERROR
|
30
|
-
|
31
25
|
@message_kind = String.new
|
32
26
|
|
33
27
|
end
|
34
28
|
|
35
29
|
def send_message(recipient, text)
|
36
|
-
@log.debug "------- Going to deliver #{text.size} bytes long message"
|
37
30
|
if text.size < 140
|
38
|
-
@log.debug "#{text.size} is < 140"
|
39
31
|
sms(recipient, text.to_a)
|
40
32
|
elsif text.scan(/./mu).size == text.size
|
41
|
-
@log.debug "Processing non-UTF8 message"
|
42
33
|
sms_parts = text.scan(/.{610}/mu)
|
43
34
|
sms_parts << text[sms_parts.to_s.size..text.size]
|
44
35
|
@message_kind = 'Text'
|
45
36
|
sms(recipient, sms_parts)
|
46
37
|
else
|
47
|
-
@log.debug "Processing UTF-8 message"
|
48
38
|
sms_parts = text.scan(/.{70}/mu)
|
49
39
|
sms_parts << text[sms_parts.to_s.size..text.size]
|
50
40
|
@message_kind = 'Unicode'
|
@@ -60,14 +50,11 @@ module Esendex
|
|
60
50
|
|
61
51
|
def sms(recipient, messages)
|
62
52
|
connect
|
63
|
-
@log.debug "*#{@message_kind}*" # message: #{messages.join('|<->|')}"
|
64
53
|
messages.each do |message|
|
65
|
-
@log.debug "Sending message _ #{message.size} bytes long"
|
66
54
|
resp = @client.request :com, :send_message_full do |soap|
|
67
55
|
soap.header["com:MessengerHeader"] = {"com:Username" => @username, "com:Password" => @password, "com:Account" => @account_reference}
|
68
56
|
soap.body = {"com:recipient" => recipient, "com:body" => message, "com:type" => @message_kind}
|
69
57
|
end
|
70
|
-
@log.debug "Message sent"
|
71
58
|
@sent_message_ids << resp.to_hash[:send_message_full_response][:send_message_full_result]
|
72
59
|
end
|
73
60
|
end
|