<commit_before>require 'faraday'
require 'faraday_middleware'

Dir[File.expand_path('../resources/*.rb', __FILE__)].each{|f| require f}

module Closeio
  class Client
    include Closeio::Client::Activity
    include Closeio::Client::BulkAction
    include Closeio::Client::Contact
    include Closeio::Client::CustomField
    include Closeio::Client::EmailTemplate
    include Closeio::Client::Lead
    include Closeio::Client::LeadStatus
    include Closeio::Client::Opportunity
    include Closeio::Client::OpportunityStatus
    include Closeio::Client::Organization
    include Closeio::Client::Report
    include Closeio::Client::SmartView
    include Closeio::Client::Task
    include Closeio::Client::User

    attr_reader :api_key

    def initialize(api_key)
      @api_key = api_key
    end

    def get(path, options={})
      connection.get(path, options).body
    end

    def post(path, req_body)
      connection.post do |req|
        req.url(path)
        req.body = req_body
      end.body
    end

    def put(path, options={})
      connection.put(path, options).body
    end

    def delete(path, options = {})
      connection.delete(path, options).body
    end

    def paginate(path, options)
      results = []
      skip    = 0

      begin
        res   = get(lead_path, options.merge!(_skip: skip))
        results.push res.data
        skip += res.data.count if data
      end while res.has_more
      json = {has_more: false, total_results: res.total_results, data: results.flatten}
      Hashie::Mash.new json
    end

    private


    def connection
      Faraday.new(url: "https://app.close.io/api/v1", headers: { accept: 'application/json' }) do |connection|
        connection.basic_auth api_key, ''
        connection.request    :json
        connection.response   :logger
        connection.use        FaradayMiddleware::Mashify
        connection.response   :json
        connection.adapter    Faraday.default_adapter
      end
    end
  end
end<commit_msg>res.data instead of data<commit_after>require 'faraday'
require 'faraday_middleware'

Dir[File.expand_path('../resources/*.rb', __FILE__)].each{|f| require f}

module Closeio
  class Client
    include Closeio::Client::Activity
    include Closeio::Client::BulkAction
    include Closeio::Client::Contact
    include Closeio::Client::CustomField
    include Closeio::Client::EmailTemplate
    include Closeio::Client::Lead
    include Closeio::Client::LeadStatus
    include Closeio::Client::Opportunity
    include Closeio::Client::OpportunityStatus
    include Closeio::Client::Organization
    include Closeio::Client::Report
    include Closeio::Client::SmartView
    include Closeio::Client::Task
    include Closeio::Client::User

    attr_reader :api_key

    def initialize(api_key)
      @api_key = api_key
    end

    def get(path, options={})
      connection.get(path, options).body
    end

    def post(path, req_body)
      connection.post do |req|
        req.url(path)
        req.body = req_body
      end.body
    end

    def put(path, options={})
      connection.put(path, options).body
    end

    def delete(path, options = {})
      connection.delete(path, options).body
    end

    def paginate(path, options)
      results = []
      skip    = 0

      begin
        res   = get(lead_path, options.merge!(_skip: skip))
        results.push res.data
        skip += res.data.count if res.data
      end while res.has_more
      json = {has_more: false, total_results: res.total_results, data: results.flatten}
      Hashie::Mash.new json
    end

    private


    def connection
      Faraday.new(url: "https://app.close.io/api/v1", headers: { accept: 'application/json' }) do |connection|
        connection.basic_auth api_key, ''
        connection.request    :json
        connection.response   :logger
        connection.use        FaradayMiddleware::Mashify
        connection.response   :json
        connection.adapter    Faraday.default_adapter
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.10337078651685393, 'fraction_numerical': 0.0009987515605493133, 'mean_word_length': 2.859344894026975, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '473542', 'n_tokens_mistral': 1196, 'n_tokens_neox': 1155, 'n_words': 266}