globelabs_sms_rails 0.0.4 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.env.sample +4 -0
- data/.gitignore +5 -2
- data/.rspec +3 -0
- data/.travis.yml +21 -0
- data/Gemfile +10 -3
- data/Gemfile.lock +175 -0
- data/LICENSE.txt +1 -1
- data/README.md +26 -8
- data/Rakefile +2 -3
- data/globelabs_sms_rails.gemspec +22 -8
- data/lib/generators/globelabs_sms_rails/install_generator.rb +15 -13
- data/lib/generators/globelabs_sms_rails/templates/globelabs_sms_rails_initializer.rb +6 -0
- data/lib/globelabs_sms_rails.rb +13 -55
- data/lib/globelabs_sms_rails/client.rb +55 -0
- data/lib/globelabs_sms_rails/configuration.rb +33 -0
- data/lib/globelabs_sms_rails/errors/configuration.rb +9 -0
- data/lib/globelabs_sms_rails/version.rb +1 -1
- metadata +64 -14
- data/lib/generators/templates/globelabs_sms_rails_initializer.rb +0 -7
- data/lib/globelabs_sms_rails/http_provider.rb +0 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 67b8a9e61563d098e47e5c5f57c49b9c9d50406aba6b7d91a9d750934b5b5350
|
4
|
+
data.tar.gz: f5b148ca59cc5600c194c0f046928a42183b8e10ea5d3a01706fd407dbad2250
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 20118b5fc24632d5093a73886977fe846eba113c64dfc083f01a899082c56293ec91d3bcc179001cc033c4b90e51acbfa7e0185c1021355b63fbd4840625f7be
|
7
|
+
data.tar.gz: e451f1f243e72f62a43f432057da3c0da872c5810a4c877e35a640d232733ce3d8f14f7553bfae017e53b092c93541897b3c42a392a9e6f25f316d3fbfba8fd1
|
data/.env.sample
ADDED
data/.gitignore
CHANGED
data/.rspec
ADDED
data/.travis.yml
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
sudo: false
|
2
|
+
language: ruby
|
3
|
+
rvm:
|
4
|
+
- 2.4.1
|
5
|
+
before_install: gem install bundler -v 1.16.1
|
6
|
+
notifications: false
|
7
|
+
|
8
|
+
env:
|
9
|
+
global:
|
10
|
+
- CC_TEST_REPORTER_ID=a1f2f3946fc17154df096b39e0d2b0c255e767d33e4fc27d3ccb43b9002e1a5d
|
11
|
+
|
12
|
+
before_script:
|
13
|
+
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
|
14
|
+
- chmod +x ./cc-test-reporter
|
15
|
+
- ./cc-test-reporter before-build
|
16
|
+
|
17
|
+
scripts:
|
18
|
+
- bundle exec rspec spec
|
19
|
+
|
20
|
+
after_script:
|
21
|
+
- ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
|
data/Gemfile
CHANGED
@@ -1,5 +1,12 @@
|
|
1
|
-
source
|
1
|
+
source "https://rubygems.org"
|
2
2
|
|
3
|
-
|
3
|
+
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
|
4
|
+
|
5
|
+
# Specify your gem's dependencies in globe_labs_sms.gemspec
|
4
6
|
gemspec
|
5
|
-
|
7
|
+
|
8
|
+
group :test do
|
9
|
+
gem 'generator_spec'
|
10
|
+
gem 'simplecov'
|
11
|
+
gem 'simplecov-console'
|
12
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,175 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
globelabs_sms_rails (0.1.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
actioncable (5.2.0)
|
10
|
+
actionpack (= 5.2.0)
|
11
|
+
nio4r (~> 2.0)
|
12
|
+
websocket-driver (>= 0.6.1)
|
13
|
+
actionmailer (5.2.0)
|
14
|
+
actionpack (= 5.2.0)
|
15
|
+
actionview (= 5.2.0)
|
16
|
+
activejob (= 5.2.0)
|
17
|
+
mail (~> 2.5, >= 2.5.4)
|
18
|
+
rails-dom-testing (~> 2.0)
|
19
|
+
actionpack (5.2.0)
|
20
|
+
actionview (= 5.2.0)
|
21
|
+
activesupport (= 5.2.0)
|
22
|
+
rack (~> 2.0)
|
23
|
+
rack-test (>= 0.6.3)
|
24
|
+
rails-dom-testing (~> 2.0)
|
25
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
26
|
+
actionview (5.2.0)
|
27
|
+
activesupport (= 5.2.0)
|
28
|
+
builder (~> 3.1)
|
29
|
+
erubi (~> 1.4)
|
30
|
+
rails-dom-testing (~> 2.0)
|
31
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.3)
|
32
|
+
activejob (5.2.0)
|
33
|
+
activesupport (= 5.2.0)
|
34
|
+
globalid (>= 0.3.6)
|
35
|
+
activemodel (5.2.0)
|
36
|
+
activesupport (= 5.2.0)
|
37
|
+
activerecord (5.2.0)
|
38
|
+
activemodel (= 5.2.0)
|
39
|
+
activesupport (= 5.2.0)
|
40
|
+
arel (>= 9.0)
|
41
|
+
activestorage (5.2.0)
|
42
|
+
actionpack (= 5.2.0)
|
43
|
+
activerecord (= 5.2.0)
|
44
|
+
marcel (~> 0.3.1)
|
45
|
+
activesupport (5.2.0)
|
46
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
47
|
+
i18n (>= 0.7, < 2)
|
48
|
+
minitest (~> 5.1)
|
49
|
+
tzinfo (~> 1.1)
|
50
|
+
addressable (2.5.2)
|
51
|
+
public_suffix (>= 2.0.2, < 4.0)
|
52
|
+
ansi (1.5.0)
|
53
|
+
arel (9.0.0)
|
54
|
+
builder (3.2.3)
|
55
|
+
concurrent-ruby (1.0.5)
|
56
|
+
crack (0.4.3)
|
57
|
+
safe_yaml (~> 1.0.0)
|
58
|
+
crass (1.0.4)
|
59
|
+
diff-lcs (1.3)
|
60
|
+
docile (1.3.1)
|
61
|
+
dotenv (2.5.0)
|
62
|
+
erubi (1.7.1)
|
63
|
+
generator_spec (0.9.4)
|
64
|
+
activesupport (>= 3.0.0)
|
65
|
+
railties (>= 3.0.0)
|
66
|
+
globalid (0.4.1)
|
67
|
+
activesupport (>= 4.2.0)
|
68
|
+
hashdiff (0.3.7)
|
69
|
+
hirb (0.7.3)
|
70
|
+
i18n (1.0.1)
|
71
|
+
concurrent-ruby (~> 1.0)
|
72
|
+
json (2.1.0)
|
73
|
+
loofah (2.2.2)
|
74
|
+
crass (~> 1.0.2)
|
75
|
+
nokogiri (>= 1.5.9)
|
76
|
+
mail (2.7.0)
|
77
|
+
mini_mime (>= 0.1.1)
|
78
|
+
marcel (0.3.2)
|
79
|
+
mimemagic (~> 0.3.2)
|
80
|
+
method_source (0.9.0)
|
81
|
+
mimemagic (0.3.2)
|
82
|
+
mini_mime (1.0.0)
|
83
|
+
mini_portile2 (2.3.0)
|
84
|
+
minitest (5.11.3)
|
85
|
+
nio4r (2.3.1)
|
86
|
+
nokogiri (1.8.4)
|
87
|
+
mini_portile2 (~> 2.3.0)
|
88
|
+
public_suffix (3.0.2)
|
89
|
+
rack (2.0.5)
|
90
|
+
rack-test (1.0.0)
|
91
|
+
rack (>= 1.0, < 3)
|
92
|
+
rails (5.2.0)
|
93
|
+
actioncable (= 5.2.0)
|
94
|
+
actionmailer (= 5.2.0)
|
95
|
+
actionpack (= 5.2.0)
|
96
|
+
actionview (= 5.2.0)
|
97
|
+
activejob (= 5.2.0)
|
98
|
+
activemodel (= 5.2.0)
|
99
|
+
activerecord (= 5.2.0)
|
100
|
+
activestorage (= 5.2.0)
|
101
|
+
activesupport (= 5.2.0)
|
102
|
+
bundler (>= 1.3.0)
|
103
|
+
railties (= 5.2.0)
|
104
|
+
sprockets-rails (>= 2.0.0)
|
105
|
+
rails-dom-testing (2.0.3)
|
106
|
+
activesupport (>= 4.2.0)
|
107
|
+
nokogiri (>= 1.6)
|
108
|
+
rails-html-sanitizer (1.0.4)
|
109
|
+
loofah (~> 2.2, >= 2.2.2)
|
110
|
+
railties (5.2.0)
|
111
|
+
actionpack (= 5.2.0)
|
112
|
+
activesupport (= 5.2.0)
|
113
|
+
method_source
|
114
|
+
rake (>= 0.8.7)
|
115
|
+
thor (>= 0.18.1, < 2.0)
|
116
|
+
rake (10.5.0)
|
117
|
+
rspec (3.7.0)
|
118
|
+
rspec-core (~> 3.7.0)
|
119
|
+
rspec-expectations (~> 3.7.0)
|
120
|
+
rspec-mocks (~> 3.7.0)
|
121
|
+
rspec-core (3.7.1)
|
122
|
+
rspec-support (~> 3.7.0)
|
123
|
+
rspec-expectations (3.7.0)
|
124
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
125
|
+
rspec-support (~> 3.7.0)
|
126
|
+
rspec-mocks (3.7.0)
|
127
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
128
|
+
rspec-support (~> 3.7.0)
|
129
|
+
rspec-support (3.7.1)
|
130
|
+
safe_yaml (1.0.4)
|
131
|
+
simplecov (0.16.1)
|
132
|
+
docile (~> 1.1)
|
133
|
+
json (>= 1.8, < 3)
|
134
|
+
simplecov-html (~> 0.10.0)
|
135
|
+
simplecov-console (0.4.2)
|
136
|
+
ansi
|
137
|
+
hirb
|
138
|
+
simplecov
|
139
|
+
simplecov-html (0.10.2)
|
140
|
+
sprockets (3.7.2)
|
141
|
+
concurrent-ruby (~> 1.0)
|
142
|
+
rack (> 1, < 3)
|
143
|
+
sprockets-rails (3.2.1)
|
144
|
+
actionpack (>= 4.0)
|
145
|
+
activesupport (>= 4.0)
|
146
|
+
sprockets (>= 3.0.0)
|
147
|
+
thor (0.20.0)
|
148
|
+
thread_safe (0.3.6)
|
149
|
+
tzinfo (1.2.5)
|
150
|
+
thread_safe (~> 0.1)
|
151
|
+
webmock (3.4.2)
|
152
|
+
addressable (>= 2.3.6)
|
153
|
+
crack (>= 0.3.2)
|
154
|
+
hashdiff
|
155
|
+
websocket-driver (0.7.0)
|
156
|
+
websocket-extensions (>= 0.1.0)
|
157
|
+
websocket-extensions (0.1.3)
|
158
|
+
|
159
|
+
PLATFORMS
|
160
|
+
ruby
|
161
|
+
|
162
|
+
DEPENDENCIES
|
163
|
+
bundler (~> 1.16)
|
164
|
+
dotenv (~> 2.5.0)
|
165
|
+
generator_spec
|
166
|
+
globelabs_sms_rails!
|
167
|
+
rails
|
168
|
+
rake (~> 10.0)
|
169
|
+
rspec (~> 3.0)
|
170
|
+
simplecov
|
171
|
+
simplecov-console
|
172
|
+
webmock (~> 3.4.2)
|
173
|
+
|
174
|
+
BUNDLED WITH
|
175
|
+
1.16.1
|
data/LICENSE.txt
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
The MIT License (MIT)
|
2
2
|
|
3
|
-
Copyright (c) 2017 Den Mark Meralpis
|
3
|
+
Copyright (c) 2017 Nujian Den Mark Meralpis
|
4
4
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
data/README.md
CHANGED
@@ -1,9 +1,15 @@
|
|
1
|
+
[![Build Status](https://travis-ci.org/denmarkmeralpis/globelabs_sms_rails.svg?branch=master)](https://travis-ci.org/denmarkmeralpis/globelabs_sms_rails) [![Test Coverage](https://api.codeclimate.com/v1/badges/8f4e8e1c883e6865d2ed/test_coverage)](https://codeclimate.com/github/denmarkmeralpis/globelabs_sms_rails/test_coverage) [![Maintainability](https://api.codeclimate.com/v1/badges/8f4e8e1c883e6865d2ed/maintainability)](https://codeclimate.com/github/denmarkmeralpis/globelabs_sms_rails/maintainability)
|
2
|
+
|
3
|
+
# Globe Labs SMS on Rails
|
4
|
+
|
5
|
+
This gem will help you send SMS using Globe Labs API. Please take note that this gem will work if the subscriber consent workflow is disabled. You can apply the process by asking Globe
|
6
|
+
|
1
7
|
## Installation
|
2
8
|
|
3
9
|
Add this line to your application's Gemfile:
|
4
10
|
|
5
11
|
```ruby
|
6
|
-
gem 'globelabs_sms_rails'
|
12
|
+
gem 'globelabs_sms_rails'
|
7
13
|
```
|
8
14
|
|
9
15
|
And then execute:
|
@@ -13,17 +19,29 @@ And then execute:
|
|
13
19
|
Or install it yourself as:
|
14
20
|
|
15
21
|
$ gem install globelabs_sms_rails
|
22
|
+
|
23
|
+
Generate initializer to config/initializer via:
|
16
24
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
25
|
+
$ rails g globelabs_sms_rails:install
|
26
|
+
|
27
|
+
then edit the file in `config/initializer/globelabs_sms_rails.rb` and supply the necessary details.
|
21
28
|
|
22
29
|
## Usage
|
30
|
+
|
31
|
+
Two way of sending SMS:
|
23
32
|
```ruby
|
24
|
-
|
33
|
+
# Direct sending through class method `#send`
|
34
|
+
GlobelabsSmsRails.send(address: '0917XXXXXXX', message: 'Your message here!')
|
35
|
+
|
36
|
+
# Initialize and send
|
37
|
+
client = GlobelabsSmsRails.new(address: '0917XXXXXXX', message: 'Your message here!)
|
38
|
+
ciient.send
|
25
39
|
```
|
26
40
|
|
27
|
-
##
|
41
|
+
## Contributing
|
42
|
+
|
43
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/denmarkmeralpis/globelabs_sms_rails. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
44
|
+
|
45
|
+
## Code of Conduct
|
28
46
|
|
29
|
-
|
47
|
+
Everyone interacting in the GlobelabsSmsRails project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/denmarkmeralpis/globelabs_sms_rails/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
CHANGED
data/globelabs_sms_rails.gemspec
CHANGED
@@ -8,18 +8,32 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.version = GlobelabsSmsRails::VERSION
|
9
9
|
spec.authors = ["Nujian Den Mark Meralpis"]
|
10
10
|
spec.email = ["meralpisdenmark@gmail.com"]
|
11
|
-
|
12
|
-
spec.
|
13
|
-
spec.homepage = "https://github.com/denmarkmeralpis"
|
11
|
+
|
12
|
+
spec.summary = "A simple gem for sending SMS through Globe Labs API."
|
13
|
+
spec.homepage = "https://github.com/denmarkmeralpis/globelabs_sms_rails"
|
14
|
+
spec.description = "This gem will help you send SMS using Globe Labs API. Please take note that this gem will work if the subscriber consent workflow is disabled. You can apply the process by asking Globe"
|
14
15
|
spec.license = "MIT"
|
16
|
+
|
17
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
18
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
19
|
+
# if spec.respond_to?(:metadata)
|
20
|
+
# spec.metadata["allowed_push_host"] = "https://github.com/denmarkmeralpis/globelabs_sms_rails"
|
21
|
+
# else
|
22
|
+
# raise "RubyGems 2.0 or newer is required to protect against " \
|
23
|
+
# "public gem pushes."
|
24
|
+
# end
|
25
|
+
|
26
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
27
|
+
f.match(%r{^(test|spec|features)/})
|
28
|
+
end
|
15
29
|
spec.bindir = "exe"
|
16
30
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
17
31
|
spec.require_paths = ["lib"]
|
18
32
|
|
19
|
-
spec.add_development_dependency "bundler", "~> 1.
|
33
|
+
spec.add_development_dependency "bundler", "~> 1.16"
|
20
34
|
spec.add_development_dependency "rake", "~> 10.0"
|
21
|
-
spec.add_development_dependency
|
22
|
-
spec.
|
23
|
-
|
24
|
-
|
35
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
36
|
+
spec.add_development_dependency "dotenv", "~> 2.5"
|
37
|
+
spec.add_development_dependency "webmock", "~> 3.4"
|
38
|
+
spec.add_development_dependency "rails", "~> 4.2"
|
25
39
|
end
|
@@ -1,14 +1,16 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
|
1
3
|
module GlobelabsSmsRails
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
4
|
+
module Generators
|
5
|
+
class InstallGenerator < Rails::Generators::NamedBase
|
6
|
+
source_root File.expand_path('../templates', __FILE__)
|
7
|
+
desc 'Creates globelabs_sms_rails.rb initializer for your application'
|
8
|
+
|
9
|
+
def copy_initializer
|
10
|
+
template 'globelabs_sms_rails_initializer.rb', 'config/initializers/globelabs_sms_rails.rb'
|
11
|
+
|
12
|
+
puts "Install complete! Configure the file in config/initializers/globelabs_sms_rails.rb"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/lib/globelabs_sms_rails.rb
CHANGED
@@ -1,65 +1,23 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
1
|
+
require 'globelabs_sms_rails/version'
|
2
|
+
require 'globelabs_sms_rails/configuration'
|
3
|
+
require 'globelabs_sms_rails/client'
|
4
|
+
require 'globelabs_sms_rails/errors/configuration'
|
5
|
+
require 'generators/globelabs_sms_rails/install_generator'
|
5
6
|
|
6
7
|
module GlobelabsSmsRails
|
7
|
-
|
8
8
|
class << self
|
9
9
|
attr_accessor :configuration
|
10
10
|
end
|
11
11
|
|
12
|
-
def self.
|
13
|
-
|
14
|
-
yield(configuration)
|
12
|
+
def self.configuration
|
13
|
+
@configuration ||= Configuration.new
|
15
14
|
end
|
16
15
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
def initialize
|
21
|
-
@short_code = ''
|
22
|
-
@app_id = ''
|
23
|
-
@app_secret = ''
|
24
|
-
@api_version = 'v1'
|
25
|
-
@passphrase = ''
|
26
|
-
@message = ''
|
27
|
-
@address = ''
|
28
|
-
end
|
16
|
+
def self.reset
|
17
|
+
@configuration = Configuration.new
|
29
18
|
end
|
30
19
|
|
31
|
-
def self.
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
if @address.nil? || @message.nil?
|
36
|
-
raise 'Address or message is nil'
|
37
|
-
else
|
38
|
-
unless customCred.nil?
|
39
|
-
appId = customCred[:app_id]
|
40
|
-
appSecret = customCred[:app_secret]
|
41
|
-
passPhrase = customCred[:passphrase]
|
42
|
-
shortCode = customCred[:short_code]
|
43
|
-
else
|
44
|
-
appId = self.configuration.app_id
|
45
|
-
appSecret = self.configuration.app_secret
|
46
|
-
passPhrase = self.configuration.passphrase
|
47
|
-
shortCode = self.configuration.short_code
|
48
|
-
end
|
49
|
-
|
50
|
-
data = {
|
51
|
-
address: @address,
|
52
|
-
message: @message,
|
53
|
-
app_id: appId,
|
54
|
-
app_secret: appSecret,
|
55
|
-
passphrase: passPhrase
|
56
|
-
}
|
57
|
-
|
58
|
-
uri = URI.parse("https://devapi.globelabs.com.ph/smsmessaging/#{self.configuration.api_version}/outbound/#{shortCode}/requests")
|
59
|
-
res = Net::HTTP.post_form(uri, data)
|
60
|
-
|
61
|
-
return JSON.parse(res.body).merge(http_code: res.code)
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
end
|
20
|
+
def self.configure
|
21
|
+
yield(configuration)
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
module GlobelabsSmsRails
|
5
|
+
class Client
|
6
|
+
attr_accessor :app_id, :app_secret, :passphrase, :short_code, :host, :address, :message
|
7
|
+
MSG_PARAMS = {}
|
8
|
+
|
9
|
+
def initialize(options = {})
|
10
|
+
@app_id = GlobelabsSmsRails.configuration.app_id
|
11
|
+
@app_secret = GlobelabsSmsRails.configuration.app_secret
|
12
|
+
@passphrase = GlobelabsSmsRails.configuration.passphrase
|
13
|
+
@short_code = GlobelabsSmsRails.configuration.short_code
|
14
|
+
@host = "https://devapi.globelabs.com.ph/smsmessaging/v1/outbound/#{short_code}/requests"
|
15
|
+
@address = options[:address]
|
16
|
+
@message = options[:message]
|
17
|
+
end
|
18
|
+
|
19
|
+
def send
|
20
|
+
uri = URI(host)
|
21
|
+
|
22
|
+
request = Net::HTTP.post_form(uri, message_params)
|
23
|
+
response = JSON.parse(request.body, symbolize_names: true)
|
24
|
+
|
25
|
+
if response.has_key?(:http_code)
|
26
|
+
case response[:http_code].to_i
|
27
|
+
when 400
|
28
|
+
raise Errors::BadRequest, response[:error]
|
29
|
+
when 401
|
30
|
+
raise Errors::Authentication, response[:error]
|
31
|
+
else
|
32
|
+
raise StandardError, response[:error]
|
33
|
+
end
|
34
|
+
else
|
35
|
+
response.merge!(http_code: '200')
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.send(options={})
|
40
|
+
obj = self.new(options)
|
41
|
+
return obj.send
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
45
|
+
|
46
|
+
def message_params
|
47
|
+
MSG_PARAMS['app_id'] = app_id
|
48
|
+
MSG_PARAMS['app_secret'] = app_secret
|
49
|
+
MSG_PARAMS['passphrase'] = passphrase
|
50
|
+
MSG_PARAMS['address'] = address
|
51
|
+
MSG_PARAMS['message'] = message
|
52
|
+
MSG_PARAMS
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module GlobelabsSmsRails
|
2
|
+
class Configuration
|
3
|
+
|
4
|
+
attr_writer :app_id, :app_secret, :passphrase, :short_code
|
5
|
+
|
6
|
+
def initialize
|
7
|
+
@app_id = nil
|
8
|
+
@app_secret = nil
|
9
|
+
@passphrase = nil
|
10
|
+
@short_code = nil
|
11
|
+
end
|
12
|
+
|
13
|
+
def app_id
|
14
|
+
raise Errors::Configuration, "Globe Labs application id missing! See documentation for configuration settings." unless @app_id
|
15
|
+
@app_id
|
16
|
+
end
|
17
|
+
|
18
|
+
def app_secret
|
19
|
+
raise Errors::Configuration, "Globe Labs application secret missing! See documentation for configuration settings." unless @app_secret
|
20
|
+
@app_secret
|
21
|
+
end
|
22
|
+
|
23
|
+
def passphrase
|
24
|
+
raise Errors::Configuration, "Globe Labs application passphrase missing! See documentation for configuration settings." unless @passphrase
|
25
|
+
@passphrase
|
26
|
+
end
|
27
|
+
|
28
|
+
def short_code
|
29
|
+
raise Errors::Configuration, "Globe Labs short code missing! See documentation for configuration settings." unless @short_code
|
30
|
+
@short_code
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: globelabs_sms_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nujian Den Mark Meralpis
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-07-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '1.
|
19
|
+
version: '1.16'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '1.
|
26
|
+
version: '1.16'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -42,26 +42,74 @@ dependencies:
|
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: dotenv
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
46
60
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
61
|
+
version: '2.5'
|
48
62
|
type: :development
|
49
63
|
prerelease: false
|
50
64
|
version_requirements: !ruby/object:Gem::Requirement
|
51
65
|
requirements:
|
52
|
-
- - "
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '2.5'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: webmock
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '3.4'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '3.4'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rails
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '4.2'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
53
95
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
55
|
-
description:
|
96
|
+
version: '4.2'
|
97
|
+
description: This gem will help you send SMS using Globe Labs API. Please take note
|
98
|
+
that this gem will work if the subscriber consent workflow is disabled. You can
|
99
|
+
apply the process by asking Globe
|
56
100
|
email:
|
57
101
|
- meralpisdenmark@gmail.com
|
58
102
|
executables: []
|
59
103
|
extensions: []
|
60
104
|
extra_rdoc_files: []
|
61
105
|
files:
|
106
|
+
- ".env.sample"
|
62
107
|
- ".gitignore"
|
108
|
+
- ".rspec"
|
109
|
+
- ".travis.yml"
|
63
110
|
- CODE_OF_CONDUCT.md
|
64
111
|
- Gemfile
|
112
|
+
- Gemfile.lock
|
65
113
|
- LICENSE.txt
|
66
114
|
- README.md
|
67
115
|
- Rakefile
|
@@ -69,11 +117,13 @@ files:
|
|
69
117
|
- bin/setup
|
70
118
|
- globelabs_sms_rails.gemspec
|
71
119
|
- lib/generators/globelabs_sms_rails/install_generator.rb
|
72
|
-
- lib/generators/templates/globelabs_sms_rails_initializer.rb
|
120
|
+
- lib/generators/globelabs_sms_rails/templates/globelabs_sms_rails_initializer.rb
|
73
121
|
- lib/globelabs_sms_rails.rb
|
74
|
-
- lib/globelabs_sms_rails/
|
122
|
+
- lib/globelabs_sms_rails/client.rb
|
123
|
+
- lib/globelabs_sms_rails/configuration.rb
|
124
|
+
- lib/globelabs_sms_rails/errors/configuration.rb
|
75
125
|
- lib/globelabs_sms_rails/version.rb
|
76
|
-
homepage: https://github.com/denmarkmeralpis
|
126
|
+
homepage: https://github.com/denmarkmeralpis/globelabs_sms_rails
|
77
127
|
licenses:
|
78
128
|
- MIT
|
79
129
|
metadata: {}
|
@@ -93,8 +143,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
93
143
|
version: '0'
|
94
144
|
requirements: []
|
95
145
|
rubyforge_project:
|
96
|
-
rubygems_version: 2.6
|
146
|
+
rubygems_version: 2.7.6
|
97
147
|
signing_key:
|
98
148
|
specification_version: 4
|
99
|
-
summary:
|
149
|
+
summary: A simple gem for sending SMS through Globe Labs API.
|
100
150
|
test_files: []
|
@@ -1,7 +0,0 @@
|
|
1
|
-
GlobelabsSmsRails.configure do |config|
|
2
|
-
config.app_id = '' # add your globelabs app app_id
|
3
|
-
config.app_secret = '' # add your globelabs app app_secret
|
4
|
-
config.passphrase = '' # add the given passphrase(provided by globe telecom)
|
5
|
-
config.short_code = '' # add the app short code
|
6
|
-
config.api_version = 'v1'
|
7
|
-
end
|