mygengo 1.3 → 1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/mygengo-ruby/api_handler.rb +5 -5
- data/lib/mygengo.rb +1 -1
- metadata +1 -1
@@ -5,7 +5,7 @@ require 'net/http'
|
|
5
5
|
require 'uri'
|
6
6
|
require 'cgi'
|
7
7
|
require 'json'
|
8
|
-
require '
|
8
|
+
require 'openssl'
|
9
9
|
require 'time'
|
10
10
|
|
11
11
|
module MyGengo
|
@@ -50,8 +50,8 @@ module MyGengo
|
|
50
50
|
end
|
51
51
|
|
52
52
|
# Creates an HMAC::SHA1 signature, signing the timestamp with the private key.
|
53
|
-
def signature_of(
|
54
|
-
HMAC
|
53
|
+
def signature_of(ts)
|
54
|
+
OpenSSL::HMAC.hexdigest 'sha1', @opts[:private_key], ts
|
55
55
|
end
|
56
56
|
|
57
57
|
# The "GET" method; handles requesting basic data sets from myGengo and converting
|
@@ -68,7 +68,7 @@ module MyGengo
|
|
68
68
|
:ts => Time.now.gmtime.to_i.to_s
|
69
69
|
}
|
70
70
|
|
71
|
-
endpoint << "?api_sig=" + signature_of(query[:
|
71
|
+
endpoint << "?api_sig=" + signature_of(query[:ts])
|
72
72
|
endpoint << '&' + query.map { |k, v| "#{k}=#{urlencode(v)}" }.join('&')
|
73
73
|
|
74
74
|
resp = Net::HTTP.start(@api_host, 80) do |http|
|
@@ -112,7 +112,7 @@ module MyGengo
|
|
112
112
|
|
113
113
|
request.content_type = 'application/x-www-form-urlencoded'
|
114
114
|
request.body = {
|
115
|
-
"api_sig" => signature_of(query[:
|
115
|
+
"api_sig" => signature_of(query[:ts]),
|
116
116
|
"api_key" => urlencode(@opts[:public_key]),
|
117
117
|
"data" => urlencode(params.to_json.gsub('\\', '\\\\')),
|
118
118
|
"ts" => Time.now.gmtime.to_i.to_s
|
data/lib/mygengo.rb
CHANGED