sms_global_sender 0.0.1 → 0.0.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
  SHA1:
3
- metadata.gz: 0bed878785d69c6378b891f639e52c1f736b0bd4
4
- data.tar.gz: 37fdf352e352745a56041c03dfb8a19994cdf907
3
+ metadata.gz: 2bf1becd135e8ac9cf50f9669fce3365bfd6ba3b
4
+ data.tar.gz: 5e301829f604bcae40c63169bd87906bc16a1214
5
5
  SHA512:
6
- metadata.gz: 62b22526fb66f5dc62d0e71a44efdeb2bda20f742d762ad1f3be27bdc0ef97be7b3bf1d6794f5c8a12e1919842a775a010a9485ceda800723f1d36c631cef226
7
- data.tar.gz: 6c38fbc1df725e82986d5f947ddc0ce18d4497a418f18571c1236338af48eac3b96f6bbf20c193144fd2c648af3c0b9c77727906bf8cb3b9f6872ff4a1a1eb21
6
+ metadata.gz: 101770f44f81591a4e3e00b576caa56d4c08bfea3a54d3bcaab6345e702c625c67c4134e7b1d63b5b38f95563e060c80b160fe159188706e0ecf371fb13681f1
7
+ data.tar.gz: 62c5175fae503d654473ca385dc61eb66fe3b8afd5f0fe42a01a7b9ba4e755662c53eb9a34db58c406c8c637468408899c73ac9998d650021242b81ba5b3663f
data/lib/sms_sender.rb CHANGED
@@ -3,12 +3,12 @@ require 'base64'
3
3
  require 'httparty'
4
4
 
5
5
  class SmsSender
6
- @@host = 'api.smsglobal.com'
7
- @@port = '443'
8
- @@request_url = '/v1/sms/'
9
- def initialize(client_id, client_secret)
6
+ def initialize(client_id, client_secret, host='api.smsglobal.com', port='443', request_url='/v1/sms/' )
10
7
  @client_id = client_id
11
8
  @secret = client_secret
9
+ @host = host
10
+ @port = port
11
+ @request_url = request_url
12
12
  end
13
13
 
14
14
  def send(title, msg, mobile)
@@ -21,13 +21,13 @@ class SmsSender
21
21
 
22
22
  body = {"origin"=>title, "destination"=>mobile, "message"=>msg }
23
23
 
24
- response = HTTParty.post("https://#{@@host}#{@@request_url}", headers: header, body: body.to_json)
24
+ response = HTTParty.post("https://#{@host}#{@request_url}", headers: header, body: body.to_json)
25
25
  response.code
26
26
  end
27
27
 
28
28
  private
29
29
  def calculate_mac
30
- body = "#{@ts}\n#{@nonce}\nPOST\n#{@@request_url}\n#{@@host}\n#{@@port}\n\n"
30
+ body = "#{@ts}\n#{@nonce}\nPOST\n#{@request_url}\n#{@host}\n#{@port}\n\n"
31
31
  digest = Digest::HMAC.digest(body, @secret, Digest::SHA256)
32
32
  Base64.strict_encode64 digest
33
33
  end
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'sms_global_sender'
3
- s.version = '0.0.1'
3
+ s.version = '0.0.2'
4
4
  s.date = '2014-02-05'
5
5
  s.summary = "Send sms through SMS gateway"
6
6
  s.description = "specific to smsglobal.com.au"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sms_global_sender
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Harry Gao