<commit_before>require "faraday"
require "faraday_middleware"
require "impermium/configuration"
require "impermium/content"
require "impermium/errors"
require "faraday/raise_4xx"

module Impermium
  class Client
    include Configuration
    include Content
    
    def initialize(options = {})
      options = Impermium.options.merge(options)
      Configuration::VALID_CONFIG_KEYS.each do |key|
        send("#{key}=", options[key])
      end
    end

    def connection
      @connection ||= Faraday.new(:url => endpoint, :headers => default_headers) do |builder|
        builder.use Faraday::Response::Mashify
        builder.use Faraday::Response::ParseJson
        builder.use Faraday::Response::Raise4xx
        builder.request :json

        builder.adapter adapter
      end
    end

    def post(url, options={})
      connection.post do |req|
        req.url api_url(url)
        req.headers['Content-Type'] = 'application/json'
        req.body = options
      end
    end

    private

    def default_headers
      { :http_user_agent => "Impermium Ruby Gem",
        :http_accept => "application/json"}
    end<commit_msg>Return body instead of response<commit_after>require "faraday"
require "faraday_middleware"
require "impermium/configuration"
require "impermium/content"
require "impermium/errors"
require "faraday/raise_4xx"

module Impermium
  class Client
    include Configuration
    include Content
    
    def initialize(options = {})
      options = Impermium.options.merge(options)
      Configuration::VALID_CONFIG_KEYS.each do |key|
        send("#{key}=", options[key])
      end
    end

    def connection
      @connection ||= Faraday.new(:url => endpoint, :headers => default_headers) do |builder|
        builder.use Faraday::Response::Mashify
        builder.use Faraday::Response::ParseJson
        builder.use Faraday::Response::Raise4xx
        builder.request :json

        builder.adapter adapter
      end
    end

    def post(url, options={})
      connection.post do |req|
        req.url api_url(url)
        req.headers['Content-Type'] = 'application/json'
        req.body = options
      end.body
    end

    private

    def default_headers
      { :http_user_agent => "Impermium Ruby Gem",
        :http_accept => "application/json"}
    end
{'fraction_non_alphanumeric': 0.1023073574227253, 'fraction_numerical': 0.0017414018284719198, 'mean_word_length': 2.9081632653061225, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '1515394', 'n_tokens_mistral': 679, 'n_tokens_neox': 658, 'n_words': 155}