class QuestradeApi::REST::Execution
@author Bruno Meira <goesmeira@gmail.com>
Public Class Methods
endpoint(account_id)
click to toggle source
# File lib/questrade_api/rest/execution.rb, line 38 def self.endpoint(account_id) "#{BASE_ENDPOINT}/accounts/#{account_id}/executions" end
fetch(authorization, account_number, params)
click to toggle source
Fetch account executions
@param authorization [QuestradeApi::Authorization] with the authorized access_token and url
. @param account_number [String] with the account the activities will be fetched @param params [Hash] with the range of dates the activities will be fetched @option params [String] :startTime The start time. ex: '2011-02-16T00:00:00.000000-05:00' @option params [String] :endTime The end time. ex: '2011-02-16T00:00:00.000000-05:00'
Calls superclass method
QuestradeApi::REST::Base#fetch
# File lib/questrade_api/rest/execution.rb, line 22 def self.fetch(authorization, account_number, params) response = super(access_token: authorization.access_token, endpoint: endpoint(account_number), url: authorization.url, params: params) result = OpenStruct.new(executions: []) if response.status == 200 result.executions = parse_executions(account_number, response.body) end result end
new(params)
click to toggle source
# File lib/questrade_api/rest/execution.rb, line 7 def initialize(params) @account_id = params[:account_id] @raw_body = params[:data] build_data(params[:data]) if @raw_body end
Private Class Methods
parse_executions(account_id, body)
click to toggle source
# File lib/questrade_api/rest/execution.rb, line 42 def self.parse_executions(account_id, body) raw = JSON.parse(body) executions = [] raw['executions'].each do |execution| executions << new(account_id: account_id, data: execution) end executions end