<commit_before>require "fyber_gateway/hash_calculator"

class FyberGateway
  class OffersRequest
    def initialize(params, api_key)
      @params = params
      @api_key = api_key
    end

    def url
      url = "http://api.fyber.com/feed/v1/offers.json?"
      url << params.flat_map { |k, v| "#{k}=#{v}" }.sort.join("&")
      url << "&hashkey=#{HashCalculator.new(params, api_key).calculate}"
      url
    end

    attr_reader :api_key, :params, :hash_calculator
  end
end<commit_msg>Encode request parameters when building URL<commit_after>require "fyber_gateway/hash_calculator"

class FyberGateway
  class OffersRequest
    def initialize(params, api_key)
      @params = params
      @api_key = api_key
    end

    def url
      url = "http://api.fyber.com/feed/v1/offers.json?"
      url << params.flat_map { |k, v| "#{k}=#{CGI.escape(v.to_s)}" }.sort.join("&")
      url << "&hashkey=#{HashCalculator.new(params, api_key).calculate}"
      url
    end

    private

    attr_reader :api_key, :params
  end
end
{'fraction_non_alphanumeric': 0.136986301369863, 'fraction_numerical': 0.0019569471624266144, 'mean_word_length': 3.1417004048582995, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 3, 'https://': 0, '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': '6796641', 'n_tokens_mistral': 375, 'n_tokens_neox': 368, 'n_words': 74}