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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e09c5e7d4327fc9d0439bae34d8c97b97e06df53fd7422e8c35bcdb31e6b0ab6
4
- data.tar.gz: 310fba6f213b8f818d85112b185ee9d61f045aa02f80424e64ea4c1e5b3910b7
3
+ metadata.gz: 3c82fc62f62444e71260e7436838c498c19404f1e0a8db774238f445d3f9d17b
4
+ data.tar.gz: '04461328ae006062b66e26ec768d2df9d9271ac4395bf9396578229f3a2a3a04'
5
5
  SHA512:
6
- metadata.gz: 772a9b35c1d5842c938b6dd9295ef360d57217357562d47afb5dd46432aaeca727c3a39d18eb70b09541f7b499227344f4abfef1ab5f8e52380204fcb5efd823
7
- data.tar.gz: fa5f20c6f106ec5e19ba0fa9c21233438af697f5b5030a74ebff284fca4dec21035373d1d45e9cd26ec52f95fddb5cf818f343fdcfcc0c5835d1d2d494e7f5fc
6
+ metadata.gz: bb3231dd6b8a1e9c21540b6db2782aba9f68a7cdc9ccb47cde148fba7d4540c89ad27204e63eaa6cd60d5aa97716dd5a10067a35b99e7e754d5c52d2c0ee5941
7
+ data.tar.gz: ae5a6f23ff904659c4ddbc19e42e6f01bda5f2e778348fa9ebbdd81e942fe286b9df0e785b5a11da3b18f8cdd0f04cc9ec969d4e72acdd0d90ca75e10a60d334
data/.gitignore CHANGED
@@ -10,4 +10,6 @@
10
10
 
11
11
  # rspec failure tracking
12
12
  .rspec_status
13
- .env
13
+ .env
14
+
15
+ *.gem
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- globelabs_sms_rails (0.1.1)
4
+ globelabs_sms_rails (0.1.2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
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(address: '0917XXXXXXX', message: 'Your message here!)
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
@@ -1,3 +1,3 @@
1
1
  module GlobelabsSmsRails
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  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.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-02 00:00:00.000000000 Z
11
+ date: 2018-11-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler