mygengo 1.3 → 1.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -5,7 +5,7 @@ require 'net/http'
5
5
  require 'uri'
6
6
  require 'cgi'
7
7
  require 'json'
8
- require 'hmac-sha1'
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(pk, ts)
54
- HMAC::SHA1.hexdigest @opts[:private_key], ts
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[:api_key], query[:ts])
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[:api_key], query[:ts]),
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
@@ -11,6 +11,6 @@ module MyGengo
11
11
  SANDBOX_API_HOST = 'api.sandbox.mygengo.com'
12
12
 
13
13
  # Pretty self explanatory.
14
- VERSION = '1.3'
14
+ VERSION = '1.4'
15
15
  end
16
16
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: mygengo
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: "1.3"
5
+ version: "1.4"
6
6
  platform: ruby
7
7
  authors:
8
8
  - Ryan McGrath <ryan@mygengo.com>