multi_sms 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/.rvmrc +32 -0
- data/Gemfile +13 -0
- data/Guardfile +22 -0
- data/License +8 -0
- data/Rakefile +9 -0
- data/Readme.md +87 -0
- data/lib/multi_sms/providers/clickatell.rb +33 -0
- data/lib/multi_sms/providers/elk.rb +24 -0
- data/lib/multi_sms/providers/sms_provider.rb +11 -0
- data/lib/multi_sms/providers/twilio.rb +34 -0
- data/lib/multi_sms/util.rb +10 -0
- data/lib/multi_sms/version.rb +3 -0
- data/lib/multi_sms.rb +113 -0
- data/lib/object.rb +9 -0
- data/multi_sms.gemspec +32 -0
- data/spec/multi_sms_spec.rb +19 -0
- data/spec/providers/clickatell_spec.rb +30 -0
- data/spec/providers/elk_spec.rb +28 -0
- data/spec/providers/twilio_spec.rb +29 -0
- data/spec/spec_helper.rb +20 -0
- metadata +250 -0
data/.gitignore
ADDED
data/.rvmrc
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
rvm use "ruby-1.9.3-p194@multi_sms"
|
3
|
+
|
4
|
+
ruby_string="ruby-1.9.3-p194"
|
5
|
+
gemset_name="multi_sms"
|
6
|
+
|
7
|
+
if rvm list strings | grep -q "${ruby_string}" ; then
|
8
|
+
|
9
|
+
# Load or create the specified environment
|
10
|
+
if [[ -d "${rvm_path:-$HOME/.rvm}/environments" \
|
11
|
+
&& -s "${rvm_path:-$HOME/.rvm}/environments/${ruby_string}@${gemset_name}" ]] ; then
|
12
|
+
\. "${rvm_path:-$HOME/.rvm}/environments/${ruby_string}@${gemset_name}"
|
13
|
+
else
|
14
|
+
rvm --create "${ruby_string}@${gemset_name}"
|
15
|
+
fi
|
16
|
+
|
17
|
+
(
|
18
|
+
# Ensure that Bundler is installed, install it if it is not.
|
19
|
+
if ! command -v bundle ; then
|
20
|
+
gem install bundler
|
21
|
+
fi
|
22
|
+
|
23
|
+
# Bundle while redcing excess noise.
|
24
|
+
bundle
|
25
|
+
)&
|
26
|
+
|
27
|
+
else
|
28
|
+
|
29
|
+
# Notify the user to install the desired interpreter before proceeding.
|
30
|
+
echo "${ruby_string} was not found, please run 'rvm install ${ruby_string}' and then cd back into the project directory."
|
31
|
+
|
32
|
+
fi
|
data/Gemfile
ADDED
data/Guardfile
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
group 'backend' do
|
2
|
+
guard 'bundler' do
|
3
|
+
watch('Gemfile')
|
4
|
+
end
|
5
|
+
guard 'spork', rspec_env: { 'RAILS_ENV' => 'test' }, test_unit: false, cucumber: false, wait: 60 do
|
6
|
+
watch('spec/spec_helper.rb')
|
7
|
+
end
|
8
|
+
|
9
|
+
guard 'rspec', version: 2, cli: '--color --format nested --fail-fast --drb', all_on_start: false, all_after_pass: false do
|
10
|
+
watch('spec/spec_helper.rb') { "spec" }
|
11
|
+
watch(%r{^lib/multi_sms/providers/(.+)\.rb$}) { |m| "spec/providers/#{m[1]}_spec.rb" }
|
12
|
+
watch(%r{^spec/.+_spec\.rb$})
|
13
|
+
watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
14
|
+
watch(%r{^app/(.*)(\.erb|\.haml)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
|
15
|
+
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
# guard 'delayed', :environment => 'development' do
|
21
|
+
# watch(%r{^app/(.+)\.rb})
|
22
|
+
# end
|
data/License
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
Copyright © 2012 Signl Apps Limited, http://www.signlapps.com
|
3
|
+
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
5
|
+
|
6
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
7
|
+
|
8
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
|
data/Rakefile
ADDED
data/Readme.md
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
#multi_sms
|
2
|
+
|
3
|
+
Multi SMS is a simple gem built to handle multiple SMS providers with a unified api to use for sending SMS'es. It allows you to route outgoing SMS'es to different SMS providers based on the country code. It also centralizes the configuration of the actual provider gem's.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Simply add multi_sms to your Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'multi_sms'
|
11
|
+
```
|
12
|
+
|
13
|
+
and from command like just run the bundler:
|
14
|
+
|
15
|
+
```sh
|
16
|
+
bundle install
|
17
|
+
```
|
18
|
+
|
19
|
+
Or you CAN install the gem with the following command:
|
20
|
+
|
21
|
+
```sh
|
22
|
+
gem install multi_sms
|
23
|
+
```
|
24
|
+
|
25
|
+
## Configuration
|
26
|
+
|
27
|
+
1. 46elks
|
28
|
+
2. smsapi.pl - coming
|
29
|
+
3. clickatell - coming
|
30
|
+
4. twilio
|
31
|
+
|
32
|
+
Sample configuration for two providers and a default/fallback provider:
|
33
|
+
|
34
|
+
```ruby
|
35
|
+
# 46Elks
|
36
|
+
MultiSms.config do |config|
|
37
|
+
config.elk.username = ENV['ELK_USERNAME']
|
38
|
+
config.elk.password = ENV['ELK_PASSWORD']
|
39
|
+
end
|
40
|
+
|
41
|
+
# Twilio
|
42
|
+
MultiSms.config do |config|
|
43
|
+
config.twilio.account_sid = ENV['TWILIO_ACCOUNT_SID']
|
44
|
+
config.twilio.auth_token = ENV['TWILIO_AUTH_TOKEN']
|
45
|
+
end
|
46
|
+
|
47
|
+
# Multiple providers
|
48
|
+
MultiSms.config do |config|
|
49
|
+
config.default_provider = "Elk"
|
50
|
+
config.providers = { "46" => "Twilio", "47" => "Elk" }
|
51
|
+
end
|
52
|
+
```
|
53
|
+
|
54
|
+
A complete sample config:
|
55
|
+
|
56
|
+
```ruby
|
57
|
+
MultiSms.config do |config|
|
58
|
+
config.elk.username = ENV['ELK_USERNAME']
|
59
|
+
config.elk.password = ENV['ELK_PASSWORD']
|
60
|
+
|
61
|
+
config.twilio.account_sid = ENV['TWILIO_ACCOUNT_SID']
|
62
|
+
config.twilio.auth_token = ENV['TWILIO_AUTH_TOKEN']
|
63
|
+
|
64
|
+
config.default_provider = "Elk"
|
65
|
+
config.providers = { "46" => "Twilio", "47" => "Elk" }
|
66
|
+
end
|
67
|
+
```
|
68
|
+
|
69
|
+
## Usage
|
70
|
+
|
71
|
+
To actually use in your code, a simple sample is shown below:
|
72
|
+
|
73
|
+
```ruby
|
74
|
+
MultiSms.send(46, to: '+46730393200', from: '+14356778899', message: 'My SMS message')
|
75
|
+
```
|
76
|
+
|
77
|
+
|
78
|
+
## License
|
79
|
+
|
80
|
+
Copyright © 2012 Signl Apps Limited, http://www.signlapps.com
|
81
|
+
|
82
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
83
|
+
|
84
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
85
|
+
|
86
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
|
87
|
+
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Providers
|
2
|
+
|
3
|
+
class Clickatell < SmsProvider
|
4
|
+
|
5
|
+
API_VERSION = ""
|
6
|
+
BASE_DOMAIN = "api.clickatell.com"
|
7
|
+
|
8
|
+
def usable?
|
9
|
+
config.clickatell.apikey.present? and config.clickatell.username.present? and config.clickatell.password.present?
|
10
|
+
end
|
11
|
+
|
12
|
+
|
13
|
+
# Send SMS
|
14
|
+
# Required parameters
|
15
|
+
#
|
16
|
+
# * :from - Either the one of the allocated numbers or arbitrary alphanumeric string of at most 11 characters
|
17
|
+
# * :to - Any phone number capable of receiving SMS
|
18
|
+
# * :message - Any UTF-8 text Splitting and joining multi-part SMS messages are automatically handled by the API
|
19
|
+
def send(parameters)
|
20
|
+
base_url = "http://#{BASE_DOMAIN}"
|
21
|
+
path = "/http/sendmsg"
|
22
|
+
url = base_url + path
|
23
|
+
response = RestClient.post url, api_id: config.clickatell.apikey, user: config.clickatell.username, password: config.clickatell.password, to: parameters[:to], text: parameters[:message]
|
24
|
+
rescue RestClient::Unauthorized
|
25
|
+
raise AuthError, "Authentication failed"
|
26
|
+
rescue RestClient::InternalServerError
|
27
|
+
raise ServerError, "Server error"
|
28
|
+
rescue RestClient::Forbidden => e
|
29
|
+
raise BadRequest, e.http_body
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Providers
|
2
|
+
|
3
|
+
class Elk < SmsProvider
|
4
|
+
|
5
|
+
|
6
|
+
BASE_DOMAIN = 'api.46elks.com'
|
7
|
+
API_VERSION = 'a1'
|
8
|
+
|
9
|
+
def usable?
|
10
|
+
config.elk.username.present? and config.elk.password.present?
|
11
|
+
end
|
12
|
+
|
13
|
+
def send(parameters)
|
14
|
+
base_url = "https://#{config.elk.username}:#{config.elk.password}@#{BASE_DOMAIN}/#{API_VERSION}"
|
15
|
+
path = "/SMS"
|
16
|
+
{ message: [] }
|
17
|
+
response = MultiSms.post(base_url, path, parameters)
|
18
|
+
|
19
|
+
MultiSms.parse_json(response.body)
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module Providers
|
2
|
+
|
3
|
+
class Twilio < SmsProvider
|
4
|
+
|
5
|
+
API_VERSION = "2010-04-01"
|
6
|
+
BASE_DOMAIN = "api.twilio.com"
|
7
|
+
|
8
|
+
def usable?
|
9
|
+
config.twilio.account_sid.present? and config.twilio.auth_token.present?
|
10
|
+
end
|
11
|
+
|
12
|
+
|
13
|
+
# Send SMS
|
14
|
+
# Required parameters
|
15
|
+
#
|
16
|
+
# * :from - Either the one of the allocated numbers or arbitrary alphanumeric string of at most 11 characters
|
17
|
+
# * :to - Any phone number capable of receiving SMS
|
18
|
+
# * :message - Any UTF-8 text Splitting and joining multi-part SMS messages are automatically handled by the API
|
19
|
+
def send(parameters)
|
20
|
+
base_url = "https://#{config.twilio.account_sid}:#{config.twilio.auth_token}@#{BASE_DOMAIN}/#{API_VERSION}"
|
21
|
+
path = "/Accounts/#{config.twilio.account_sid}/SMS/Messages.json"
|
22
|
+
|
23
|
+
response = RestClient.post base_url + path, :To => parameters[:to], :Body => parameters[:message], :From => parameters[:from]
|
24
|
+
MultiSms.parse_json(response.body)
|
25
|
+
rescue RestClient::Unauthorized
|
26
|
+
raise AuthError, "Authentication failed"
|
27
|
+
rescue RestClient::InternalServerError
|
28
|
+
raise ServerError, "Server error"
|
29
|
+
rescue RestClient::Forbidden => e
|
30
|
+
raise BadRequest, e.http_body
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
module MultiSms
|
2
|
+
module Util
|
3
|
+
def verify_parameters(parameters, required_parameters)
|
4
|
+
missing_parameters = (required_parameters - parameters.keys)
|
5
|
+
unless missing_parameters.empty?
|
6
|
+
raise MultiSms::MissingParameter, "Requires #{missing_parameters.collect {|s| ":#{s}"}.join(', ')} parameters"
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
data/lib/multi_sms.rb
ADDED
@@ -0,0 +1,113 @@
|
|
1
|
+
require "multi_sms/version"
|
2
|
+
require 'configatron'
|
3
|
+
require 'rest-client'
|
4
|
+
require 'multi_json'
|
5
|
+
require 'json'
|
6
|
+
require "object"
|
7
|
+
require "multi_sms/util"
|
8
|
+
|
9
|
+
|
10
|
+
def gem_available?(gemname)
|
11
|
+
Gem::Specification.find_all_by_name(gemname).size > 0
|
12
|
+
end
|
13
|
+
|
14
|
+
module MultiSms
|
15
|
+
|
16
|
+
# When the authentication can't be done
|
17
|
+
class AuthError < RuntimeError; end
|
18
|
+
# Raised when the API server isn't working
|
19
|
+
class ServerError < RuntimeError; end
|
20
|
+
# Generic exception when API gives a response we can't parse
|
21
|
+
class BadResponse < RuntimeError; end
|
22
|
+
# Generic exception calling an API the wrong way
|
23
|
+
class BadRequest < RuntimeError; end
|
24
|
+
# Raised when required paremeters are omitted
|
25
|
+
class MissingParameter < RuntimeError; end
|
26
|
+
|
27
|
+
class << self
|
28
|
+
|
29
|
+
include MultiSms::Util
|
30
|
+
|
31
|
+
attr_accessor :config
|
32
|
+
|
33
|
+
# Yields up a configuration object when given a block.
|
34
|
+
# Without a block it just returns the configuration object.
|
35
|
+
# Uses Configatron under the covers.
|
36
|
+
#
|
37
|
+
# Example:
|
38
|
+
# MultiSms.config do |c|
|
39
|
+
# c.foo = :bar
|
40
|
+
# end
|
41
|
+
#
|
42
|
+
# MultiSms.config.foo # => :bar
|
43
|
+
def config(&block)
|
44
|
+
yield configatron.multi_sms if block_given?
|
45
|
+
configatron.multi_sms
|
46
|
+
end
|
47
|
+
|
48
|
+
def send(country_code, parameters)
|
49
|
+
provider = get_provider country_code
|
50
|
+
provider.send(parameters)
|
51
|
+
end
|
52
|
+
|
53
|
+
def logger
|
54
|
+
@logger ||= begin
|
55
|
+
log = Logger.new($stdout)
|
56
|
+
log.level = Logger::INFO
|
57
|
+
log
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def get_provider(country_code)
|
62
|
+
name = config.providers[country_code.to_s]
|
63
|
+
provider = "Providers::#{name}".split('::').inject(Object) {|o,c| o.const_get c}
|
64
|
+
provider.new
|
65
|
+
end
|
66
|
+
|
67
|
+
# Wrapper for MultiSms.execute(:get)
|
68
|
+
def get(base_url, path, parameters = {})
|
69
|
+
execute(base_url, :get, path, parameters)
|
70
|
+
end
|
71
|
+
|
72
|
+
# Wrapper for MultiSms::execute(:post)
|
73
|
+
def post(base_url, path, parameters = {})
|
74
|
+
execute(base_url, :post, path, parameters)
|
75
|
+
end
|
76
|
+
|
77
|
+
# Wrapper around RestClient::RestClient.execute
|
78
|
+
#
|
79
|
+
# * Sets accept header to json
|
80
|
+
# * Handles some exceptions
|
81
|
+
#
|
82
|
+
def execute(base_url, method, path, parameters, headers={ accept: :json}, &block)
|
83
|
+
verify_parameters(parameters, [:from, :message, :to])
|
84
|
+
|
85
|
+
# Warn if the from string will be capped by the sms gateway
|
86
|
+
if parameters[:from] && parameters[:from].match(/^(\w{11,})$/)
|
87
|
+
warn "SMS 'from' value #{parameters[:from]} will be capped at 11 chars"
|
88
|
+
end
|
89
|
+
payload = {}.merge(parameters)
|
90
|
+
url = base_url + path
|
91
|
+
RestClient::Request.execute(:method => method, :url => url, :payload => payload, :headers => headers, &block)
|
92
|
+
rescue RestClient::Unauthorized
|
93
|
+
raise AuthError, "Authentication failed"
|
94
|
+
rescue RestClient::InternalServerError
|
95
|
+
raise ServerError, "Server error"
|
96
|
+
rescue RestClient::Forbidden => e
|
97
|
+
raise BadRequest, e.http_body
|
98
|
+
end
|
99
|
+
|
100
|
+
# Wrapper around MultiJson.load, symbolize names
|
101
|
+
def parse_json(body)
|
102
|
+
MultiJson.load(body, :symbolize_keys => true)
|
103
|
+
rescue MultiJson::DecodeError
|
104
|
+
raise BadResponse, "Can't parse JSON"
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
end
|
109
|
+
|
110
|
+
require "multi_sms/providers/sms_provider"
|
111
|
+
require "multi_sms/providers/elk"
|
112
|
+
require "multi_sms/providers/clickatell"
|
113
|
+
require "multi_sms/providers/twilio"
|
data/lib/object.rb
ADDED
data/multi_sms.gemspec
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/multi_sms/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Mikael Henriksson"]
|
6
|
+
gem.email = ["mikael@zoolutions.se"]
|
7
|
+
gem.description = %q{Gem for handling multiple SMS API's}
|
8
|
+
gem.summary = %q{Gem for handling multiple SMS API's}
|
9
|
+
|
10
|
+
gem.homepage = "http://github.com/signlapps/multi_sms"
|
11
|
+
gem.license = "MIT"
|
12
|
+
gem.rubyforge_project = "multi_sms"
|
13
|
+
# gem.executables = ['']
|
14
|
+
gem.files = `git ls-files`.split("\n")
|
15
|
+
gem.test_files = `git ls-files -- test/*`.split("\n")
|
16
|
+
gem.name = "multi_sms"
|
17
|
+
gem.require_paths = ["lib"]
|
18
|
+
gem.version = MultiSms::VERSION
|
19
|
+
|
20
|
+
gem.add_runtime_dependency 'configatron'
|
21
|
+
gem.add_runtime_dependency 'rest-client'
|
22
|
+
gem.add_runtime_dependency 'multi_json'
|
23
|
+
|
24
|
+
gem.add_development_dependency 'ruby_gntp'
|
25
|
+
gem.add_development_dependency 'guard'
|
26
|
+
gem.add_development_dependency 'guard-bundler'
|
27
|
+
gem.add_development_dependency 'guard-rspec'
|
28
|
+
gem.add_development_dependency 'guard-spork'
|
29
|
+
gem.add_development_dependency 'spork', '> 0.9.0.rc'
|
30
|
+
gem.add_development_dependency 'rspec'
|
31
|
+
gem.add_development_dependency 'rake'
|
32
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
describe MultiSms do
|
3
|
+
|
4
|
+
before do
|
5
|
+
MultiSms.config do |config|
|
6
|
+
config.providers = {"46" => "Elk", "47" => "Twilio"}
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should get provider based on swedish country code" do
|
11
|
+
provider = MultiSms.get_provider 46
|
12
|
+
provider.should be_an_instance_of Providers::Elk
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should get provider based on norweigan country code" do
|
16
|
+
provider = MultiSms.get_provider 47
|
17
|
+
provider.should be_an_instance_of Providers::Twilio
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Providers::Clickatell do
|
4
|
+
|
5
|
+
let(:provider) { Providers::Clickatell.new }
|
6
|
+
|
7
|
+
it "should not be usable unless configuration is complete" do
|
8
|
+
expect(provider.usable?).to be_false
|
9
|
+
end
|
10
|
+
|
11
|
+
|
12
|
+
context "with authentication provided" do
|
13
|
+
before do
|
14
|
+
MultiSms.config do |config|
|
15
|
+
config.clickatell.username = ENV['CLICKATELL_USERNAME'] ||= "username"
|
16
|
+
config.clickatell.password = ENV['CLICKATELL_PASSWORD'] ||= "password"
|
17
|
+
config.clickatell.apikey = ENV['CLICKATELL_APIKEY'] ||= "apikey"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should be usable when configured" do
|
22
|
+
provider.usable?.should be_true
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should send sms as requested" do
|
26
|
+
# MultiSms.logger.info provider.send(to: '+46730393200', message: 'testmessage', from: "signlapps")
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Providers::Elk do
|
4
|
+
let(:provider) { Providers::Elk.new }
|
5
|
+
context "without authentication details" do
|
6
|
+
it "should not be usable?" do
|
7
|
+
provider.usable?.should be_false
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
context "with authentication provided" do
|
12
|
+
before do
|
13
|
+
MultiSms.config do |config|
|
14
|
+
config.elk.username = ENV['ELK_USERNAME'] ||= "username"
|
15
|
+
config.elk.password = ENV['ELK_PASSWORD'] ||= "password"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should be usable when configured" do
|
20
|
+
provider.usable?.should be_true
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should send sms as requested" do
|
24
|
+
# MultiSms.logger.info provider.send(to: '+46730393200', message: 'testmessage', from: "signlapps")
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Providers::Twilio do
|
4
|
+
|
5
|
+
let(:provider) { Providers::Twilio.new }
|
6
|
+
|
7
|
+
context "without authentication details" do
|
8
|
+
it "should not be usable?" do
|
9
|
+
provider.usable?.should be_false
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
context "with authentication provided" do
|
14
|
+
before do
|
15
|
+
MultiSms.config do |config|
|
16
|
+
config.twilio.account_sid = ENV['TWILIO_ACCOUNT_SID'] ||= "username"
|
17
|
+
config.twilio.auth_token = ENV['TWILIO_AUTH_TOKEN'] ||= "username"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
it "should be usable when configured" do
|
21
|
+
provider.usable?.should be_true
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should send sms as requested" do
|
25
|
+
# MultiSms.logger.info provider.send(to: '+46730393200', message: 'testmessage', from: "+14155992671")
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'spork'
|
3
|
+
|
4
|
+
Spork.prefork do
|
5
|
+
require 'rspec/autorun'
|
6
|
+
RSpec.configure do |config|
|
7
|
+
config.mock_with :rspec
|
8
|
+
|
9
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
10
|
+
config.filter_run :focus => true
|
11
|
+
config.run_all_when_everything_filtered = true
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
Spork.each_run do
|
17
|
+
RSpec.configure do |config|
|
18
|
+
require 'multi_sms'
|
19
|
+
end
|
20
|
+
end
|
metadata
ADDED
@@ -0,0 +1,250 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: multi_sms
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Mikael Henriksson
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-08-28 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: configatron
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rest-client
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: multi_json
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: ruby_gntp
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: guard
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: guard-bundler
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ! '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
- !ruby/object:Gem::Dependency
|
111
|
+
name: guard-rspec
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
113
|
+
none: false
|
114
|
+
requirements:
|
115
|
+
- - ! '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ! '>='
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
126
|
+
- !ruby/object:Gem::Dependency
|
127
|
+
name: guard-spork
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
129
|
+
none: false
|
130
|
+
requirements:
|
131
|
+
- - ! '>='
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0'
|
134
|
+
type: :development
|
135
|
+
prerelease: false
|
136
|
+
version_requirements: !ruby/object:Gem::Requirement
|
137
|
+
none: false
|
138
|
+
requirements:
|
139
|
+
- - ! '>='
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '0'
|
142
|
+
- !ruby/object:Gem::Dependency
|
143
|
+
name: spork
|
144
|
+
requirement: !ruby/object:Gem::Requirement
|
145
|
+
none: false
|
146
|
+
requirements:
|
147
|
+
- - ! '>'
|
148
|
+
- !ruby/object:Gem::Version
|
149
|
+
version: 0.9.0.rc
|
150
|
+
type: :development
|
151
|
+
prerelease: false
|
152
|
+
version_requirements: !ruby/object:Gem::Requirement
|
153
|
+
none: false
|
154
|
+
requirements:
|
155
|
+
- - ! '>'
|
156
|
+
- !ruby/object:Gem::Version
|
157
|
+
version: 0.9.0.rc
|
158
|
+
- !ruby/object:Gem::Dependency
|
159
|
+
name: rspec
|
160
|
+
requirement: !ruby/object:Gem::Requirement
|
161
|
+
none: false
|
162
|
+
requirements:
|
163
|
+
- - ! '>='
|
164
|
+
- !ruby/object:Gem::Version
|
165
|
+
version: '0'
|
166
|
+
type: :development
|
167
|
+
prerelease: false
|
168
|
+
version_requirements: !ruby/object:Gem::Requirement
|
169
|
+
none: false
|
170
|
+
requirements:
|
171
|
+
- - ! '>='
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0'
|
174
|
+
- !ruby/object:Gem::Dependency
|
175
|
+
name: rake
|
176
|
+
requirement: !ruby/object:Gem::Requirement
|
177
|
+
none: false
|
178
|
+
requirements:
|
179
|
+
- - ! '>='
|
180
|
+
- !ruby/object:Gem::Version
|
181
|
+
version: '0'
|
182
|
+
type: :development
|
183
|
+
prerelease: false
|
184
|
+
version_requirements: !ruby/object:Gem::Requirement
|
185
|
+
none: false
|
186
|
+
requirements:
|
187
|
+
- - ! '>='
|
188
|
+
- !ruby/object:Gem::Version
|
189
|
+
version: '0'
|
190
|
+
description: Gem for handling multiple SMS API's
|
191
|
+
email:
|
192
|
+
- mikael@zoolutions.se
|
193
|
+
executables: []
|
194
|
+
extensions: []
|
195
|
+
extra_rdoc_files: []
|
196
|
+
files:
|
197
|
+
- .gitignore
|
198
|
+
- .rvmrc
|
199
|
+
- Gemfile
|
200
|
+
- Guardfile
|
201
|
+
- License
|
202
|
+
- Rakefile
|
203
|
+
- Readme.md
|
204
|
+
- lib/multi_sms.rb
|
205
|
+
- lib/multi_sms/providers/clickatell.rb
|
206
|
+
- lib/multi_sms/providers/elk.rb
|
207
|
+
- lib/multi_sms/providers/sms_provider.rb
|
208
|
+
- lib/multi_sms/providers/twilio.rb
|
209
|
+
- lib/multi_sms/util.rb
|
210
|
+
- lib/multi_sms/version.rb
|
211
|
+
- lib/object.rb
|
212
|
+
- multi_sms.gemspec
|
213
|
+
- spec/multi_sms_spec.rb
|
214
|
+
- spec/providers/clickatell_spec.rb
|
215
|
+
- spec/providers/elk_spec.rb
|
216
|
+
- spec/providers/twilio_spec.rb
|
217
|
+
- spec/spec_helper.rb
|
218
|
+
homepage: http://github.com/signlapps/multi_sms
|
219
|
+
licenses:
|
220
|
+
- MIT
|
221
|
+
post_install_message:
|
222
|
+
rdoc_options: []
|
223
|
+
require_paths:
|
224
|
+
- lib
|
225
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
226
|
+
none: false
|
227
|
+
requirements:
|
228
|
+
- - ! '>='
|
229
|
+
- !ruby/object:Gem::Version
|
230
|
+
version: '0'
|
231
|
+
segments:
|
232
|
+
- 0
|
233
|
+
hash: 3870457680915898508
|
234
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
235
|
+
none: false
|
236
|
+
requirements:
|
237
|
+
- - ! '>='
|
238
|
+
- !ruby/object:Gem::Version
|
239
|
+
version: '0'
|
240
|
+
segments:
|
241
|
+
- 0
|
242
|
+
hash: 3870457680915898508
|
243
|
+
requirements: []
|
244
|
+
rubyforge_project: multi_sms
|
245
|
+
rubygems_version: 1.8.24
|
246
|
+
signing_key:
|
247
|
+
specification_version: 3
|
248
|
+
summary: Gem for handling multiple SMS API's
|
249
|
+
test_files: []
|
250
|
+
has_rdoc:
|