mblox 0.4.1 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +8 -8
- data/lib/mblox.rb +3 -0
- data/lib/mblox/sms.rb +8 -4
- data/lib/mblox/version.rb +1 -1
- data/mblox.gemspec +1 -1
- data/spec/sms_spec.rb +55 -14
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
Nzk1MWJlNGZlNzNhZWU2YTQ3OTMxNDUzYmRiMTk1MDYyNGE5YmI2YQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NmVmM2U3MTdhYWE3NDdkZGMwNjgzOGE3NTkxNjE3YTM3MTE0YWZiMg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NDhlYjI3ODQwNTI0MGM3MmE4YzdkZjczMmQ3ZTY5YzY0YTA0NzZhMjkwMDA4
|
10
|
+
MmJmNGNiYzk2NTk1Nzc5NjdlYmM4NTQyMDExZTk4ZTE1YTMwMjg5ZWU2ODE4
|
11
|
+
OGE1YzFjZjliZjdjMDhmMjBmYjQyNDhiM2MwZDljZGViMmU2NDA=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YzdiNDQ0MzI1MDA3MTYyN2NlZmNjYzdiNDQ0MDY2MGM4ODU4YTQ5MzFkYTIy
|
14
|
+
OTg3MDIzNmQzZTczNjJkNzg2ZDUzYzRiZjUxY2M5YWRmZDZiYmUzMmRkYmZj
|
15
|
+
MTYzNTA2NTBiMWJkZjAyMTQ0ZmI2ZDkzNTE4NTk1YmZkNTdlNDg=
|
data/lib/mblox.rb
CHANGED
data/lib/mblox/sms.rb
CHANGED
@@ -38,9 +38,13 @@ module Mblox
|
|
38
38
|
@batch_id = batch_id.to_i unless batch_id.blank?
|
39
39
|
end
|
40
40
|
|
41
|
-
def send_from(
|
42
|
-
raise InvalidSenderIdError, "You can only send from a 5-digit shortcode" unless
|
43
|
-
@sender_id =
|
41
|
+
def send_from(sender_id, service_id=nil)
|
42
|
+
raise InvalidSenderIdError, "You can only send from a 5-digit shortcode" unless Mblox.is_a_five_digit_number?(sender_id)
|
43
|
+
@sender_id = sender_id.to_i.to_s
|
44
|
+
unless service_id.nil?
|
45
|
+
raise InvalidSenderIdError, "You can only send using a 5-digit service ID. Leave out the 2nd argument of send_from to use the globally configured '#{Mblox.config.service_id}'" unless Mblox.is_a_five_digit_number?(service_id)
|
46
|
+
@service_id = service_id.to_i.to_s
|
47
|
+
end
|
44
48
|
end
|
45
49
|
|
46
50
|
def send
|
@@ -75,7 +79,7 @@ module Mblox
|
|
75
79
|
n.Subscriber do |s|
|
76
80
|
s.SubscriberNumber(@phone)
|
77
81
|
end
|
78
|
-
n.ServiceId(Mblox.config.service_id)
|
82
|
+
n.ServiceId(@service_id || Mblox.config.service_id)
|
79
83
|
end
|
80
84
|
end
|
81
85
|
end
|
data/lib/mblox/version.rb
CHANGED
data/mblox.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.email = ["iybetesh@gmail.com"]
|
11
11
|
spec.description = "Send SMS messages"
|
12
12
|
spec.summary = `cat README.md`
|
13
|
-
spec.homepage = ""
|
13
|
+
spec.homepage = "https://github.com/betesh/mblox/"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
16
16
|
spec.files = `git ls-files`.split($/)
|
data/spec/sms_spec.rb
CHANGED
@@ -189,24 +189,65 @@ describe Mblox::Sms do
|
|
189
189
|
before(:each) do
|
190
190
|
@sms = Mblox::Sms.new(TEST_NUMBER,'This message should come from shortcode 55555')
|
191
191
|
end
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
192
|
+
|
193
|
+
describe "sender_id" do
|
194
|
+
def raise_invalid_sender_id_error
|
195
|
+
raise_error(Mblox::Sms::InvalidSenderIdError, 'You can only send from a 5-digit shortcode')
|
196
|
+
end
|
197
|
+
it "cannot be a 4-digit number" do
|
198
|
+
expect{@sms.send_from(1234)}.to raise_invalid_sender_id_error
|
199
|
+
end
|
200
|
+
it "cannot be a 6-digit number" do
|
201
|
+
expect{@sms.send_from(123456)}.to raise_invalid_sender_id_error
|
202
|
+
end
|
203
|
+
it "cannot be a blank string" do
|
204
|
+
expect{@sms.send_from('')}.to raise_invalid_sender_id_error
|
205
|
+
end
|
206
|
+
it "cannot be a float" do
|
207
|
+
expect{@sms.send_from(12345.6)}.to raise_invalid_sender_id_error
|
208
|
+
end
|
209
|
+
it "cannot be nil" do
|
210
|
+
expect{@sms.send_from(nil)}.to raise_invalid_sender_id_error
|
211
|
+
end
|
203
212
|
end
|
204
|
-
|
205
|
-
|
213
|
+
|
214
|
+
describe "service_id" do
|
215
|
+
def raise_invalid_service_id
|
216
|
+
raise_error(Mblox::Sms::InvalidSenderIdError, "You can only send using a 5-digit service ID. Leave out the 2nd argument of send_from to use the globally configured '#{Mblox.config.service_id}'")
|
217
|
+
end
|
218
|
+
it "cannot be a 4-digit number" do
|
219
|
+
expect{@sms.send_from(Mblox.config.sender_id, 1234)}.to raise_invalid_service_id
|
220
|
+
end
|
221
|
+
it "cannot be a 6-digit number" do
|
222
|
+
expect{@sms.send_from(Mblox.config.sender_id, 123456)}.to raise_invalid_service_id
|
223
|
+
end
|
224
|
+
it "cannot be a blank string" do
|
225
|
+
expect{@sms.send_from(Mblox.config.sender_id, '')}.to raise_invalid_service_id
|
226
|
+
end
|
227
|
+
it "cannot be a float" do
|
228
|
+
expect{@sms.send_from(Mblox.config.sender_id, 12345.6)}.to raise_invalid_service_id
|
229
|
+
end
|
230
|
+
it "can be nil" do
|
231
|
+
expect{@sms.send_from(Mblox.config.sender_id, nil)}.to_not raise_error
|
232
|
+
end
|
206
233
|
end
|
207
|
-
|
234
|
+
|
235
|
+
it "should send from the specified sender_id" do
|
236
|
+
@sms.instance_variable_get("@sender_id").should be_nil
|
208
237
|
expect{@sms.send_from(55555)}.to_not raise_error
|
209
238
|
@sms.send.first.ok?.should be_true
|
239
|
+
@sms.instance_variable_get("@sender_id").should == "55555"
|
240
|
+
end
|
241
|
+
|
242
|
+
it "should send from the specified sender_id and service_id" do
|
243
|
+
@sms.instance_variable_get("@service_id").should be_nil
|
244
|
+
expect{@sms.send_from(55555, 44444)}.to_not raise_error
|
245
|
+
response = @sms.send.first
|
246
|
+
response.should_not be_ok
|
247
|
+
response.request.should be_ok
|
248
|
+
response.result.should be_ok
|
249
|
+
response.subscriber_result.should == Mblox::SmsResponse::Result.new(10, "MsipRejectCode=63 Invalid ServiceId:2e Do not retry:2e")
|
250
|
+
@sms.instance_variable_get("@service_id").should == "44444"
|
210
251
|
end
|
211
252
|
end
|
212
253
|
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.4.
|
4
|
+
version: 0.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Isaac Betesh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-02-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -150,7 +150,7 @@ files:
|
|
150
150
|
- spec/sms_response_spec.rb
|
151
151
|
- spec/sms_spec.rb
|
152
152
|
- spec/spec_helper.rb
|
153
|
-
homepage:
|
153
|
+
homepage: https://github.com/betesh/mblox/
|
154
154
|
licenses:
|
155
155
|
- MIT
|
156
156
|
metadata: {}
|