<commit_before>module MWS
  class Api
    def initialize(connection)
      @connection = connection
    end

    def get(options={})
      @options = options
      @options[:verb] = :get
      @connection.get(request_uri)
    end

    def post(options={})
      @options = options
      @options[:verb] = :post
      @connection.post(request_uri)
    end

    def request_uri
      "https://" << @connection.host << @options[:uri] << '?' << query(signature)
    end

    def canonical
      [@options[:verb].to_s.upcase, @connection.host.downcase, @options[:uri], query].join("\n")
    end

    def query(signature = nil)
      query = {
        :"AWSAccessKeyId" => @connection.aws_access_key_id,
        :"Action" => @options[:action],
        :"SellerId" => @connection.merchant_id,
        :"SignatureMethod" => "HmacSHA256",
        :"SignatureVersion" => 2,
        :"Timestamp" => Time.now.iso8601,
        :"Version" => @options[:version]
      }
      query[:"Signature"] = signature if signature

      query.merge(@options[:parameters]).to_query
    end

    def signature
      digest = OpenSSL::Digest::Digest.new('sha256')
      key = @connection.aws_secret_key
      Base64.encode64(OpenSSL::HMAC.digest(digest, key, canonical)).chomp
    end
  end
end<commit_msg>Add method 'camelize_hash'<commit_after>module MWS
  class Api
    def initialize(connection)
      @connection = connection
    end

    def get(options={})
      @options = options
      @options[:verb] = :get
      @connection.get(request_uri)
    end

    def post(options={})
      @options = options
      @options[:verb] = :post
      @connection.post(request_uri)
    end

    def request_uri
      "https://" << @connection.host << @options[:uri] << '?' << query(signature)
    end

    def canonical
      [@options[:verb].to_s.upcase, @connection.host.downcase, @options[:uri], query].join("\n")
    end

    def query(signature = nil)
      query = {
        :"AWSAccessKeyId" => @connection.aws_access_key_id,
        :"Action" => @options[:action],
        :"SellerId" => @connection.merchant_id,
        :"SignatureMethod" => "HmacSHA256",
        :"SignatureVersion" => 2,
        :"Timestamp" => Time.now.iso8601,
        :"Version" => @options[:version]
      }
      query[:"Signature"] = signature if signature

      query.merge(@options[:parameters]).to_query
    end

    def signature
      digest = OpenSSL::Digest::Digest.new('sha256')
      key = @connection.aws_secret_key
      Base64.encode64(OpenSSL::HMAC.digest(digest, key, canonical)).chomp
    end

    def camelize_hash(hash)
      hash.map {|key, value| {:"#{key.to_s.camelize}" => value}}.reduce({}, :merge)
    end
  end
end
{'fraction_non_alphanumeric': 0.15193164933135214, 'fraction_numerical': 0.011144130757800892, 'mean_word_length': 2.7929577464788733, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 18, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1021698', 'n_tokens_mistral': 882, 'n_tokens_neox': 829, 'n_words': 160}