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 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
 
@@ -6,6 +6,10 @@ module Providers
6
6
  MultiSms.config
7
7
  end
8
8
 
9
+ private
10
+ def method_missing(m, *args, &block)
11
+ self.class.const_get(:API_VERSION)
12
+ end
9
13
  end
10
14
 
11
15
  end
@@ -1,3 +1,3 @@
1
1
  module MultiSms
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
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,})$/)
@@ -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
- end
23
+
24
+ end
@@ -27,4 +27,8 @@ describe Providers::Clickatell do
27
27
  end
28
28
  end
29
29
 
30
+ it "should respond to version" do
31
+ provider.version.should eql ""
32
+ end
33
+
30
34
  end
@@ -24,5 +24,7 @@ describe Providers::Elk do
24
24
  # MultiSms.logger.info provider.send(to: '+46730393200', message: 'testmessage', from: "signlapps")
25
25
  end
26
26
  end
27
-
27
+ it "should respond to version" do
28
+ provider.version.should eql "a1"
29
+ end
28
30
  end
@@ -26,4 +26,8 @@ describe Providers::Twilio do
26
26
  end
27
27
  end
28
28
 
29
+ it "should respond to version" do
30
+ provider.version.should eql "2010-04-01"
31
+ end
32
+
29
33
  end
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.2
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: 3870457680915898508
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: 3870457680915898508
242
+ hash: 3864534140144719119
243
243
  requirements: []
244
244
  rubyforge_project: multi_sms
245
245
  rubygems_version: 1.8.24