Class: TesoteSdk::V1::Transactions

Inherits:
Object
  • Object
show all
Defined in:
lib/tesote_sdk/v1/transactions.rb

Constant Summary collapse

SHOW_CACHE_TTL =
300

Instance Method Summary collapse

Constructor Details

#initialize(transport) ⇒ Transactions

Returns a new instance of Transactions.



6
7
8
# File 'lib/tesote_sdk/v1/transactions.rb', line 6

def initialize(transport)
  @transport = transport
end

Instance Method Details

#get(id, opts: {}) ⇒ Object

GET /v1/transactions/id

Raises:

  • (ArgumentError)


21
22
23
24
25
26
27
# File 'lib/tesote_sdk/v1/transactions.rb', line 21

def get(id, opts: {})
  raise ArgumentError, 'id is required' if id.nil? || id.to_s.empty?

  merged = opts.key?(:cache) ? opts : opts.merge(cache: { ttl: SHOW_CACHE_TTL })
  body = @transport.request('GET', "transactions/#{id}", opts: merged)
  Models::Transaction.from_hash(body)
end

#list_for_account(account_id, query = {}, opts: {}) ⇒ Object

GET /v1/accounts/id/transactions — convenience pass-through to V1::Accounts#list_transactions for callers that prefer to start from the transactions client.

Raises:

  • (ArgumentError)


13
14
15
16
17
18
# File 'lib/tesote_sdk/v1/transactions.rb', line 13

def (, query = {}, opts: {})
  raise ArgumentError, 'account_id is required' if .nil? || .to_s.empty?

  body = @transport.request('GET', "accounts/#{}/transactions", query: query, opts: opts)
  Models::TransactionList.from_hash(body)
end