diff --git a/.gitignore b/.gitignore index 232ab1d..f46a52d 100644 --- a/.gitignore +++ b/.gitignore @@ -33,6 +33,7 @@ # Ignore master key for decrypting credentials and more. /config/master.key +/config/api_keys.rb # ignore local database.yml /config/database.yml diff --git a/app/jobs/stock_prices_update_job.rb b/app/jobs/stock_prices_update_job.rb index d46f994..c7094b3 100644 --- a/app/jobs/stock_prices_update_job.rb +++ b/app/jobs/stock_prices_update_job.rb @@ -4,5 +4,18 @@ class StockPricesUpdateJob < ApplicationJob def perform(*args) # For each stock symbol, request the latest closing cost # update the stocks table with each new closing cost + stock_symbols = ["KO", "SNE", "TWX", "DIS", "SIRI", "F", "EA", "FB", "UA", "LUV", "GPS"] + stock_symbols.each do |symbol| + api_request(symbol) + stock_db = Stock.find_by(ticker: symbol) + end + end + + private + + def api_request(symbol) + url = "https://www.alphavantage.co/query?function=GLOBAL_QUOTE&symbol=#{symbol}&apikey=#{API_KEY}" + uri = URI.parse(url) + print Net::HTTP.get(uri) end end