<commit_before>require 'faraday'
require 'faraday_middleware'

module WpApiClient
  class Connection

    attr_accessor :headers

    def initialize(configuration)
      @configuration = configuration
      @conn = Faraday.new(url: configuration.endpoint) do |faraday|
        if configuration.oauth_credentials
          faraday.use FaradayMiddleware::OAuth, configuration.oauth_credentials
        end
        faraday.response :json, :content_type => /\bjson$/
        faraday.adapter  Faraday.default_adapter  # make requests with Net::HTTP
      end
    end

    # translate requests into wp-api urls
    def get(url, params = {})
      @conn.get url, params.merge(@configuration.request_params)
    end
  end<commit_msg>Raise Exceptions on non-200 response<commit_after>require 'faraday'
require 'faraday_middleware'

module WpApiClient
  class Connection

    attr_accessor :headers

    def initialize(configuration)
      @configuration = configuration
      @conn = Faraday.new(url: configuration.endpoint) do |faraday|
        if configuration.oauth_credentials
          faraday.use FaradayMiddleware::OAuth, configuration.oauth_credentials
        end
        faraday.use Faraday::Response::RaiseError
        faraday.response :json, :content_type => /\bjson$/
        faraday.adapter  Faraday.default_adapter  # make requests with Net::HTTP
      end
    end

    # translate requests into wp-api urls
    def get(url, params = {})
      @conn.get url, params.merge(@configuration.request_params)
    end
  end
{'fraction_non_alphanumeric': 0.08010505581089954, 'fraction_numerical': 0.001969796454366382, 'mean_word_length': 3.245125348189415, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '7534347', 'n_tokens_mistral': 451, 'n_tokens_neox': 422, 'n_words': 105}