<commit_before>require "net/http"
require "uri"

module Picolib
  module HTTPService
    def self.request(path, args, verb, options = {})
      uri = URI(path)
      res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == 'https') do |http|
        if verb == "post"
          req = Net::HTTP::Post.new(uri.path)
          # req.form_data = args[:params]
          req.body = args[:params].to_json
          req.content_type = 'application/json'
        else
          req = Net::HTTP::Get.new(uri.path)
        end
        if args[:access_token]
          req.add_field 'authorization', args[:access_token]
        end

        http.request req
      end

      if options[:debug]
        puts "============ API: #{uri} ==============="
        if args[:params]
          puts "     params: #{args[:params].to_json}"
        end
        puts "     result: #{res.body}"
        puts "============ END ======================="
      end
      return res
    end
  end
end<commit_msg>checking params is not empty to add in body when post api<commit_after>require "net/http"
require "uri"
require "openssl"

module Picolib
  module HTTPService
    def self.request(path, args, verb, options = {})
      uri = URI(path)
      res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == 'https') do |http|
        if verb == "post"
          req = Net::HTTP::Post.new(uri.path)
          # req.form_data = args[:params]
          if args[:params]
            req.body = args[:params].to_json
            req.content_type = 'application/json'
          end
        else
          req = Net::HTTP::Get.new(uri.path)
        end
        if args[:access_token]
          req.add_field 'authorization', args[:access_token]
        end

        http.request req
      end

      if options[:debug]
        puts "============ API: #{uri} ==============="
        if args[:params]
          puts "     params: #{args[:params].to_json}"
        end
        puts "     result: #{res.body}"
        puts "============ END ======================="
      end
      return res
    end
  end
end
{'fraction_non_alphanumeric': 0.17501192179303768, 'fraction_numerical': 0.0, 'mean_word_length': 2.062773722627737, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '1654349', 'n_tokens_mistral': 623, 'n_tokens_neox': 624, 'n_words': 153}