<commit_before>require 'net/http'
require 'json'

class ZiggeoConnect
  def initialize(application)
    @application = application
  end

  def request(method, path, data = nil, file = nil)
    url = URI.parse(@application.config.server_api_url + '/v1' + path)
    if (method == "GET")
      if (data != nil)
        url.query = URI.encode_www_form(data)
      end
      req = Net::HTTP::Get.new(url.to_s)
    elsif (method == "POST")
      req = Net::HTTP::Post.new(url.to_s)
      if (data != nil)
      req.req.set_form_data(data)
      end
    elsif (method == "DELETE")
      req = Net::HTTP::Delete.new(url.to_s)
      if (data != nil)
      req.req.set_form_data(data)
      end
    end
    req.basic_auth(@application.token, @application.private_key)
    http = Net::HTTP.new(url.host, url.port)
    if (url.scheme == "https")
      http.use_ssl = true
      http.verify_mode = OpenSSL::SSL::VERIFY_NONE
    end
    res = http.start() {|agent|
      agent.request(req)
    }
    return res.body
  end

  def requestJSON(method, path, data = nil, file = nil)
    return JSON.parse self.request(method, path, data, file)
  end

  def get(path, data = nil, file = nil)
    return self.request("GET", path, data, file)
  end

  def getJSON(path, data = nil, file = nil)
    return self.requestJSON("GET", path, data, file)
  end

  def post(path, data = nil, file = nil)
    return self.request("POST", path, data, file)
  end

  def postJSON(path, data = nil, file = nil)
    return self.requestJSON("POST", path, data, file)
  end

  def delete(path, data = nil, file = nil)
    return self.request("DELETE", path, data, file)
  end

  def deleteJSON(path, data = nil, file = nil)
    return self.requestJSON("DELETE", path, data, file)
  end

end
<commit_msg>fix ZiggeoConnect#request when creating authtoken<commit_after>require 'net/http'
require 'json'

class ZiggeoConnect
  def initialize(application)
    @application = application
  end

  def request(method, path, data = nil, file = nil)
    url = URI.parse(@application.config.server_api_url + '/v1' + path)
    if (method == "GET")
      if (data != nil)
        url.query = URI.encode_www_form(data)
      end
      req = Net::HTTP::Get.new(url.to_s)
    elsif (method == "POST")
      req = Net::HTTP::Post.new(url.to_s)
      if (data != nil)
      req.set_form_data(data)
      end
    elsif (method == "DELETE")
      req = Net::HTTP::Delete.new(url.to_s)
      if (data != nil)
      req.set_form_data(data)
      end
    end
    req.basic_auth(@application.token, @application.private_key)
    http = Net::HTTP.new(url.host, url.port)
    if (url.scheme == "https")
      http.use_ssl = true
      http.verify_mode = OpenSSL::SSL::VERIFY_NONE
    end
    res = http.start() {|agent|
      agent.request(req)
    }
    return res.body
  end

  def requestJSON(method, path, data = nil, file = nil)
    return JSON.parse self.request(method, path, data, file)
  end

  def get(path, data = nil, file = nil)
    return self.request("GET", path, data, file)
  end

  def getJSON(path, data = nil, file = nil)
    return self.requestJSON("GET", path, data, file)
  end

  def post(path, data = nil, file = nil)
    return self.request("POST", path, data, file)
  end

  def postJSON(path, data = nil, file = nil)
    return self.requestJSON("POST", path, data, file)
  end

  def delete(path, data = nil, file = nil)
    return self.request("DELETE", path, data, file)
  end

  def deleteJSON(path, data = nil, file = nil)
    return self.requestJSON("DELETE", path, data, file)
  end

end

{'fraction_non_alphanumeric': 0.13623595505617977, 'fraction_numerical': 0.0005617977528089888, 'mean_word_length': 2.926130099228225, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '1334451', 'n_tokens_mistral': 1230, 'n_tokens_neox': 1213, 'n_words': 326}