globelabs_sms_rails 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +3 -1
- data/Gemfile.lock +1 -1
- data/README.md +5 -5
- data/lib/globelabs_sms_rails/client.rb +11 -11
- data/lib/globelabs_sms_rails/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3c82fc62f62444e71260e7436838c498c19404f1e0a8db774238f445d3f9d17b
|
4
|
+
data.tar.gz: '04461328ae006062b66e26ec768d2df9d9271ac4395bf9396578229f3a2a3a04'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bb3231dd6b8a1e9c21540b6db2782aba9f68a7cdc9ccb47cde148fba7d4540c89ad27204e63eaa6cd60d5aa97716dd5a10067a35b99e7e754d5c52d2c0ee5941
|
7
|
+
data.tar.gz: ae5a6f23ff904659c4ddbc19e42e6f01bda5f2e778348fa9ebbdd81e942fe286b9df0e785b5a11da3b18f8cdd0f04cc9ec969d4e72acdd0d90ca75e10a60d334
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -19,11 +19,11 @@ And then execute:
|
|
19
19
|
Or install it yourself as:
|
20
20
|
|
21
21
|
$ gem install globelabs_sms_rails
|
22
|
-
|
22
|
+
|
23
23
|
Generate initializer to config/initializer via:
|
24
24
|
|
25
25
|
$ rails g globelabs_sms_rails:install initializer
|
26
|
-
|
26
|
+
|
27
27
|
then edit the file in `config/initializer/globelabs_sms_rails.rb` and supply the necessary details.
|
28
28
|
|
29
29
|
## Usage
|
@@ -32,10 +32,10 @@ Two way of sending SMS:
|
|
32
32
|
```ruby
|
33
33
|
# Direct sending through class method #send
|
34
34
|
GlobelabsSmsRails::Client.send(address: '0917XXXXXXX', message: 'Your message here!')
|
35
|
-
|
35
|
+
|
36
36
|
# Initialize and send
|
37
|
-
client = GlobelabsSmsRails::Client.new
|
38
|
-
ciient.send
|
37
|
+
client = GlobelabsSmsRails::Client.new
|
38
|
+
ciient.send(address: '0917XXXXXXX', message: 'Your message here!)
|
39
39
|
```
|
40
40
|
|
41
41
|
# License
|
@@ -2,7 +2,7 @@ require 'net/http'
|
|
2
2
|
require 'json'
|
3
3
|
|
4
4
|
module GlobelabsSmsRails
|
5
|
-
class Client
|
5
|
+
class Client
|
6
6
|
attr_accessor :app_id, :app_secret, :passphrase, :short_code, :host, :address, :message
|
7
7
|
MSG_PARAMS = {}
|
8
8
|
|
@@ -12,20 +12,20 @@ module GlobelabsSmsRails
|
|
12
12
|
@passphrase = GlobelabsSmsRails.configuration.passphrase
|
13
13
|
@short_code = GlobelabsSmsRails.configuration.short_code
|
14
14
|
@host = "https://devapi.globelabs.com.ph/smsmessaging/v1/outbound/#{short_code}/requests"
|
15
|
-
@address = options[:address]
|
16
|
-
@message = options[:message]
|
17
15
|
end
|
18
16
|
|
19
|
-
def send
|
17
|
+
def send(options)
|
18
|
+
@address = options.fetch(:address)
|
19
|
+
@message = options.fetch(:message)
|
20
20
|
uri = URI(host)
|
21
21
|
|
22
22
|
request = Net::HTTP.post_form(uri, message_params)
|
23
23
|
response = JSON.parse(request.body, symbolize_names: true)
|
24
24
|
|
25
25
|
if response.has_key?(:http_code)
|
26
|
-
case response[:http_code].to_i
|
26
|
+
case response[:http_code].to_i
|
27
27
|
when 400
|
28
|
-
raise Errors::BadRequest, response[:error]
|
28
|
+
raise Errors::BadRequest, response[:error]
|
29
29
|
when 401
|
30
30
|
raise Errors::Authentication, response[:error]
|
31
31
|
else
|
@@ -33,16 +33,16 @@ module GlobelabsSmsRails
|
|
33
33
|
end
|
34
34
|
else
|
35
35
|
response.merge!(http_code: '200')
|
36
|
-
end
|
36
|
+
end
|
37
37
|
end
|
38
38
|
|
39
39
|
def self.send(options={})
|
40
40
|
obj = self.new(options)
|
41
|
-
return obj.send
|
41
|
+
return obj.send(options)
|
42
42
|
end
|
43
|
-
|
43
|
+
|
44
44
|
private
|
45
|
-
|
45
|
+
|
46
46
|
def message_params
|
47
47
|
MSG_PARAMS['app_id'] = app_id
|
48
48
|
MSG_PARAMS['app_secret'] = app_secret
|
@@ -50,6 +50,6 @@ module GlobelabsSmsRails
|
|
50
50
|
MSG_PARAMS['address'] = address
|
51
51
|
MSG_PARAMS['message'] = message
|
52
52
|
MSG_PARAMS
|
53
|
-
end
|
53
|
+
end
|
54
54
|
end
|
55
55
|
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.1.
|
4
|
+
version: 0.1.2
|
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: 2018-11-
|
11
|
+
date: 2018-11-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|