multi_sms 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Readme.md +12 -1
- data/lib/multi_sms/providers/sms_provider.rb +4 -0
- data/lib/multi_sms/version.rb +1 -1
- data/lib/multi_sms.rb +7 -1
- data/spec/multi_sms_spec.rb +6 -1
- data/spec/providers/clickatell_spec.rb +4 -0
- data/spec/providers/elk_spec.rb +3 -1
- data/spec/providers/twilio_spec.rb +4 -0
- metadata +3 -3
data/Readme.md
CHANGED
@@ -32,6 +32,13 @@ gem install multi_sms
|
|
32
32
|
Sample configuration for two providers and a default/fallback provider:
|
33
33
|
|
34
34
|
```ruby
|
35
|
+
# Clickatell
|
36
|
+
MultiSms.config do |config|
|
37
|
+
config.clickatell.username = ENV['ELK_USERNAME']
|
38
|
+
config.clickatell.password = ENV['ELK_PASSWORD']
|
39
|
+
config.clickatell.api_id = ENV['CLICKATELL_API_ID']
|
40
|
+
end
|
41
|
+
|
35
42
|
# 46Elks
|
36
43
|
MultiSms.config do |config|
|
37
44
|
config.elk.username = ENV['ELK_USERNAME']
|
@@ -55,6 +62,10 @@ A complete sample config:
|
|
55
62
|
|
56
63
|
```ruby
|
57
64
|
MultiSms.config do |config|
|
65
|
+
config.clickatell.username = ENV['ELK_USERNAME']
|
66
|
+
config.clickatell.password = ENV['ELK_PASSWORD']
|
67
|
+
config.clickatell.api_id = ENV['CLICKATELL_API_ID']
|
68
|
+
|
58
69
|
config.elk.username = ENV['ELK_USERNAME']
|
59
70
|
config.elk.password = ENV['ELK_PASSWORD']
|
60
71
|
|
@@ -62,7 +73,7 @@ MultiSms.config do |config|
|
|
62
73
|
config.twilio.auth_token = ENV['TWILIO_AUTH_TOKEN']
|
63
74
|
|
64
75
|
config.default_provider = "Elk"
|
65
|
-
config.providers = { "46" => "Twilio", "47" => "Elk" }
|
76
|
+
config.providers = { "46" => "Twilio", "47" => "Elk", "1" => "Clickatell" }
|
66
77
|
end
|
67
78
|
```
|
68
79
|
|
data/lib/multi_sms/version.rb
CHANGED
data/lib/multi_sms.rb
CHANGED
@@ -30,6 +30,11 @@ module MultiSms
|
|
30
30
|
|
31
31
|
attr_accessor :config
|
32
32
|
|
33
|
+
# Responds with all the currently supported providers
|
34
|
+
def providers
|
35
|
+
%W(Clickatell Elk Twilio)
|
36
|
+
end
|
37
|
+
|
33
38
|
# Yields up a configuration object when given a block.
|
34
39
|
# Without a block it just returns the configuration object.
|
35
40
|
# Uses Configatron under the covers.
|
@@ -46,6 +51,7 @@ module MultiSms
|
|
46
51
|
end
|
47
52
|
|
48
53
|
def send(country_code, parameters)
|
54
|
+
verify_parameters(parameters, [:from, :message, :to])
|
49
55
|
provider = get_provider country_code
|
50
56
|
provider.send(parameters)
|
51
57
|
end
|
@@ -60,6 +66,7 @@ module MultiSms
|
|
60
66
|
|
61
67
|
def get_provider(country_code)
|
62
68
|
name = config.providers[country_code.to_s]
|
69
|
+
name = config.default_provider unless name
|
63
70
|
provider = "Providers::#{name}".split('::').inject(Object) {|o,c| o.const_get c}
|
64
71
|
provider.new
|
65
72
|
end
|
@@ -80,7 +87,6 @@ module MultiSms
|
|
80
87
|
# * Handles some exceptions
|
81
88
|
#
|
82
89
|
def execute(base_url, method, path, parameters, headers={ accept: :json}, &block)
|
83
|
-
verify_parameters(parameters, [:from, :message, :to])
|
84
90
|
|
85
91
|
# Warn if the from string will be capped by the sms gateway
|
86
92
|
if parameters[:from] && parameters[:from].match(/^(\w{11,})$/)
|
data/spec/multi_sms_spec.rb
CHANGED
@@ -7,6 +7,10 @@ describe MultiSms do
|
|
7
7
|
end
|
8
8
|
end
|
9
9
|
|
10
|
+
it "should respond to providers" do
|
11
|
+
MultiSms.providers.should eql ["Clickatell", "Elk", "Twilio"]
|
12
|
+
end
|
13
|
+
|
10
14
|
it "should get provider based on swedish country code" do
|
11
15
|
provider = MultiSms.get_provider 46
|
12
16
|
provider.should be_an_instance_of Providers::Elk
|
@@ -16,4 +20,5 @@ describe MultiSms do
|
|
16
20
|
provider = MultiSms.get_provider 47
|
17
21
|
provider.should be_an_instance_of Providers::Twilio
|
18
22
|
end
|
19
|
-
|
23
|
+
|
24
|
+
end
|
data/spec/providers/elk_spec.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: multi_sms
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -230,7 +230,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
230
230
|
version: '0'
|
231
231
|
segments:
|
232
232
|
- 0
|
233
|
-
hash:
|
233
|
+
hash: 3864534140144719119
|
234
234
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
235
235
|
none: false
|
236
236
|
requirements:
|
@@ -239,7 +239,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
239
239
|
version: '0'
|
240
240
|
segments:
|
241
241
|
- 0
|
242
|
-
hash:
|
242
|
+
hash: 3864534140144719119
|
243
243
|
requirements: []
|
244
244
|
rubyforge_project: multi_sms
|
245
245
|
rubygems_version: 1.8.24
|