<commit_before>require './api_accessor'
require './utils/request_parser'

# QueremoSaber just requires title, description, name, email.

puts 'Starting ...'
api = ApiAccessor.new

response = api.get_bodies(18)
json_res = JSON.parse(response.body)
puts JSON.pretty_generate(json_res)

=begin
9.times do |i|
  response = api.get_bodies(nil, i+1)
  json_res = JSON.parse(response.body)
  puts JSON.pretty_generate(json_res)
end
=end<commit_msg>Code for RequestController and RequestMailer<commit_after>require './services/api_accessor'
require './services/request_parser'

# QueremoSaber just requires title, description, name, email.

# RequestController

request = RequestParser.parse(@info_request, @outgoing_message)

api = ApiAccessor.new
response = api.post_request(request)
req_json = JSON.parse(response.body)
@info_request.id_gov = req_json['id'].to_i
@info_request.save!

# RequestController end


# RequestMailer

api = ApiAccessor.new
request_id = reply_info_request.id_gov.to_i
req_flow_response = api.get_request_flow request_id
req_flows = JSON.parse(req_flow_response.body)

# Not sure if needed, but consulted Gaby and
# she told that the results are not ordered.
# So to prevent its better to sort
req_flows.sort_by! { |hash| hash['id'] }
most_recent = req_flows[ req_flows.size - 1 ]

new_mail = Mail.new do
  to      '<EMAIL>'
  from    'API'
  subject 'Respuesta de la solicitud de informacion'
  body most_recent['comentario']
end

raw_email = new_mail.to_s

# RequestMailer end
{'fraction_non_alphanumeric': 0.10287241148964596, 'fraction_numerical': 0.0033400133600534404, 'mean_word_length': 5.2677824267782425, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, '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': '7066495', 'n_tokens_mistral': 525, 'n_tokens_neox': 511, 'n_words': 124}