Class: QuestradeApi::REST::Activity

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

Overview

Author:

Constant Summary

Constants inherited from Base

Base::BASE_ENDPOINT

Instance Attribute Summary collapse

Attributes inherited from Base

#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) ⇒ Activity

Returns a new instance of Activity.



9
10
11
12
13
14
# File 'lib/questrade_api/rest/activity.rb', line 9

def initialize(params)
  @account_id = params[:account_id]

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

Instance Attribute Details

#account_idObject

Returns the value of attribute account_id.



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

def 
  @account_id
end

Class Method Details

.endpoint(account_id) ⇒ Object



39
40
41
# File 'lib/questrade_api/rest/activity.rb', line 39

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

.fetch(authorization, account_number, params) ⇒ Object

Fetch account activities

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'



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

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

  result = OpenStruct.new(activities: [])

  if response.status == 200
    result.activities = parse_activities(, response.body)
  end

  result
end