<commit_before>module Shirtsio
  module Request
    def get(path, options = {}, headers = {}, raw = false)
      request(:get, path, options, headers, raw)
    end

    def post(path, options = {}, headers = {}, raw = false)
      request(:post, path, options, headers, raw)
    end

    private
    # Perform an HTTP request
    def request(method, path, options, headers, raw)
      headers.merge!({
        'User-Agent' => user_agent
      })

      options.merge!({
        :api_key => api_key
      })

      response = connection.send(method) do |request|
        if method == :get
          request.url "#{endpoint}#{path}", options
        else
          request.url "#{endpoint}#{path}"
          request.body = options
        end
        request.headers = headers
      end
      Shirtsio::Utils.handle_api_error(response) if response.status != 200

      if raw
        result = response.body
      else
        # The API is returning the "result" encoded as a string rather than
        # object notation so it requires a second pass of the JSON parser
        result = Shirtsio::Utils.parse_json(response.body)[:result]
      end

      result
    end
  end
end
<commit_msg>Simplified how params are passed into a request.<commit_after>module Shirtsio
  module Request
    def get(path, options = {}, headers = {}, raw = false)
      request(:get, path, options, headers, raw)
    end

    def post(path, options = {}, headers = {}, raw = false)
      request(:post, path, options, headers, raw)
    end

    private
    # Perform an HTTP request
    def request(method, path, options, headers, raw)
      headers.merge!({
        'User-Agent' => user_agent
      })

      options.merge!({
        :api_key => api_key
      })

      response = connection.send(method) do |request|
        request.url "#{endpoint}#{path}", options
        request.body = options
        request.headers = headers
      end
      Shirtsio::Utils.handle_api_error(response) if response.status != 200

      if raw
        result = response.body
      else
        # The API is returning the "result" encoded as a string rather than
        # object notation so it requires a second pass of the JSON parser
        result = Shirtsio::Utils.parse_json(response.body)[:result]
      end

      result
    end
  end
end

{'fraction_non_alphanumeric': 0.10246433203631647, 'fraction_numerical': 0.0025940337224383916, 'mean_word_length': 2.2869318181818183, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '776847', 'n_tokens_mistral': 651, 'n_tokens_neox': 635, 'n_words': 208}