Class: Schwab::Client

Inherits:
Object
  • Object
show all
Includes:
Authentication, Error
Defined in:
lib/schwab/client.rb

Instance Attribute Summary

Attributes included from Authentication

#access_token, #access_token_expires_at, #authorization_code, #client_id, #redirect_uri, #refresh_token, #refresh_token_expires_at, #secret

Instance Method Summary collapse

Methods included from Error

raise_error

Methods included from Authentication

#authorization_header_token, #default_headers, #refresh_access_token, #request_access_token

Methods included from Util

response_success?

Constructor Details

#initialize(**args) ⇒ Client

Returns a new instance of Client.



17
18
19
20
21
22
23
24
25
# File 'lib/schwab/client.rb', line 17

def initialize(**args)
  @access_token = args[:access_token]
  @refresh_token = args[:refresh_token]
  @access_token_expires_at = args[:access_token_expires_at]
  @refresh_token_expires_at = args[:refresh_token_expires_at]
  @client_id = args[:client_id] || raise_error('client_id is required!')
  @secret = args[:secret] || raise_error('client_id is required!')
  @redirect_uri = args[:redirect_uri] || raise_error('redirect_uri is required!')
end

Instance Method Details

#get_account_numbersObject



31
32
33
# File 'lib/schwab/client.rb', line 31

def 
  Operations::GetAccountNumbers.new(self).call
end

#get_accounts(fields = nil) ⇒ Object



27
28
29
# File 'lib/schwab/client.rb', line 27

def get_accounts(fields=nil)
  Operations::GetAccounts.new(self).call(fields:)
end

#get_instrument(symbol, projection) ⇒ Object



35
36
37
# File 'lib/schwab/client.rb', line 35

def get_instrument(symbol, projection)
  Operations::GetInstrument.new(self).call(symbol, projection:)
end

#get_instrument_by_cusip(cusip) ⇒ Object



39
40
41
# File 'lib/schwab/client.rb', line 39

def get_instrument_by_cusip(cusip)
  Operations::GetInstrumentByCusip.new(self).call(cusip)
end

#get_price_history(symbol, **options) ⇒ Object



43
44
45
# File 'lib/schwab/client.rb', line 43

def get_price_history(symbol, **options)
  Operations::GetPriceHistory.new(self).call(symbol, **options)
end

#get_quotes(symbols, **options) ⇒ Object



47
48
49
# File 'lib/schwab/client.rb', line 47

def get_quotes(symbols, **options)
  Operations::GetQuotes.new(self).call(symbols:, **options)
end

#get_transactionsObject



51
52
53
# File 'lib/schwab/client.rb', line 51

def get_transactions(...)
  Operations::GetTransactions.new(self).call(...)
end