mblox 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/mblox/sms.rb +3 -2
- data/lib/mblox/version.rb +1 -1
- data/spec/sms_spec.rb +30 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NTE2NzFlOTIxYjBiYjA5YWJhNjEyYzk1ZjcwYzQxZDY3NDVhOTFiNw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZDZmNDc0YmVlMzdjM2M4ZGRmNjA5OTFlNzc3YjViNGIzZDRhNGZhNA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
YjdjZDA1YWNjZjg4MDZjN2Y4YmI0NzkwOTk4ODM1Y2ZkNjNlN2FjODliZWQ1
|
10
|
+
MTliNzIyN2VhMGRkZGY0M2JhYWM0YjU1OTU4ZWM4ZTIzODEzYTQ0MzgzMjYw
|
11
|
+
N2NlMmM2Zjc0ZDE5ZDVhZDIwM2EwODY5MjU3ODU4ZWQ2NTAxNWI=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
OWEzYmNjOTU0MjBkYTZiYmRiODBiNTAxMmQyNjlhNzFlOGY3MjRiNmQ3ZTYw
|
14
|
+
MWFlYTEyYWQ4ZmJiYjQ2Y2QzZGY2ZmIxNjNmZDNkNTVhYmQ3ZDk3OGRiMDA3
|
15
|
+
MmQ0NDNjMGUyNmFiZWYyNmJiMzJmZjc5MmFjNTU5NGJmNDBjNjk=
|
data/lib/mblox/sms.rb
CHANGED
@@ -21,7 +21,7 @@ module Mblox
|
|
21
21
|
:split => Proc.new { |message| split_message(message) }
|
22
22
|
}
|
23
23
|
|
24
|
-
def initialize(phone,message)
|
24
|
+
def initialize(phone, message, batch_id=nil)
|
25
25
|
phone = phone.to_s
|
26
26
|
raise InvalidPhoneNumberError, "Phone number must be ten digits" unless /\A[0-9]{10}\z/.match(phone)
|
27
27
|
raise InvalidPhoneNumberError, "Phone number cannot begin with 0 or 1" if ['0','1'].include?(phone[0].to_s)
|
@@ -31,6 +31,7 @@ module Mblox
|
|
31
31
|
Mblox.log "WARNING: Some characters may be lost because the message must be broken into at least 1000 sections" if message.size > (999 * MAX_SECTION_LENGTH)
|
32
32
|
@message = (message.size > MAX_LENGTH) ? ON_MESSAGE_TOO_LONG_HANDLER[Mblox.config.on_message_too_long].call(message) : [message.dup]
|
33
33
|
@phone = "1#{phone}"
|
34
|
+
@batch_id = batch_id.to_i unless batch_id.blank?
|
34
35
|
end
|
35
36
|
|
36
37
|
def send
|
@@ -54,7 +55,7 @@ module Mblox
|
|
54
55
|
nh.PartnerName(Mblox.config.partner_name)
|
55
56
|
nh.PartnerPassword(Mblox.config.password)
|
56
57
|
end
|
57
|
-
nr.NotificationList(:BatchID => 1) do |nl|
|
58
|
+
nr.NotificationList(:BatchID => @batch_id || 1) do |nl|
|
58
59
|
nl.Notification(:SequenceNumber => 1, :MessageType => :SMS, :Format => :UTF8) do |n|
|
59
60
|
n.Message do |m|
|
60
61
|
m.cdata!(message)
|
data/lib/mblox/version.rb
CHANGED
data/spec/sms_spec.rb
CHANGED
@@ -1,6 +1,14 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
require "spec_helper"
|
3
3
|
|
4
|
+
module Mblox
|
5
|
+
class Sms
|
6
|
+
def build_for_test(message)
|
7
|
+
build(message)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
4
12
|
describe Mblox::Sms do
|
5
13
|
def the_message
|
6
14
|
"Mblox gem test sent at #{Time.now}"
|
@@ -134,4 +142,26 @@ describe Mblox::Sms do
|
|
134
142
|
end
|
135
143
|
end
|
136
144
|
end
|
145
|
+
|
146
|
+
describe "batch_id" do
|
147
|
+
it "can be specified" do
|
148
|
+
batch_id = 12345
|
149
|
+
sms = Mblox::Sms.new(LANDLINE,the_message, batch_id)
|
150
|
+
content = Hash.from_xml(sms.build_for_test(the_message))
|
151
|
+
content['NotificationRequest']['NotificationList']['BatchID'].should eq("#{batch_id}")
|
152
|
+
end
|
153
|
+
|
154
|
+
it "get converted to a Fixnum" do
|
155
|
+
batch_id = 12345
|
156
|
+
sms = Mblox::Sms.new(LANDLINE,the_message, "#{batch_id}ab")
|
157
|
+
content = Hash.from_xml(sms.build_for_test(the_message))
|
158
|
+
content['NotificationRequest']['NotificationList']['BatchID'].should eq("#{batch_id}")
|
159
|
+
end
|
160
|
+
|
161
|
+
it "defaults to 1" do
|
162
|
+
sms = Mblox::Sms.new(LANDLINE,the_message)
|
163
|
+
content = Hash.from_xml(sms.build_for_test(the_message))
|
164
|
+
content['NotificationRequest']['NotificationList']['BatchID'].should eq('1')
|
165
|
+
end
|
166
|
+
end
|
137
167
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mblox
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Isaac Betesh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-10-
|
11
|
+
date: 2013-10-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|