outbox-msg91 0.1.4
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 +7 -0
- data/.gitignore +14 -0
- data/.rspec +2 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +55 -0
- data/Rakefile +6 -0
- data/lib/outbox-msg91.rb +1 -0
- data/lib/outbox/msg91.rb +10 -0
- data/lib/outbox/msg91/client.rb +45 -0
- data/lib/outbox/msg91/version.rb +5 -0
- data/outbox-msg91.gemspec +25 -0
- data/spec/outbox/msg91/client_spec.rb +37 -0
- data/spec/outbox/msg91_spec.rb +7 -0
- data/spec/spec_helper.rb +2 -0
- metadata +117 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a44d8f0ba4080c64b8da9786b2c859415f9ced2e
|
4
|
+
data.tar.gz: ac0ae817515efe5932225cad064c4848f5216493
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6f9f087ae6a69f593d562501277d8b0757bf09424d13025e5ef63aef011ae27c4f54826e443f397b6a46505986549347dbc7e0693d2217df7abd6647d89bb015
|
7
|
+
data.tar.gz: 10aeb69732b951e1e6a95673eeb8ba4334ebb5f4eacce5e78513eb3fc3cd002cf9b08c3fe3b73307d27ca847a1f5ae69d2f2834691482b4100f6dfe4b2d22f06
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2016 NSOX Tech
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
Outbox::Msg91
|
2
|
+
==============
|
3
|
+
|
4
|
+
[](http://badge.fury.io/rb/outbox-msg91)
|
5
|
+
|
6
|
+
MSG91 SMS API wrapper for [Outbox](https://github.com/localmed/outbox).
|
7
|
+
|
8
|
+
## Installation
|
9
|
+
|
10
|
+
Add this line to your application's Gemfile:
|
11
|
+
|
12
|
+
``` ruby
|
13
|
+
gem 'outbox-msg91'
|
14
|
+
```
|
15
|
+
|
16
|
+
And then execute:
|
17
|
+
|
18
|
+
``` bash
|
19
|
+
$ bundle
|
20
|
+
```
|
21
|
+
|
22
|
+
Or install it yourself as:
|
23
|
+
|
24
|
+
``` bash
|
25
|
+
$ gem install outbox-msg91
|
26
|
+
```
|
27
|
+
|
28
|
+
## Usage
|
29
|
+
|
30
|
+
Configure Outbox to use Outbox::Msg91 as the default SMS client:
|
31
|
+
|
32
|
+
``` ruby
|
33
|
+
Outbox::Messages::SMS.default_client(
|
34
|
+
:msg91,
|
35
|
+
authkey = "xxxxxxxxxxxxxxxxxxx"
|
36
|
+
)
|
37
|
+
```
|
38
|
+
|
39
|
+
SMS messages will now use the Msg91 Ap for devlivery:
|
40
|
+
|
41
|
+
``` ruby
|
42
|
+
sms = Outbox::Messages::SMS.new(
|
43
|
+
from: "ABCDEFG", <6 digit sender id>
|
44
|
+
body: 'Hello World',
|
45
|
+
)
|
46
|
+
sms.deliver('+15552224444')
|
47
|
+
```
|
48
|
+
|
49
|
+
## Contributing
|
50
|
+
|
51
|
+
1. Fork it ( https://github.com/nsox/outbox-msg1/fork )
|
52
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
53
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
54
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
55
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/lib/outbox-msg91.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'outbox/msg91'
|
data/lib/outbox/msg91.rb
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
module Outbox
|
2
|
+
module Msg91
|
3
|
+
# Uses MSG91s php API client to deliver SMS messages.
|
4
|
+
#
|
5
|
+
# Outbox::Messages::SMS.default_client(
|
6
|
+
# :msg91,
|
7
|
+
# authkey = "xxxxxxxxxxxxxxxxxxx")
|
8
|
+
# sms = Outbox::Messages::SMS.new(
|
9
|
+
# from: = "ABCDEFG" <6 digit code>
|
10
|
+
# body: 'Hello World'
|
11
|
+
# )
|
12
|
+
# sms.deliver('+15552224444')
|
13
|
+
class Client < Outbox::Clients::Base
|
14
|
+
attr_reader :auth_key, :senderid
|
15
|
+
|
16
|
+
def initialize(settings = nil)
|
17
|
+
super
|
18
|
+
|
19
|
+
options = @settings.dup
|
20
|
+
p @options
|
21
|
+
|
22
|
+
# 4 indicates transactional sms
|
23
|
+
@route_code = 4
|
24
|
+
@authkey = options[:authkey]
|
25
|
+
end
|
26
|
+
|
27
|
+
|
28
|
+
def full_path(url, path, params)
|
29
|
+
encoded_params = URI.encode_www_form(params)
|
30
|
+
params_string = [path, encoded_params].join("?")
|
31
|
+
URI.parse(url + params_string)
|
32
|
+
end
|
33
|
+
|
34
|
+
#MSG91 API Documented at https://api.msg91.com/apidoc/textsms/send-sms.php
|
35
|
+
def deliver(sms)
|
36
|
+
params = {:authkey => @authkey, :mobiles => sms.to, :message => sms.body , :sender => sms.from ,:route => @route_code, :response => "json"}
|
37
|
+
url = "http://api.msg91.com"
|
38
|
+
uri = full_path(url, '/api/sendhttp.php', params)
|
39
|
+
#p uri
|
40
|
+
response = Net::HTTP.get(uri)
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'outbox/msg91/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'outbox-msg91'
|
8
|
+
spec.version = Outbox::Msg91::VERSION
|
9
|
+
spec.authors = ['Rabi Cherian']
|
10
|
+
spec.email = ['rabi@nsox.tech']
|
11
|
+
spec.summary = %q{Outbox SMS client for MSG91.}
|
12
|
+
spec.description = %q{MSG91 API wrapper for Outbox, a generic interface for sending sms notificatons.}
|
13
|
+
spec.homepage = 'https://github.com/nsox/outbox-msg91'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ['lib']
|
20
|
+
|
21
|
+
spec.add_runtime_dependency 'outbox', '~> 0.2'
|
22
|
+
spec.add_development_dependency 'bundler', '~> 1.6'
|
23
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
24
|
+
spec.add_development_dependency 'rspec'
|
25
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Outbox::Msg91::Client do
|
4
|
+
describe '.new' do
|
5
|
+
it 'expects configuration fot the Msg91 API' do
|
6
|
+
# client = Outbox::Msg91::Client(
|
7
|
+
# :authkey "ABCDEFG"
|
8
|
+
# )
|
9
|
+
client = Outbox::Messages::SMS.default_client(
|
10
|
+
:msg91,
|
11
|
+
authkey: "ABCDEFG"
|
12
|
+
)
|
13
|
+
expect(client.authkey).not_to be_empty
|
14
|
+
end
|
15
|
+
end
|
16
|
+
describe '#deliver' do
|
17
|
+
before do
|
18
|
+
# @client = Outbox::Msg91::Client(
|
19
|
+
# :authkey "ABCDEFG"
|
20
|
+
# )
|
21
|
+
@client = Outbox::Messages::SMS.default_client(
|
22
|
+
:msg91,
|
23
|
+
authkey: "ABCDEFG"
|
24
|
+
)
|
25
|
+
@sms = Outbox::Messages::SMS.new do
|
26
|
+
to '+919876543210'
|
27
|
+
from 'SENDER'
|
28
|
+
body 'Hello world.'
|
29
|
+
end
|
30
|
+
end
|
31
|
+
it 'delivers the SMS' do
|
32
|
+
response = @client.deliver(@sms)
|
33
|
+
parsed_body = JSON.parse(response.body)
|
34
|
+
expect(parsed_body).not_to be_empty
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,117 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: outbox-msg91
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.4
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Rabi Cherian
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-09-22 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: outbox
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.2'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.2'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.6'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.6'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: MSG91 API wrapper for Outbox, a generic interface for sending sms notificatons.
|
70
|
+
email:
|
71
|
+
- rabi@nsox.tech
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- ".rspec"
|
78
|
+
- Gemfile
|
79
|
+
- LICENSE.txt
|
80
|
+
- README.md
|
81
|
+
- Rakefile
|
82
|
+
- lib/outbox-msg91.rb
|
83
|
+
- lib/outbox/msg91.rb
|
84
|
+
- lib/outbox/msg91/client.rb
|
85
|
+
- lib/outbox/msg91/version.rb
|
86
|
+
- outbox-msg91.gemspec
|
87
|
+
- spec/outbox/msg91/client_spec.rb
|
88
|
+
- spec/outbox/msg91_spec.rb
|
89
|
+
- spec/spec_helper.rb
|
90
|
+
homepage: https://github.com/nsox/outbox-msg91
|
91
|
+
licenses:
|
92
|
+
- MIT
|
93
|
+
metadata: {}
|
94
|
+
post_install_message:
|
95
|
+
rdoc_options: []
|
96
|
+
require_paths:
|
97
|
+
- lib
|
98
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
104
|
+
requirements:
|
105
|
+
- - ">="
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
version: '0'
|
108
|
+
requirements: []
|
109
|
+
rubyforge_project:
|
110
|
+
rubygems_version: 2.2.2
|
111
|
+
signing_key:
|
112
|
+
specification_version: 4
|
113
|
+
summary: Outbox SMS client for MSG91.
|
114
|
+
test_files:
|
115
|
+
- spec/outbox/msg91/client_spec.rb
|
116
|
+
- spec/outbox/msg91_spec.rb
|
117
|
+
- spec/spec_helper.rb
|