<commit_before>namespace :nestgraphing do
  task fetchdata: :environment do
    Device.all.each do |device|
      puts "Creating record for " + device.name

      device.create_new_record
    end
  end

  task providecredentials: :environment do
    nest = NestApi::Api.new

    @remotedevices   =  nest.get_thermostat_list
  end
end<commit_msg>Taking another crack at Heroku Nest API authentication<commit_after>namespace :nestgraphing do
  task fetchdata: :environment do
    Device.all.each do |device|
      puts "Creating record for " + device.name

      device.create_new_record
    end
  end

  task providecredentials: :environment do

    puts "Go:"
    pin = STDIN.gets.strip
    
    HTTParty.post("#{NestApi::TOKEN_URL}", query: {
        code: pin,
        client_id: ENV['NEST_PRODUCT_ID'],
        client_secret: ENV['NEST_PRODUCT_SECRET'],
        grant_type: 'authorization_code'
    })

    File.open(@file, "w") { |file| file.write(result.to_json) }

  end
end
{'fraction_non_alphanumeric': 0.09489795918367347, 'fraction_numerical': 0.0, 'mean_word_length': 3.174468085106383, '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': '1528686', 'n_tokens_mistral': 329, 'n_tokens_neox': 315, 'n_words': 76}