Class: LatestStockPrice::Price

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

Constant Summary collapse

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

Class Method Summary collapse

Class Method Details

.fetch(search_term) ⇒ Object

Param example - “AAATECH.NS”

Raises:

  • (ArgumentError)


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

def self.fetch(search_term) # Param example - "AAATECH.NS"
  raise ArgumentError, "Search term cannot be nil or empty" if search_term.nil? || search_term.strip.empty?

  encoded_term = URI.encode_www_form_component(search_term)
  uri = URI("#{API_BASE_URL}?Search=#{encoded_term}")
			LatestStockPrice::HttpClient.make_request(uri)
end