Sha256: cfba27be0b42793bb3501bcc50e51716bd097d967d746a8af1c4c2d264b2a42a

Contents?: true

Size: 554 Bytes

Versions: 1

Compression:

Stored size: 554 Bytes

Contents

module Marvel
  module Request
    def get(path, options = {})
      request(:get, path, options)
    end

    private

    def request(method, path, options = {})
      response = connection.send(method) do |request|
        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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
marvel_api-0.2.0 lib/marvel/request.rb