Class: Tastytrade::Client

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

Instance Attribute Summary

Attributes included from Authentication

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

Instance Method Summary collapse

Methods included from Error

raise_error

Methods included from Authentication

#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.



16
17
18
19
20
21
22
23
# File 'lib/tastytrade/client.rb', line 16

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

Instance Method Details

#get_account(account_number:) ⇒ Object



45
46
47
# File 'lib/tastytrade/client.rb', line 45

def (account_number:)
  Operations::CustomerAccountInfo::GetAccount.new(self).call(account_number:)
end

#get_customerObject



37
38
39
# File 'lib/tastytrade/client.rb', line 37

def get_customer
  Operations::CustomerAccountInfo::GetCustomer.new(self).call
end

#get_total_fees(account_number:, **options) ⇒ Object



25
26
27
# File 'lib/tastytrade/client.rb', line 25

def get_total_fees(account_number:, **options)
  Operations::AccountTransactions::GetTotalFees.new(self).call(account_number:, **options)
end

#get_transaction(account_number:, id:) ⇒ Object



29
30
31
# File 'lib/tastytrade/client.rb', line 29

def get_transaction(account_number:, id:)
  Operations::AccountTransactions::GetTransaction.new(self).call(account_number:, id:)
end

#list_customer_accountsObject



41
42
43
# File 'lib/tastytrade/client.rb', line 41

def list_customer_accounts
  Operations::CustomerAccountInfo::ListCustomerAccounts.new(self).call
end

#list_transactions(account_number:, **options) ⇒ Object



33
34
35
# File 'lib/tastytrade/client.rb', line 33

def list_transactions(account_number:, **options)
  Operations::AccountTransactions::ListTransactions.new(self).call(account_number:, **options)
end