Sha256: 6014370a3653e4060799b0fbde0c29358d369a17f181e53e59c6c14928d83e19

Contents?: true

Size: 493 Bytes

Versions: 5

Compression:

Stored size: 493 Bytes

Contents

module Mettlr
  class Signature
    def initialize(request)
      @request = request
    end

    def concat_string
      @request.method.to_s.upcase +
        "http://api.mettl.com" + 
        @request.path + 
        param_values
    end
    def param_values
      "\n" + @request.params.values.join("\n")
    end
    def signature
      hmac = OpenSSL::HMAC.digest('sha1', Mettlr::METTL_PRIVATE_KEY, concat_string)
      Faraday::Utils.escape(Base64.encode64(hmac).chomp)
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
mettlr-0.1.4 lib/mettlr/sig_gen.rb
mettlr-0.1.3 lib/mettlr/sig_gen.rb
mettlr-0.1.2 lib/mettlr/sig_gen.rb
mettlr-0.1.1 lib/mettlr/sig_gen.rb
mettlr-0.1.0 lib/mettlr/sig_gen.rb