require 'net/http' namespace :bot do namespace :kik do desc "Update a bot config" task :configure => :environment do uri = URI.parse("https://api.kik.com/v1/config") request = Net::HTTP::Post.new(uri.request_uri, initheader = { "Content-Type" => "application/json" }) request.basic_auth Bot.configuration.adapter.config[:bot_user], Bot.configuration.adapter.config[:bot_token] request.body = { webhook: "#{ENV['CALLBACK_URL']}", features: { manuallySendReadReceipts: false, receiveReadReceipts: false, receiveDeliveryReceipts: false, receiveIsTyping: false } }.to_json http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = (uri.scheme == "https") response = http.request(request) if response.code == "200" puts "Configured okay!" else puts "Error: #{response.body}" end end end end