Class: LatestStockPrice::Prices
- Inherits:
-
Object
- Object
- LatestStockPrice::Prices
- Defined in:
- lib/prices.rb
Constant Summary collapse
- API_BASE_URL =
"https://latest-stock-price.p.rapidapi.com/equities-enhanced"
Class Method Summary collapse
-
.fetch(symbols) ⇒ Object
Param example - [‘AAATECH.NS’, ‘AADHHOUS.NS’].
Class Method Details
.fetch(symbols) ⇒ Object
Param example - [‘AAATECH.NS’, ‘AADHHOUS.NS’]
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 |