ballou_sms_gateway 1.0.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/Readme.md CHANGED
@@ -52,8 +52,8 @@ The `send!` method returns a request object with the following methods.
52
52
  - **request_id** (String) Request ID defined by you using the `request_id` method, or an auto-generated UUID string.
53
53
  - **sms_id** (String) ID defined by you using the `id` method, or an auto-generated UUID string.
54
54
  - **to** (String) Receiver specified by you using the `to` method.
55
- - **send?** (Boolean) Was the SMS send?
56
- - **valid?** (Boolean) Alias for `send?`.
55
+ - **sent?** (Boolean) Was the SMS sent?
56
+ - **valid?** (Boolean) Alias for `sent?`.
57
57
  - **error** (Fixnum) Error code. `0` if everything went okay.
58
58
  - **status** (Fixnum) Status code. `-1` means that the SMS was added to Ballou's queue.
59
59
  - **message** (String) A message from Ballou. This is set when a request goes wrong.
@@ -10,7 +10,7 @@ Gem::Specification.new do |gem|
10
10
  gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
11
11
  gem.name = "ballou_sms_gateway"
12
12
  gem.require_paths = ["lib"]
13
- gem.version = "1.0.0"
13
+ gem.version = "2.0.0"
14
14
 
15
15
  gem.add_dependency("rest-client", "~> 1.6.7")
16
16
  gem.add_dependency("uuid", "~> 2.3.4")
@@ -7,7 +7,7 @@ module BallouSmsGatewayModule
7
7
  #
8
8
  # @return Boolean Did everything went okay?
9
9
  #
10
- def send?
10
+ def sent?
11
11
  error == 0
12
12
  end
13
13
 
@@ -19,6 +19,6 @@ module BallouSmsGatewayModule
19
19
  @error.to_i
20
20
  end
21
21
 
22
- alias_method :valid?, :send?
22
+ alias_method :valid?, :sent?
23
23
  end
24
24
  end
@@ -92,14 +92,14 @@ class BallouSmsGateway
92
92
  #
93
93
  # @to A list of phonenumbers. Can contain 0-9 and the "+" sign.
94
94
  # @return BallouSmsGateway
95
- def to(*to)
96
- to.flatten.each do |number|
95
+ def to(*receivers)
96
+ receivers.flatten.each do |number|
97
97
  unless number.to_s.match(/^\+?[0-9]{4,}$/)
98
98
  raise "Invalid receiver."
99
99
  end
100
100
  end
101
101
 
102
- @to = to.flatten.map { |number| number }.join(",")
102
+ @to = receivers.flatten.join(",")
103
103
  return self
104
104
  end
105
105
 
@@ -107,21 +107,21 @@ class BallouSmsGateway
107
107
  # @from String Sender. Max length when only numbers are submitet; 15, otherwise; 10
108
108
  # @return BallouSmsGateway
109
109
  #
110
- def from(from)
111
- if from.to_s.length.zero?
110
+ def from(sender)
111
+ if sender.to_s.length.zero?
112
112
  raise "Sender is invalid, to short."
113
113
  end
114
114
 
115
115
  # Max length 15 for integers and 10 for chars
116
- if from.match(/^[0-9]+$/)
117
- if from.length > 15
116
+ if sender.match(/^[0-9]+$/)
117
+ if sender.length > 15
118
118
  raise "Sender is invalid, to long."
119
119
  end
120
- elsif from.length > 10
120
+ elsif sender.length > 10
121
121
  raise "Sender is invalid, to long."
122
122
  end
123
123
 
124
- @from = from
124
+ @from = sender
125
125
  return self
126
126
  end
127
127
 
@@ -145,7 +145,7 @@ describe BallouSmsGateway do
145
145
  request.status.should eq(-1)
146
146
  request.error.should eq(0)
147
147
  request.message.should be_empty
148
- request.should be_send
148
+ request.should be_sent
149
149
  end
150
150
 
151
151
  it "should send message to invalid receiver" do
@@ -164,7 +164,7 @@ describe BallouSmsGateway do
164
164
  request.sms_id.should eq(id)
165
165
  request.request_id.should eq(request_id)
166
166
  request.error.should eq(3)
167
- request.should_not be_send
167
+ request.should_not be_sent
168
168
  end
169
169
 
170
170
  it "should be able to handle request errors" do
@@ -184,7 +184,7 @@ describe BallouSmsGateway do
184
184
  request.sms_id.should eq(id)
185
185
  request.request_id.should eq(request_id)
186
186
  request.error.should eq(7)
187
- request.should_not be_send
187
+ request.should_not be_sent
188
188
  request.message.should eq("404 Resource Not Found")
189
189
  end
190
190
  end
@@ -204,7 +204,7 @@ describe BallouSmsGateway do
204
204
  send!
205
205
 
206
206
  request.should_not be_valid
207
- request.should_not be_send
207
+ request.should_not be_sent
208
208
  request.error.should eq(2)
209
209
  request.status.should eq(-2)
210
210
  request.message.should eq("Authentication failed or IP rejected")
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: ballou_sms_gateway
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 1.0.0
5
+ version: 2.0.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - Linus Oleander