Class: Schwab::Operations::GetTransactions

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

Constant Summary collapse

TYPES =
%w[
  TRADE
  RECEIVE_AND_DELIVER
  DIVIDEND_OR_INTEREST
  ACH_RECEIPT
  ACH_DISBURSEMENT
  CASH_RECEIPT
  CASH_DISBURSEMENT
  ELECTRONIC_FUND
  WIRE_OUT
  WIRE_IN
  JOURNAL
  MEMORANDUM
  MARGIN_CALL
  MONEY_MARKET
  SMA_ADJUSTMENT
]

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(account_number:, start_date:, end_date:, types:, symbol: nil) ⇒ Object

Raises:

  • (ArgumentError)


24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/schwab/operations/get_transactions.rb', line 24

def call(account_number:, start_date:, end_date:, types:, symbol: nil)
  raise(ArgumentError, "types must be one of #{TYPES}") unless TYPES.include?(types)
  raise(ArgumentError, "start_date and end_date must be Time") unless [start_date, end_date].all?(Time)

  params = {
    startDate: start_date.utc.iso8601,
    endDate: end_date.utc.iso8601,
    types:,
  }
  params.merge!(symbol:) if symbol

  response = perform_api_get_request(
    url: "https://api.schwabapi.com/trader/v1/accounts/#{}/transactions",
    query: params,
    )

  response
end