Class: Schwab::Operations::GetQuotes

Inherits:
BaseOperation show all
Defined in:
lib/schwab/operations/get_quotes.rb

Constant Summary collapse

FIELDS =
%i[quote extended fundamental reference regular]

Constants inherited from BaseOperation

BaseOperation::HTTP_DEBUG_OUTPUT

Instance Attribute Summary

Attributes inherited from BaseOperation

#client

Instance Method Summary collapse

Methods inherited from BaseOperation

#initialize

Methods included from Util

response_success?

Methods included from Error

raise_error

Constructor Details

This class inherits a constructor from Schwab::Operations::BaseOperation

Instance Method Details

#call(symbols: [], fields: []) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/schwab/operations/get_quotes.rb', line 8

def call(symbols: [], fields: [])
  if fields.present? && fields.any? { |field| FIELDS.exclude?(field) }
    raise(ArgumentError, "all fields must be in #{FIELDS}, got #{fields}")
  end

  params = {
    symbols: symbols.join(','),
  }
  params.merge!(fields: fields.join(',')) if fields.present?

  perform_api_get_request(
    url: "https://api.schwabapi.com/marketdata/v1/quotes",
    query: params,
  )
end