Class: LedgerSync::Adaptors::Test::Account::Searcher

Inherits:
Searcher
  • Object
show all
Defined in:
lib/ledger_sync/adaptors/test/account/searcher.rb

Instance Attribute Summary

Attributes inherited from Searcher

#adaptor, #pagination, #query

Instance Method Summary collapse

Methods inherited from Searcher

#initialize

Constructor Details

This class inherits a constructor from LedgerSync::Adaptors::Searcher

Instance Method Details

#next_searcherObject



6
7
8
# File 'lib/ledger_sync/adaptors/test/account/searcher.rb', line 6

def next_searcher
  paginate(cursor: 'asdf')
end

#previous_searcherObject



10
11
12
# File 'lib/ledger_sync/adaptors/test/account/searcher.rb', line 10

def previous_searcher
  paginate(cursor: 'asdf')
end

#resourcesObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/ledger_sync/adaptors/test/account/searcher.rb', line 14

def resources
  @resources ||= begin
    adaptor
      .query(
        resource: 'account',
        query: "name LIKE '#{query}%'"
      )
      .map do |a|
        LedgerSync::Account.new(
          ledger_id: a.fetch('id'),
          name: a.fetch('name', ''),
          account_type: a.fetch('account_type', '')
        )
      end
  end
end

#searchObject



31
32
33
34
35
# File 'lib/ledger_sync/adaptors/test/account/searcher.rb', line 31

def search
  super
rescue OAuth2::Error => e
  failure(e)
end