<commit_before>require "rubygems"
require "json"
require "openssl"
require "time"
require "net/https"
require "uri"

class Azuqua
  VERSION = "1.0.0"

	HTTP_OPTIONS = {
		:host => "https://api.azuqua.com", 
		:headers => {
			"Content-Type" => "application/json"
		}
	}

  @accessKey = nil
  @accessSecret = nil

  def initialize(key, secret)
    @accessKey = key
    @accessSecret = secret
    raise "Invalid account credentials" unless @accessKey && @accessSecret
  end

  def self.from_config(path)
    open(path, "r") do |file|
      data = JSON.parse(file.read)
      accessKey = data["accessKey"]
      accessSecret = data["accessSecret"]
      Azuqua.new(accessKey, accessSecret)
    end
  end

  def self.from_env()
      accessKey = ENV["AZUQUA_ACCESS_KEY"]
      accessSecret = ENV["AZUQUA_ACCESS_SECRET"]
      Azuqua.new(accessKey, accessSecret)
  end

  def account
    unless @accessKey.nil? || @accessSecret.nil?
      {
        :accessKey => @accessKey,
        :accessSecret => @accessSecret
      }
    else
      raise "Invalid account credentials"
    end
  end

  # Invokes an Azuqua Flo
  def invoke(floAlias, data, verb="POST")
    invokeRoute = "/flo/" + floAlias + "/invoke";
    request(invokeRoute, verb, data)
  end

  # Alias for invoke
  def invoke_flo(floAlias, data, verb="POST")
    invoke(floAlias, verb, data)
  end
<commit_msg>Add better error message<commit_after>require "rubygems"
require "json"
require "openssl"
require "time"
require "net/https"
require "uri"

class Azuqua
  VERSION = "1.0.0"

	HTTP_OPTIONS = {
		:host => "https://api.azuqua.com", 
		:headers => {
			"Content-Type" => "application/json"
		}
	}

  @accessKey = nil
  @accessSecret = nil

  def initialize(key, secret)
    @accessKey = key
    @accessSecret = secret
    raise "Invalid account credentials" unless @accessKey && @accessSecret
  end

  def self.from_config(path)
    open(path, "r") do |file|
      data = JSON.parse(file.read)
      accessKey = data["accessKey"]
      accessSecret = data["accessSecret"]
      Azuqua.new(accessKey, accessSecret)
    end
  end

  def self.from_env()
      accessKey = ENV["AZUQUA_ACCESS_KEY"]
      accessSecret = ENV["AZUQUA_ACCESS_SECRET"]
      Azuqua.new(accessKey, accessSecret)
  end

  def account
    unless @accessKey.nil? || @accessSecret.nil?
      {
        :accessKey => @accessKey,
        :accessSecret => @accessSecret
      }
    else
      raise "Invalid account credentials. Missing accessKey or accessSecret"
    end
  end

  # Invokes an Azuqua Flo
  def invoke(floAlias, data, verb="POST")
    invokeRoute = "/flo/" + floAlias + "/invoke";
    request(invokeRoute, verb, data)
  end

  # Alias for invoke
  def invoke_flo(floAlias, data, verb="POST")
    invoke(floAlias, verb, data)
  end

{'fraction_non_alphanumeric': 0.12085137085137085, 'fraction_numerical': 0.0021645021645021645, 'mean_word_length': 3.1081481481481483, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, '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': '3177365', 'n_tokens_mistral': 974, 'n_tokens_neox': 916, 'n_words': 225}