<commit_before>require 'sinatra'
require 'sinatra/reloader' if development?
require 'httparty'
require 'dotenv'
Dotenv.load

puts
puts 'Environment'
puts "CONTROL_API_BASE_URI=#{ENV['CONTROL_API_BASE_URI']}"
puts

# # API Documentation
#
# This class uses a library called `HTTParty` to connect to the Control API.  In general, all API responses are JSON.  `HTTParty` automatically detects this and parses into a Ruby object.
class ControlAPI
  include HTTParty
  base_uri ENV['CONTROL_API_BASE_URI']
end

# ## GET /v1/status
#
# Check the API status.  Useful for testing authentication without knowing other information.
#
# ### Example request
#
#     GET /v1/status
#
# ### Example response
#
# #### HTTP 200 OK
#
#     {"description":"up"}
#
# #### HTTP 500 Server Error
#
# ### Response fields
#
#   * `description`: A text description of the API state.
#
get '/' do
  status = ControlAPI.get('/v1/status')
  "API status: #{status['description']}"
end

# ## POST /v1/distributed_to_dos
#
# **Asynchronously** distribute a ToDo to the given assignees.
#
# ### Example request
#
#     POST /v1/distributed_to_dos
#     template_to_do_api_id=12345678-1234-5678-1234-567812345678
#     assignee_emails=<EMAIL>,<EMAIL>,<EMAIL>,<EMAIL>
#     content={"field1":"value1"}
#
# ### Request fields
#
#   * `template_to_do_api_id`: **Required**.  The UUID for the TemplateToDo that will be distributed.  This can be found in settings.
#   * `assignee_emails`: **Required**.  A comma separated list of emails of Users that will receive the DistributedToDos.
#   * `content`: JSON text of values to pre-fill in the DistributedToDo.  Field names are available under "Settings".
#
# ### Example responses
#
# #### HTTP 201 Accepted
#<commit_msg>Should be HTTP 202<commit_after>require 'sinatra'
require 'sinatra/reloader' if development?
require 'httparty'
require 'dotenv'
Dotenv.load

puts
puts 'Environment'
puts "CONTROL_API_BASE_URI=#{ENV['CONTROL_API_BASE_URI']}"
puts

# # API Documentation
#
# This class uses a library called `HTTParty` to connect to the Control API.  In general, all API responses are JSON.  `HTTParty` automatically detects this and parses into a Ruby object.
class ControlAPI
  include HTTParty
  base_uri ENV['CONTROL_API_BASE_URI']
end

# ## GET /v1/status
#
# Check the API status.  Useful for testing authentication without knowing other information.
#
# ### Example request
#
#     GET /v1/status
#
# ### Example response
#
# #### HTTP 200 OK
#
#     {"description":"up"}
#
# #### HTTP 500 Server Error
#
# ### Response fields
#
#   * `description`: A text description of the API state.
#
get '/' do
  status = ControlAPI.get('/v1/status')
  "API status: #{status['description']}"
end

# ## POST /v1/distributed_to_dos
#
# **Asynchronously** distribute a ToDo to the given assignees.
#
# ### Example request
#
#     POST /v1/distributed_to_dos
#     template_to_do_api_id=12345678-1234-5678-1234-567812345678
#     assignee_emails=<EMAIL>,<EMAIL>,<EMAIL>,<EMAIL>
#     content={"field1":"value1"}
#
# ### Request fields
#
#   * `template_to_do_api_id`: **Required**.  The UUID for the TemplateToDo that will be distributed.  This can be found in settings.
#   * `assignee_emails`: **Required**.  A comma separated list of emails of Users that will receive the DistributedToDos.
#   * `content`: JSON text of values to pre-fill in the DistributedToDo.  Field names are available under "Settings".
#
# ### Example responses
#
# #### HTTP 202 Accepted
#
{'fraction_non_alphanumeric': 0.12669162107687879, 'fraction_numerical': 0.028505614742297725, 'mean_word_length': 4.411214953271028, 'pattern_counts': {'":': 4, '<': 11, '<?xml version=': 0, '>': 11, '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': '1096575', 'n_tokens_mistral': 1207, 'n_tokens_neox': 1125, 'n_words': 351}