Class: StocktickerCli::API
- Inherits:
-
Object
- Object
- StocktickerCli::API
- Defined in:
- lib/stockticker_cli/api.rb
Constant Summary collapse
- BASE_URL =
'https://fmpcloud.io/api/v3/'
Class Method Summary collapse
Class Method Details
.info_query(stock_obj) ⇒ Object
18 19 20 21 22 |
# File 'lib/stockticker_cli/api.rb', line 18 def self.info_query(stock_obj) results = RestClient.get("#{BASE_URL}profile/#{stock_obj.ticker}?apikey=#{$KEY}") json = JSON.parse(results) stock_obj.set_attributes(json[0]) end |
.query ⇒ Object
Api call
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/stockticker_cli/api.rb', line 6 def self.query # https://fmpcloud.io/api/v3/actives?apikey=4b31fc84cd3248a0f61868b96f531bde results = RestClient.get("#{BASE_URL}actives?apikey=#{$KEY}") json = JSON.parse(results) # iterating through results and creating stock instances json.each do |stock_hash| StocktickerCli::STOCK.new(stock_hash) end end |