Class: QuestradeApi::REST::OptionQuote

Inherits:
Base
  • Object
show all
Defined in:
lib/questrade_api/rest/option_quote.rb

Constant Summary

Constants inherited from Base

Base::BASE_ENDPOINT

Instance Attribute Summary

Attributes inherited from Base

#account_id, #authorization, #connection, #data, #endpoint, #id, #raw_body

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#build_attributes, #build_data, connection, #fetch, post, #url

Constructor Details

#initialize(params) ⇒ OptionQuote

Returns a new instance of OptionQuote.



6
7
8
9
# File 'lib/questrade_api/rest/option_quote.rb', line 6

def initialize(params)
  @raw_body = params[:data]
  build_data(params[:data]) if @raw_body
end

Class Method Details

.endpointObject



26
27
28
# File 'lib/questrade_api/rest/option_quote.rb', line 26

def self.endpoint
  "#{BASE_ENDPOINT}/markets/quotes/options"
end

.fetch(authorization, params) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/questrade_api/rest/option_quote.rb', line 11

def self.fetch(authorization, params)
  response = post(access_token: authorization.access_token,
                  endpoint: endpoint,
                  url: authorization.url,
                  body: params.to_json)

  if response.status == 200
    result = OpenStruct.new(optionQuotes: [])
    result.optionQuotes = parse_option_quotes(response.body)
    response = result
  end

  response
end