Class: QuestradeApi::REST::Execution

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

Overview

Author:

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) ⇒ Execution

Returns a new instance of Execution.



7
8
9
10
11
12
# 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

Class Method Details

.endpoint(account_id) ⇒ Object



38
39
40
# File 'lib/questrade_api/rest/execution.rb', line 38

def self.endpoint()
  "#{BASE_ENDPOINT}/accounts/#{}/executions"
end

.fetch(authorization, account_number, params) ⇒ Object

Fetch account executions

Parameters:

  • authorization (QuestradeApi::Authorization)

    with the authorized #access_token and #url.

  • account_number (String)

    with the account the activities will be fetched

  • params (Hash)

    with the range of dates the activities will be fetched

Options Hash (params):

  • :startTime (String)

    The start time. ex: '2011-02-16T00:00:00.000000-05:00'

  • :endTime (String)

    The end time. ex: '2011-02-16T00:00:00.000000-05:00'



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/questrade_api/rest/execution.rb', line 22

def self.fetch(authorization, , params)

  response = super(access_token: authorization.access_token,
                   endpoint: endpoint(),
                   url: authorization.url,
                   params: params)

  result = OpenStruct.new(executions: [])

  if response.status == 200
    result.executions = parse_executions(, response.body)
  end

  result
end