mblox 0.2.8 → 0.2.9
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/README.md +1 -1
- data/lib/mblox/sms.rb +7 -1
- data/lib/mblox/version.rb +1 -1
- data/spec/sms_spec.rb +25 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ODgwZjU3MWFlNWUzYjI1OTAxNzBlY2MwMmI0NTNhZmE0Y2M1YjMxMw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
OGVkNTE1ZWRmZjY1ZmRkN2JlMmJlYmU2MTQ1ZmQyMjEzODExYzdmMg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
OGYyYjhlNjQxNjljM2Q5M2I3NDZjZGZmZmMzNGU4Y2I0ZDdmZDQ5ZmMzN2Y3
|
10
|
+
YzlmODE1YjFmZTI1YWU2M2I5MmEwMWJiYTM0ZjRlNmRmMjlhMzQ0M2NmZjFk
|
11
|
+
MDdjMmQyMjY4OTgxMmJjOWI1MWJhNDRmOThjOTg0NmRkNjk5ZWM=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NWUyMTNkZTVjZDYxOTg2MTVmNTdlMTdlYjZhZDNmNWY5YjgyMGQ5NDBkZDli
|
14
|
+
ZWNlN2I4OWYwMWUxMzY2N2IwYzhiMjI1OGZmNWY5ZDcyYzU5NTMzMWJjNjFk
|
15
|
+
ZGM0MDI1MTFlYTdhOGM4NmM5MjQ5YTQzY2M1MDAwMjY0YjA1YTc=
|
data/README.md
CHANGED
@@ -56,7 +56,7 @@ Copy config.yml.example to config.yml and set all the values in that file. Run:
|
|
56
56
|
|
57
57
|
rspec
|
58
58
|
|
59
|
-
You should recieve
|
59
|
+
You should recieve 6 SMS messages to your phone within several seconds.
|
60
60
|
|
61
61
|
## Contributing
|
62
62
|
|
data/lib/mblox/sms.rb
CHANGED
@@ -10,6 +10,7 @@ module Mblox
|
|
10
10
|
class InvalidPhoneNumberError < ::ArgumentError; end
|
11
11
|
class InvalidMessageError < ::ArgumentError; end
|
12
12
|
class BatchIdOutOfRangeError < ::ArgumentError; end
|
13
|
+
class InvalidSenderIdError < ::ArgumentError; end
|
13
14
|
MAX_LENGTH = 160
|
14
15
|
MAX_SECTION_LENGTH = MAX_LENGTH - "(MSG XXX/XXX): ".size
|
15
16
|
LEGAL_CHARACTERS = "~\`!\"#\$\%&'\(\)*+,-.\/:;<=>?@_£¤¥§¿i¡ÄÅÆÇÉÑÖØÜßáäåæèéìñòöøóùüú\n\r\tí "
|
@@ -37,6 +38,11 @@ module Mblox
|
|
37
38
|
@batch_id = batch_id.to_i unless batch_id.blank?
|
38
39
|
end
|
39
40
|
|
41
|
+
def send_from(_)
|
42
|
+
raise InvalidSenderIdError, "You can only send from a 5-digit shortcode" unless ((_.is_a?(Fixnum) || _.is_a?(String)) && 5 == _.to_i.to_s.size)
|
43
|
+
@sender_id = _.to_i.to_s
|
44
|
+
end
|
45
|
+
|
40
46
|
def send
|
41
47
|
@message.collect { |message| commit build(message) }
|
42
48
|
end
|
@@ -64,7 +70,7 @@ module Mblox
|
|
64
70
|
m.cdata!(message)
|
65
71
|
end
|
66
72
|
n.Profile(Mblox.config.profile_id)
|
67
|
-
n.SenderID(Mblox.config.sender_id, :Type => :Shortcode)
|
73
|
+
n.SenderID(@sender_id || Mblox.config.sender_id, :Type => :Shortcode)
|
68
74
|
n.Tariff(Mblox.config.tariff)
|
69
75
|
n.Subscriber do |s|
|
70
76
|
s.SubscriberNumber(@phone)
|
data/lib/mblox/version.rb
CHANGED
data/spec/sms_spec.rb
CHANGED
@@ -184,4 +184,29 @@ describe Mblox::Sms do
|
|
184
184
|
expect{Mblox::Sms.new(LANDLINE,the_message, 100000000)}.to raise_error(Mblox::Sms::BatchIdOutOfRangeError, 'batch_id must be in the range 1 to 99999999. The batch_id specified (100000000) is out of range.')
|
185
185
|
end
|
186
186
|
end
|
187
|
+
|
188
|
+
describe "send from" do
|
189
|
+
before(:each) do
|
190
|
+
@sms = Mblox::Sms.new(TEST_NUMBER,'This message should come from shortcode 55555')
|
191
|
+
end
|
192
|
+
def raise_invalid_sender_id_error
|
193
|
+
raise_error(Mblox::Sms::InvalidSenderIdError, 'You can only send from a 5-digit shortcode')
|
194
|
+
end
|
195
|
+
it "should not allow a 4-digit number" do
|
196
|
+
expect{@sms.send_from(1234)}.to raise_invalid_sender_id_error
|
197
|
+
end
|
198
|
+
it "should not allow a 6-digit number" do
|
199
|
+
expect{@sms.send_from(123456)}.to raise_invalid_sender_id_error
|
200
|
+
end
|
201
|
+
it "should not allow a blank string" do
|
202
|
+
expect{@sms.send_from('')}.to raise_invalid_sender_id_error
|
203
|
+
end
|
204
|
+
it "should not allow a float" do
|
205
|
+
expect{@sms.send_from(12345.6)}.to raise_invalid_sender_id_error
|
206
|
+
end
|
207
|
+
it "should send from the value" do
|
208
|
+
expect{@sms.send_from(55555)}.to_not raise_error
|
209
|
+
@sms.send.first.ok?.should be_true
|
210
|
+
end
|
211
|
+
end
|
187
212
|
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.9
|
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-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -176,7 +176,7 @@ summary: ! '# Mblox This gem is for subscribers to Mblox to send SMS messages.
|
|
176
176
|
to sending to must be a 10-digit number, including the area code. Can be a String
|
177
177
|
or Fixnum. phone_number = 2225555555 # or: phone_number = "2225555555" Mblox::Sms.new(phone_number,
|
178
178
|
"your message").send ## Testing Copy config.yml.example to config.yml and set
|
179
|
-
all the values in that file. Run: rspec You should recieve
|
179
|
+
all the values in that file. Run: rspec You should recieve 6 SMS messages to
|
180
180
|
your phone within several seconds. ## Contributing 1. Fork it 2. Create your feature
|
181
181
|
branch (`git checkout -b my-new-feature`) 3. Commit your changes (`git commit -am
|
182
182
|
''Add some feature''`) 4. Push to the branch (`git push origin my-new-feature`)
|