Class: LatestStockPrice::Prices

Inherits:
Object
  • Object
show all
Defined in:
lib/prices.rb

Constant Summary collapse

API_BASE_URL =
"https://latest-stock-price.p.rapidapi.com/equities-enhanced"

Class Method Summary collapse

Class Method Details

.fetch(symbols) ⇒ Object

Param example - [‘AAATECH.NS’, ‘AADHHOUS.NS’]

Raises:

  • (ArgumentError)


5
6
7
8
9
10
11
# File 'lib/prices.rb', line 5

def self.fetch(symbols) # Param example - ['AAATECH.NS', 'AADHHOUS.NS']
  raise ArgumentError, "Search term cannot be nil or empty" if symbols.nil? || symbols.empty? # could improve by checking each array item

			symbols_param = URI.encode_www_form_component(symbols.join(','))
  uri = URI("#{API_BASE_URL}?Symbols=#{symbols_param}")
			LatestStockPrice::HttpClient.make_request(uri)
end