lib/marvel/request.rb in marvel_api-0.1.3 vs lib/marvel/request.rb in marvel_api-0.2.0

- old
+ new

@@ -4,13 +4,27 @@ request(:get, path, options) end private - def request(method, path, options) + def request(method, path, options = {}) response = connection.send(method) do |request| - request.url(path, options) + request.url(path, options.merge(auth)) end response.body end + + def auth + ts = timestamp + hsh = hash(ts) + { ts: ts, apikey: api_key, hash: hsh } + end + + def hash(ts) + Digest::MD5.hexdigest(ts + private_key + api_key) + end + + def timestamp + Time.now.to_s + end end end \ No newline at end of file