<commit_before>require 'faraday'
require 'base64'
require 'mime/types'

module Nominal

  class Requestor

    attr_reader :private_api_key
    attr_reader :public_api_key
    attr_reader :time

    def initialize
      @private_api_key = Nominal.private_api_key
      @public_api_key = Nominal.public_api_key
      @time = Time.now.utc
    end

    def api_url(url='')
      api_base = Nominal.api_base
      api_base + url
    end

    def request(method, url, params=nil)

      url = self.api_url(url)
      meth = method.downcase

      begin
        conn = Faraday.new( url: url ) do |faraday|
          faraday.adapter Faraday.default_adapter
        end

        conn.headers['Authorization'] = get_token
        conn.headers['x-nominal-time'] = self.time
        conn.headers['Accept'] = MIME::Types['application/json']
        conn.headers['Content-Type'] = MIME::Types['application/json']

        if params
          conn.params = params
        end

        response = conn.method(meth).call
      rescue Exception => e
        Error.error_handler(e, "")
      end
      if response.status != 200
        Error.error_handler(JSON.parse(response.body), response.status)
      end

      JSON.parse(response.body)<commit_msg>Corrección bug time en request header.<commit_after>require 'faraday'
require 'base64'
require 'mime/types'

module Nominal

  class Requestor

    attr_reader :private_api_key
    attr_reader :public_api_key
    attr_reader :time

    def initialize
      @private_api_key = Nominal.private_api_key
      @public_api_key = Nominal.public_api_key
      @time = Time.now.utc
    end

    def api_url(url='')
      api_base = Nominal.api_base
      api_base + url
    end

    def request(method, url, params=nil)

      url = self.api_url(url)
      meth = method.downcase

      begin
        conn = Faraday.new( url: url ) do |faraday|
          faraday.adapter Faraday.default_adapter
        end

        conn.headers['Authorization'] = get_token
        conn.headers['x-nominal-time'] = self.time.to_s
        conn.headers['Accept'] = MIME::Types['application/json']
        conn.headers['Content-Type'] = MIME::Types['application/json']

        if params
          conn.params = params
        end

        response = conn.method(meth).call
      rescue Exception => e
        Error.error_handler(e, "")
      end
      if response.status != 200
        Error.error_handler(JSON.parse(response.body), response.status)
      end

      JSON.parse(response.body)
{'fraction_non_alphanumeric': 0.09992006394884093, 'fraction_numerical': 0.003996802557953637, 'mean_word_length': 2.457182320441989, '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': '4763717', 'n_tokens_mistral': 798, 'n_tokens_neox': 756, 'n_words': 158}