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

module Plaid
  class Connection
    class << self
      # API: semi-private
      def post(path, options = {})
        uri = build_uri(path)
        options.merge!(client_id: Plaid.customer_id, secret: Plaid.secret)
        http = Net::HTTP.new(uri.host, uri.port)
        http.use_ssl = (uri.scheme == 'https')
        request = Net::HTTP::Post.new(uri.path)
        request.set_form_data(options)
        res = http.request(request)
        parse_response(res)
      end

      # API: semi-private
      def get(path, id = nil)
        uri = build_uri(path,id)
        res = Net::HTTP.get(uri)
        parse_get_response(res)
      end

      # API: semi-private
      def secure_get(path, access_token, options = {})
        uri = build_uri(path)
        options.merge!({access_token:access_token})
        req = Net::HTTP::Get.new(uri)
        req.body = URI.encode_www_form(options) if options
        req.content_type = 'application/x-www-form-urlencoded'
        res = Net::HTTP.start(uri.hostname, uri.port, :use_ssl => uri.scheme == 'https') { |http| http.request(req) }
        parse_response(res)
      end

      # API: semi-private
      def patch(path, options = {})
        uri = build_uri(path)
        options.merge!(client_id: Plaid.customer_id, secret: Plaid.secret)
        req = Net::HTTP::Patch.new(uri)
        req.body = URI.encode_www_form(options) if options
        req.content_type = 'application/x-www-form-urlencoded'
        res = Net::HTTP.start(uri.hostname, uri.port, :use_ssl => uri.scheme == 'https') { |http| http.request(req) }
        parse_response(res)
      end

      # API: semi-private
      def delete(path, options = {})
        uri = build_uri(path)
        options.merge!(client_id: Plaid.customer_id, secret: Plaid.secret)
        req = Net::HTTP::Delete.new(uri)
        req.body = URI.encode_www_form(options) if options
        req.content_type = 'application/x-www-form-urlencoded'
        Net::HTTP.start(uri.hostname, uri.port, :use_ssl => uri.scheme == 'https') { |http| http.request(req) }
      end

      protected

      # API: semi-private<commit_msg>Changes required for ruby 1.9.3<commit_after>require 'net/http'
require 'json'
require 'uri'

module Plaid
  class Connection
    class << self
      # API: semi-private
      def post(path, options = {})
        uri = build_uri(path)
        options.merge!(client_id: Plaid.customer_id, secret: Plaid.secret)
        http = Net::HTTP.new(uri.host, uri.port)
        http.use_ssl = (uri.scheme == 'https')
        request = Net::HTTP::Post.new(uri.path)
        request.set_form_data(options)
        res = http.request(request)
        parse_response(res)
      end

      # API: semi-private
      def get(path, id = nil)
        uri = build_uri(path,id)
        http = Net::HTTP.new(uri.host, uri.port)
        http.use_ssl = (uri.scheme == 'https')
        request = Net::HTTP::Get.new(uri.path)
        res = http.request(request)
        parse_get_response(res.body)
      end

      # API: semi-private
      def secure_get(path, access_token, options = {})
        uri = build_uri(path)
        options.merge!({access_token:access_token})
        req = Net::HTTP::Get.new(uri.path)
        req.body = URI.encode_www_form(options) if options
        req.content_type = 'application/x-www-form-urlencoded'
        res = Net::HTTP.start(uri.hostname, uri.port, :use_ssl => uri.scheme == 'https') { |http| http.request(req) }
        parse_response(res)
      end

      # API: semi-private
      def patch(path, options = {})
        uri = build_uri(path)
        options.merge!(client_id: Plaid.customer_id, secret: Plaid.secret)
        req = Net::HTTP::Patch.new(uri.path)
        req.body = URI.encode_www_form(options) if options
        req.content_type = 'application/x-www-form-urlencoded'
        res = Net::HTTP.start(uri.hostname, uri.port, :use_ssl => uri.scheme == 'https') { |http| http.request(req) }
        parse_response(res)
      end

      # API: semi-private
      def delete(path, options = {})
        uri = build_uri(path)
        options.merge!(client_id: Plaid.customer_id, secret: Plaid.secret)
        req = Net::HTTP::Delete.new(uri.path)
        req.body = URI.encode_www_form(options) if options
        req.content_type = 'application/x-www-form-urlencoded'
        Net::HTTP.start(uri.hostname, uri.port, :use_ssl => uri.scheme == 'https') { |http| http.request(req) }
      end

      protected

      # API: semi-private
{'fraction_non_alphanumeric': 0.1364037020713971, 'fraction_numerical': 0.0006610841780520053, 'mean_word_length': 2.551643192488263, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 12, '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': '2814360', 'n_tokens_mistral': 1469, 'n_tokens_neox': 1468, 'n_words': 279}