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 +4 -4
- data/lib/sms_sender.rb +6 -6
- data/sms_global_sender.gemspec +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2bf1becd135e8ac9cf50f9669fce3365bfd6ba3b
|
4
|
+
data.tar.gz: 5e301829f604bcae40c63169bd87906bc16a1214
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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://#{
|
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#{
|
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
|
data/sms_global_sender.gemspec
CHANGED